* carbonated beverage (ramune@net-ronin.org) wrote:
>
> It's rather annoying and counter-intuitive to have:
>
> crw-r----- 1 root kmem 1, 2 Sep 8 21:56 /dev/kmem
>
> but to have the following code fragment give:
>
> int fd;
> fd = open("/dev/kmem", O_RDONLY);
> if(fd == -1) {
> fprintf(stderr, "Can't open /dev/kmem: %s\n", strerror(errno));
> exit(EXIT_FAILURE);
> }
>
> Can't open /dev/kmem: Operation not permitted
>
> with a user in the kmem group.
>
> Also, the utility I'm writing doesn't need write access, so why give it to
> the process in the first place?
Then open O_RDONLY (with CAP_SYS_RAWIO). Then the utility won't have
write access. If that's all you are worried about.
or.
If you have only one capability (CAP_SYS_RAWIO), you are not owner of
/dev/kmem, you are in group kmem, and /dev/kmem is 0640, then all you will
get is read-only access to /dev/kmem. This does not require kernel changes.
thanks,
-chris
-- Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Sun Dec 15 2002 - 22:00:23 EST