Skip to contentSkip to conversation

devtmpfs default permissions

DISCUSSION Mark Rosenstand 3 participants 10 messages Oct 29, 2009 – Nov 5, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi,

I've been using the devtmpfs patch for 2.6.31 and recently mainline 2.6.32-rc5. I've noticed that /dev now have default tmpfs permissions, i.e. 1777.

CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y

One can chmod the directory, but would it not make sense to use a more less permissive mode (e.g. 0755) by default?

Thanks for working out this feature, the "just works" of devfs together with the configurability of udev - love it :)

#1 lore raw
Quoted 11 lines · Mark Rosenstand

Hi,

I've been using the devtmpfs patch for 2.6.31 and recently mainline 2.6.32-rc5. I've noticed that /dev now have default tmpfs permissions, i.e. 1777.

CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y

One can chmod the directory, but would it not make sense to use a more less permissive mode (e.g. 0755) by default?

I think the patch sent by Kay to the linux-kernel mailing list yesterday will solve this problem. It uses the default umask instead.

Can you test it out to verify this?

Quoted 2 lines

Thanks for working out this feature, the "just works" of devfs together with the configurability of udev - love it :)

Glad you like it.

thanks,

greg k-h

#2 lore raw
In reply to Mark Rosenstand
Quoted 8 lines · Greg KH
Quoted 7 lines · Mark Rosenstand

I've been using the devtmpfs patch for 2.6.31 and recently mainline 2.6.32-rc5.  I've noticed that /dev now have default tmpfs permissions, i.e. 1777.

One can chmod the directory, but would it not make sense to use a more less permissive mode (e.g. 0755) by default?

Yeah, sounds good.

Quoted 4 lines

I think the patch sent by Kay to the linux-kernel mailing list yesterday will solve this problem.  It uses the default umask instead.

Can you test it out to verify this?

I'll prepare a patch to fix that, we need to pass "mode55" to the mount command, to set the tmpfs root directory mode.

Thanks,
Kay

#3 lore raw
In reply to Mark Rosenstand
Quoted 16 lines · Kay Sievers
Quoted 8 lines · Greg KH
Quoted 7 lines · Mark Rosenstand

I've been using the devtmpfs patch for 2.6.31 and recently mainline 2.6.32-rc5. I've noticed that /dev now have default tmpfs permissions, i.e. 1777.

One can chmod the directory, but would it not make sense to use a more less permissive mode (e.g. 0755) by default?

Yeah, sounds good.

Quoted 4 lines

I think the patch sent by Kay to the linux-kernel mailing list yesterday will solve this problem. It uses the default umask instead.

Can you test it out to verify this?

Default umask would probably be even better than a hardcoded one. Just tried latest git, seems to still get 1777 permissions.

Quoted 2 lines

I'll prepare a patch to fix that, we need to pass "mode55" to the mount command, to set the tmpfs root directory mode.

Thanks guys, rock on! :)

#4 lore raw
In reply to Mark Rosenstand
Quoted 18 lines · Mark Rosenstand
Quoted 16 lines · Kay Sievers
Quoted 8 lines · Greg KH
Quoted 7 lines · Mark Rosenstand

I've been using the devtmpfs patch for 2.6.31 and recently mainline 2.6.32-rc5. I've noticed that /dev now have default tmpfs permissions, i.e. 1777.

One can chmod the directory, but would it not make sense to use a more less permissive mode (e.g. 0755) by default?

Yeah, sounds good.

Quoted 4 lines

I think the patch sent by Kay to the linux-kernel mailing list yesterday will solve this problem. It uses the default umask instead.

Can you test it out to verify this?

Quoted 7 lines

Default umask would probably be even better than a hardcoded one. Just tried latest git, seems to still get 1777 permissions.

Quoted 2 lines

I'll prepare a patch to fix that, we need to pass "mode55" to the mount command, to set the tmpfs root directory mode.

Thanks guys, rock on! :)

Thanks! This works for me.

From: Kay Sievers <[email protected]>
Subject: Driver-Core: devtmpfs - set root directory mode to 0755

---
 drivers/base/devtmpfs.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/devtmpfs.c +1 -1
@@ -359,7 +359,7 @@ int __init devtmpfs_init(void)
 		return err;
 	}
 
-	mnt = kern_mount(&dev_fs_type);
+	mnt = kern_mount_data(&dev_fs_type, "mode55");
 	if (IS_ERR(mnt)) {
 		err = PTR_ERR(mnt);
 		printk(KERN_ERR "devtmpfs: unable to create devtmpfs %i\n", err);
#5 lore raw
In reply to Mark Rosenstand
Quoted 41 lines · Kay Sievers
Quoted 18 lines · Mark Rosenstand
Quoted 16 lines · Kay Sievers
Quoted 8 lines · Greg KH
Quoted 7 lines · Mark Rosenstand

I've been using the devtmpfs patch for 2.6.31 and recently mainline 2.6.32-rc5. I've noticed that /dev now have default tmpfs permissions, i.e. 1777.

One can chmod the directory, but would it not make sense to use a more less permissive mode (e.g. 0755) by default?

Yeah, sounds good.

Quoted 4 lines

I think the patch sent by Kay to the linux-kernel mailing list yesterday will solve this problem. It uses the default umask instead.

Can you test it out to verify this?

Quoted 7 lines

Default umask would probably be even better than a hardcoded one. Just tried latest git, seems to still get 1777 permissions.

Quoted 2 lines

I'll prepare a patch to fix that, we need to pass "mode55" to the mount command, to set the tmpfs root directory mode.

Thanks guys, rock on! :)

Thanks! This works for me.

From: Kay Sievers <[email protected]>
Subject: Driver-Core: devtmpfs - set root directory mode to 0755

---
 drivers/base/devtmpfs.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

drivers/base/devtmpfs.c int __init devtmpfs_init(void) · line 365

Quoted 8 lines
drivers/base/devtmpfs.c +1 -1
@@ -359,7 +359,7 @@ int __init devtmpfs_init(void)
 		return err;
 	}
 
-	mnt = kern_mount(&dev_fs_type);
+	mnt = kern_mount_data(&dev_fs_type, "mode55");
 	if (IS_ERR(mnt)) {
 		err = PTR_ERR(mnt);
 		printk(KERN_ERR "devtmpfs: unable to create devtmpfs %i\n", err);

Works here too. Getting this on the console, though:

tmpfs: No value for mount option 'mode'

But hey, it works. Thanks :)

#6 lore raw
In reply to Mark Rosenstand
Quoted 5 lines · Mark Rosenstand

Works here too. Getting this on the console, though:

tmpfs: No value for mount option 'mode'

But hey, it works. Thanks :)

Yeah, the tmpfs code mangles *data, and as we get a single superblock, remount is called during mount, and the tmpfs code tries to parse *data again which it destroyed in the first run. It's harmless and needs to be fixed, but I'm not sure which piece to fix at the moment. :)

Thanks,
Kay

#7 lore raw
In reply to Mark Rosenstand
Quoted 5 lines · Kay Sievers
Quoted 4 lines · Mark Rosenstand

Works here too. Getting this on the console, though:

tmpfs: No value for mount option 'mode'

Quoted 7 lines
Quoted 1 line

But hey, it works. Thanks :)

Yeah, the tmpfs code mangles *data, and as we get a single superblock, remount is called during mount, and the tmpfs code tries to parse *data again which it destroyed in the first run. It's harmless and needs to be fixed, but I'm not sure which piece to fix at the moment. :)

This seems to work here.

Thanks,
Kay

From: Kay Sievers <[email protected]>
Subject: tmpfs: zap options after mangling them during parsing

Zap options list we have destroyed during parsing, to prevent errors on repeated calls, like in the case we do kern_mount() which might do an implicit remount() call.

---
 mm/shmem.c |   26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)
mm/shmem.c +18 -8
@@ -2147,22 +2147,26 @@ static const struct export_operations sh
 static int shmem_parse_options(char *options, struct shmem_sb_info *sbinfo,
 			       bool remount)
 {
-	char *this_char, *value, *rest;
+	char *option, *value, *this_char, *rest;
 
-	while (options != NULL) {
-		this_char = options;
+	if (!options || !options[0])
+		return 0;
+
+	option = options;
+	while (option != NULL) {
+		this_char = option;
 		for (;;) {
 			/*
 			 * NUL-terminate this option: unfortunately,
 			 * mount options form a comma-separated list,
 			 * but mpol's nodelist may also contain commas.
 			 */
-			options = strchr(options, ',');
-			if (options = NULL)
+			option = strchr(option, ',');
+			if (option = NULL)
 				break;
-			options++;
-			if (!isdigit(*options)) {
-				options[-1] = '\0';
+			option++;
+			if (!isdigit(*option)) {
+				option[-1] = '\0';
 				break;
 			}
 		}
@@ -2225,6 +2229,12 @@ static int shmem_parse_options(char *opt
 			return 1;
 		}
 	}
+	/*
+	 * Zap options list we have destroyed during parsing, to prevent
+	 * errors on repeated calls, like in the case we do kern_mount()
+	 * which might do an implicit remount() call.
+	 */
+	options[0] = '\0';
 	return 0;
 
 bad_val:
#8 lore raw
In reply to Mark Rosenstand
Quoted 8 lines · Kay Sievers
Quoted 7 lines · Kay Sievers
Quoted 5 lines · Mark Rosenstand

Works here too. Getting this on the console, though:

tmpfs: No value for mount option 'mode'

But hey, it works. Thanks :)

Quoted 7 lines
Quoted 5 lines

Yeah, the tmpfs code mangles *data, and as we get a single superblock, remount is called during mount, and the tmpfs code tries to parse *data again which it destroyed in the first run. It's harmless and needs to be fixed, but I'm not sure which piece to fix at the moment. :)

This seems to work here.

Care to run it by Hugh?

thanks,

greg k-h

#9 lore raw
In reply to Mark Rosenstand
Quoted 15 lines · Greg KH
Quoted 14 lines · Kay Sievers
Quoted 12 lines · Kay Sievers
Quoted 5 lines · Mark Rosenstand

Works here too. Getting this on the console, though:

tmpfs: No value for mount option 'mode'

But hey, it works. Thanks :)

Yeah, the tmpfs code mangles *data, and as we get a single superblock, remount is called during mount, and the tmpfs code tries to parse *data again which it destroyed in the first run. It's harmless and needs to be fixed, but I'm not sure which piece to fix at the moment. :)

Quoted 3 lines
Quoted 1 line

This seems to work here.

Care to run it by Hugh?

Oh, I sent another possible, simpler fix to fsdevel:
http://article.gmane.org/gmane.linux.file-systems/36535

Let's wait for a response from them.

Thanks,
Kay