[patch] add modes to open call of ismounted

Erik Hovland erik at hovland.org
Thu Jul 20 22:24:23 UTC 2006


The ismounted.c file makes a call to open using O_CREAT but does not
specify file permission modes. This is slightly dangerous since it is
plausible to exploit a file created with world writability. But is not
all that dangerous since the file does not live very long. It would take
a pretty savvy attacker to be able to slip in and do something bad
between the open and the unlink.

But anyway. Here is a patch for it.

E

-- 
Erik Hovland
mail: erik AT hovland DOT org
web: http://hovland.org/
PGP/GPG public key available on request
-------------- next part --------------
diff -Nurdp -x .svn -x busybox_old busybox-ro/e2fsprogs/ext2fs/ismounted.c busybox-trunk/e2fsprogs/ext2fs/ismounted.c
--- busybox-ro/e2fsprogs/ext2fs/ismounted.c	2006-07-14 16:07:58.704776346 -0700
+++ busybox-trunk/e2fsprogs/ext2fs/ismounted.c	2006-07-20 13:59:52.105631994 -0700
@@ -148,7 +148,7 @@ static errcode_t check_mntent_file(const
 is_root:
 #define TEST_FILE "/.ismount-test-file"
 		*mount_flags |= EXT2_MF_ISROOT;
-		fd = open(TEST_FILE, O_RDWR|O_CREAT);
+		fd = open(TEST_FILE, O_RDWR|O_CREAT, S_IRUSR | S_IWUSR);
 		if (fd < 0) {
 			if (errno == EROFS)
 				*mount_flags |= EXT2_MF_READONLY;


More information about the busybox mailing list