Skip to contentSkip to conversation

mkfs.ubifs: do not override root inode permissions

PATCH In review Artem Bityutskiy 2 participants 5 messages Sep 7, 2010 – Sep 8, 2010 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mkfs.ubifs: do not override root inode permissions

From: Artem Bityutskiy <[email protected]>

When mkfs.ubifs is used with -r dir, it does not make the root UBIFS inode uid/gid/permissions to be equivalent to dir's permissions, but it makes root inode permissions to be equivalent to uid = git = 0 (root) and permissions = u+rwx go+rx.

This patch changes the behavior and makes mkfs.ubifs use the permissions of the directory containing the original files on the host. I.e., it will be <dir>'s uid/git/permissions if case of mkfs.ubifs -r <dir>.

This patch is a bit dangerous because it changes the behavior and may have security implications if someone used the older version, relied on this bug, and upgrades to the newer version.

---
 mkfs.ubifs/mkfs.ubifs.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
mkfs.ubifs/mkfs.ubifs.c +1 -2
index 9f2a226..a4aebcb 100644
@@ -1639,9 +1639,8 @@ static int write_data(void)
 	} else {
 		root_st.st_mtime = time(NULL);
 		root_st.st_atime = root_st.st_ctime = root_st.st_mtime;
+		root_st.st_mode = S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
 	}
-	root_st.st_uid = root_st.st_gid = 0;
-	root_st.st_mode = S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
 
 	head_flags = 0;
 	err = add_directory(root, UBIFS_ROOT_INO, &root_st, !root);
Signature · 1 line
1.7.1.1
#1 lore raw

NOTE! mkfs.ubifs

Quoted 12 lines · Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>

When mkfs.ubifs is used with -r dir, it does not make the root UBIFS inode uid/gid/permissions to be equivalent to dir's permissions, but it makes root inode permissions to be equivalent to uid = git = 0 (root) and permissions = u+rwx go+rx.

This patch changes the behavior and makes mkfs.ubifs use the permissions of the directory containing the original files on the host. I.e., it will be <dir>'s uid/git/permissions if case of mkfs.ubifs -r <dir>.

Quoted 5 lines

This patch is a bit dangerous because it changes the behavior and may have security implications if someone used the older version, relied on this bug, and upgrades to the newer version.

All mkfs.ubifs users should take a look at this - should we apply this patch? I'm still in doubt...

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
#2 lore raw

Re: NOTE! mkfs.ubifs

Quoted 13 lines · Artem Bityutskiy
Quoted 12 lines · Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>

When mkfs.ubifs is used with -r dir, it does not make the root UBIFS inode uid/gid/permissions to be equivalent to dir's permissions, but it makes root inode permissions to be equivalent to uid = git = 0 (root) and permissions = u+rwx go+rx.

This patch changes the behavior and makes mkfs.ubifs use the permissions of the directory containing the original files on the host. I.e., it will be <dir>'s uid/git/permissions if case of mkfs.ubifs -r <dir>.

Quoted 9 lines
Quoted 5 lines

This patch is a bit dangerous because it changes the behavior and may have security implications if someone used the older version, relied on this bug, and upgrades to the newer version.

All mkfs.ubifs users should take a look at this - should we apply this patch? I'm still in doubt...

I do not agree with changing the behaviour. It should be a new option, and you could add a warning explaining what the root inode permissions are and why e.g.

Warning: Option ?? not used. Setting root inode permissions to blah

Warning: Option ?? used. Setting root inode permissions to blah

#3 lore raw

Re: NOTE! mkfs.ubifs

Quoted 20 lines · Adrian Hunter
Quoted 19 lines · Artem Bityutskiy
Quoted 17 lines · Artem Bityutskiy

From: Artem Bityutskiy <[email protected]>

When mkfs.ubifs is used with -r dir, it does not make the root UBIFS inode uid/gid/permissions to be equivalent to dir's permissions, but it makes root inode permissions to be equivalent to uid = git = 0 (root) and permissions = u+rwx go+rx.

This patch changes the behavior and makes mkfs.ubifs use the permissions of the directory containing the original files on the host. I.e., it will be <dir>'s uid/git/permissions if case of mkfs.ubifs -r <dir>.

This patch is a bit dangerous because it changes the behavior and may have security implications if someone used the older version, relied on this bug, and upgrades to the newer version.

Quoted 7 lines
Quoted 3 lines

All mkfs.ubifs users should take a look at this - should we apply this patch? I'm still in doubt...

I do not agree with changing the behaviour. It should be a new option, and you could add a warning explaining what the root inode permissions are and why e.g.

But on the other hand, a separate option looks silly... Would be nice to somehow slowly deprecate current behavior...

Quoted 3 lines

Warning: Option ?? not used. Setting root inode permissions to blah

Warning: Option ?? used. Setting root inode permissions to blah

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Битюцкий Артём)
#4 lore raw

Re: NOTE! mkfs.ubifs

In reply to Adrian Hunter
Quoted 7 lines · Adrian Hunter

I do not agree with changing the behaviour. It should be a new option, and you could add a warning explaining what the root inode permissions are and why e.g.

Warning: Option ?? not used. Setting root inode permissions to blah

Warning: Option ?? used. Setting root inode permissions to blah

Sent you v2 of this patch with an alternative (less harsh) solution.

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)