lkml.org 
[lkml]   [2002]   [Dec]   [11]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
DateWed, 11 Dec 2002 16:43:48 -0800
FromChris Wright <>
SubjectRe: capable open_port() check wrong for kmem
* 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/

\
 
 \ /
  Last update: 2005-03-22 12:31    [W:0.127 / U:0.310 seconds]
©2003-2008 Jasper Spaans