Skip to contentSkip to conversation

debugfs: keep the old valid mode value when no explicity specify it

PATCH In review Chen LinX 3 participants 4 messages Aug 28, 2014 – Aug 29, 2014 Driver core

lore
Share & tools
lore

Chen LinX

author
#0 lore raw

PATCH 1/1 debugfs: keep the old valid mode value when no explicity specify it

From: "Chen, LinX" <[email protected]>

When mount debugfs with no mode specifed after it's mounted, the mount point mode will change to default mode(0700) even the mount operation was fail, this will cause some issues like can't get binder info in android. Here we can keep the old valid mode if no explicity specify the mode value and also change the mode value even the mount fails if the mode value is specified.

Change-Id I591ce5328e9589adfc3d7317f04276bf0033202a
---
 fs/debugfs/inode.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/debugfs/inode.c +2 -1
index c7c83ff..f1eb4b9 100644
@@ -159,7 +159,8 @@ static int debugfs_parse_options(char *data, struct debugfs_mount_opts *opts)
 	kgid_t gid;
 	char *p;
 
-	opts->mode = DEBUGFS_DEFAULT_MODE;
+	if (opts->mode == 0)
+		opts->mode = DEBUGFS_DEFAULT_MODE;
 
 	while ((p = strsep(&data, ",")) != NULL) {
 		if (!*p)
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw
Quoted 5 lines · Chen LinX

From: "Chen, LinX" <[email protected]>

When mount debugfs with no mode specifed after it's mounted, the mount point mode will change to default mode(0700) even the mount operation was fail, this will cause some issues like can't get binder info in android.

I don't understand, what did you do to get into this state?

And why does binder care about debugfs?

Quoted 3 lines

Here we can keep the old valid mode if no explicity specify the mode value and also change the mode value even the mount fails if the mode value is specified.

I can't parse this sentence :(

Quoted 1 line

Change-Id: I591ce5328e9589adfc3d7317f04276bf0033202a

Please never put these markings in patches for inclusion in the upstream kernel, as they make no sense.

thanks,

greg k-h

#2 lore raw
Quoted 7 lines · Greg KH
Quoted 5 lines · Chen LinX

From: "Chen, LinX" <[email protected]>

When mount debugfs with no mode specifed after it's mounted, the mount point mode will change to default mode(0700) even the mount operation was fail, this will cause some issues like can't get binder info in android.

I don't understand, what did you do to get into this state?

Greg,

Thanks for your kind quick comments. The patch description can be improved.

We hit the issue when debugging a UIWDT issue. Android framework has a good method to detect userspace hang and reports UIWDT issues. Android uses client/server model. Clients communicates with servers by binder. binder has debugfs interfaces. Some files show what threads are communicating with what other threads. If one thread is blocked for a long time, we can find the blocking chain from the binder info.

Since the error dumping process has no root access, booting process changes debugfs mount dir mode to 0755. When UIWDT happens, the error dumping process can read the info.

Unfortunately, some other scripts at booting try to mount debugfs for many times. No matter if the double mounting fails or succeeds, debugfs_parse_options changes the root inode's mode back to the default 0700. It means the effect of previous mode changing to 0755 is lost. At UIWDT, the dumping process can't save binder info to disk log files.

Quoted 7 lines

And why does binder care about debugfs?

Quoted 3 lines

Here we can keep the old valid mode if no explicity specify the mode value and also change the mode value even the mount fails if the mode value is specified.

I can't parse this sentence :(

Lin's patch checks if debugfs_mount_opts->mode is initiated. If it is already, the patch would bypass the reinitiation, so the old mode value is kept.

Yanmin

maintainer
#3 lore raw
Quoted 25 lines · Yanmin
Quoted 7 lines · Greg KH
Quoted 5 lines · Chen LinX

From: "Chen, LinX" <[email protected]>

When mount debugfs with no mode specifed after it's mounted, the mount point mode will change to default mode(0700) even the mount operation was fail, this will cause some issues like can't get binder info in android.

I don't understand, what did you do to get into this state?

Greg,

Thanks for your kind quick comments. The patch description can be improved.

We hit the issue when debugging a UIWDT issue. Android framework has a good method to detect userspace hang and reports UIWDT issues. Android uses client/server model. Clients communicates with servers by binder. binder has debugfs interfaces. Some files show what threads are communicating with what other threads. If one thread is blocked for a long time, we can find the blocking chain from the binder info.

Since the error dumping process has no root access, booting process changes debugfs mount dir mode to 0755. When UIWDT happens, the error dumping process can read the info.

Quoted 5 lines

Unfortunately, some other scripts at booting try to mount debugfs for many times. No matter if the double mounting fails or succeeds, debugfs_parse_options changes the root inode's mode back to the default 0700. It means the effect of previous mode changing to 0755 is lost. At UIWDT, the dumping process can't save binder info to disk log files.

Then fix those other scripts, don't try to work around broken userspace scripts by changing the kernel.

Sorry, I can't take this patch.

greg k-h