* FAILED: patch "[PATCH] tracefs: Only clobber mode/uid/gid on remount if asked" failed to apply to 5.15-stable tree
@ 2022-09-09 18:31 gregkh
2022-09-12 22:23 ` Brian Norris
0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2022-09-09 18:31 UTC (permalink / raw)
To: briannorris, rostedt; +Cc: stable
The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
Possible dependencies:
47311db8e8f3 ("tracefs: Only clobber mode/uid/gid on remount if asked")
851e99ebeec3 ("tracefs: Set the group ownership in apply_options() not parse_options()")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 47311db8e8f33011d90dee76b39c8886120cdda4 Mon Sep 17 00:00:00 2001
From: Brian Norris <briannorris@chromium.org>
Date: Fri, 26 Aug 2022 17:44:17 -0700
Subject: [PATCH] tracefs: Only clobber mode/uid/gid on remount if asked
Users may have explicitly configured their tracefs permissions; we
shouldn't overwrite those just because a second mount appeared.
Only clobber if the options were provided at mount time.
Note: the previous behavior was especially surprising in the presence of
automounted /sys/kernel/debug/tracing/.
Existing behavior:
## Pre-existing status: tracefs is 0755.
# stat -c '%A' /sys/kernel/tracing/
drwxr-xr-x
## (Re)trigger the automount.
# umount /sys/kernel/debug/tracing
# stat -c '%A' /sys/kernel/debug/tracing/.
drwx------
## Unexpected: the automount changed mode for other mount instances.
# stat -c '%A' /sys/kernel/tracing/
drwx------
New behavior (after this change):
## Pre-existing status: tracefs is 0755.
# stat -c '%A' /sys/kernel/tracing/
drwxr-xr-x
## (Re)trigger the automount.
# umount /sys/kernel/debug/tracing
# stat -c '%A' /sys/kernel/debug/tracing/.
drwxr-xr-x
## Expected: the automount does not change other mount instances.
# stat -c '%A' /sys/kernel/tracing/
drwxr-xr-x
Link: https://lkml.kernel.org/r/20220826174353.2.Iab6e5ea57963d6deca5311b27fb7226790d44406@changeid
Cc: stable@vger.kernel.org
Fixes: 4282d60689d4f ("tracefs: Add new tracefs file system")
Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index 81d26abf486f..da85b3979195 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -141,6 +141,8 @@ struct tracefs_mount_opts {
kuid_t uid;
kgid_t gid;
umode_t mode;
+ /* Opt_* bitfield. */
+ unsigned int opts;
};
enum {
@@ -241,6 +243,7 @@ static int tracefs_parse_options(char *data, struct tracefs_mount_opts *opts)
kgid_t gid;
char *p;
+ opts->opts = 0;
opts->mode = TRACEFS_DEFAULT_MODE;
while ((p = strsep(&data, ",")) != NULL) {
@@ -275,24 +278,36 @@ static int tracefs_parse_options(char *data, struct tracefs_mount_opts *opts)
* but traditionally tracefs has ignored all mount options
*/
}
+
+ opts->opts |= BIT(token);
}
return 0;
}
-static int tracefs_apply_options(struct super_block *sb)
+static int tracefs_apply_options(struct super_block *sb, bool remount)
{
struct tracefs_fs_info *fsi = sb->s_fs_info;
struct inode *inode = d_inode(sb->s_root);
struct tracefs_mount_opts *opts = &fsi->mount_opts;
- inode->i_mode &= ~S_IALLUGO;
- inode->i_mode |= opts->mode;
+ /*
+ * On remount, only reset mode/uid/gid if they were provided as mount
+ * options.
+ */
+
+ if (!remount || opts->opts & BIT(Opt_mode)) {
+ inode->i_mode &= ~S_IALLUGO;
+ inode->i_mode |= opts->mode;
+ }
- inode->i_uid = opts->uid;
+ if (!remount || opts->opts & BIT(Opt_uid))
+ inode->i_uid = opts->uid;
- /* Set all the group ids to the mount option */
- set_gid(sb->s_root, opts->gid);
+ if (!remount || opts->opts & BIT(Opt_gid)) {
+ /* Set all the group ids to the mount option */
+ set_gid(sb->s_root, opts->gid);
+ }
return 0;
}
@@ -307,7 +322,7 @@ static int tracefs_remount(struct super_block *sb, int *flags, char *data)
if (err)
goto fail;
- tracefs_apply_options(sb);
+ tracefs_apply_options(sb, true);
fail:
return err;
@@ -359,7 +374,7 @@ static int trace_fill_super(struct super_block *sb, void *data, int silent)
sb->s_op = &tracefs_super_operations;
- tracefs_apply_options(sb);
+ tracefs_apply_options(sb, false);
return 0;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: FAILED: patch "[PATCH] tracefs: Only clobber mode/uid/gid on remount if asked" failed to apply to 5.15-stable tree
2022-09-09 18:31 FAILED: patch "[PATCH] tracefs: Only clobber mode/uid/gid on remount if asked" failed to apply to 5.15-stable tree gregkh
@ 2022-09-12 22:23 ` Brian Norris
2022-09-13 11:34 ` Greg Kroah-Hartman
0 siblings, 1 reply; 4+ messages in thread
From: Brian Norris @ 2022-09-12 22:23 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Steven Rostedt, stable
Hi Greg,
On Fri, Sep 9, 2022 at 11:31 AM <gregkh@linuxfoundation.org> wrote:
> The patch below does not apply to the 5.15-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
Did something go wrong in your automation? The same patch applies
cleanly to me (currently, on top of v5.15.67).
> Possible dependencies:
>
> 47311db8e8f3 ("tracefs: Only clobber mode/uid/gid on remount if asked")
That's $subject patch. OK, so not that one.
> 851e99ebeec3 ("tracefs: Set the group ownership in apply_options() not parse_options()")
That one *is* a dependency, but it's already backported to 5.15.y as
of several months ago:
commit 6db927ce66ac68bf732f0b14190791458e75047a
Author: Steven Rostedt (Google) <rostedt@goodmis.org>
AuthorDate: Fri Feb 25 15:34:26 2022 -0500
Commit: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CommitDate: Wed Mar 2 11:48:05 2022 +0100
tracefs: Set the group ownership in apply_options() not parse_options()
commit 851e99ebeec3f4a672bb5010cf1ece095acee447 upstream.
So I'm not sure what to do to fix the backporting, other than ping back here.
I think the same applies to the 5.10.y rejection notice, and possibly
a few others.
Brian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: FAILED: patch "[PATCH] tracefs: Only clobber mode/uid/gid on remount if asked" failed to apply to 5.15-stable tree
2022-09-12 22:23 ` Brian Norris
@ 2022-09-13 11:34 ` Greg Kroah-Hartman
2022-09-13 20:01 ` Brian Norris
0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2022-09-13 11:34 UTC (permalink / raw)
To: Brian Norris; +Cc: Steven Rostedt, stable
On Mon, Sep 12, 2022 at 03:23:42PM -0700, Brian Norris wrote:
> Hi Greg,
>
> On Fri, Sep 9, 2022 at 11:31 AM <gregkh@linuxfoundation.org> wrote:
> > The patch below does not apply to the 5.15-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
>
> Did something go wrong in your automation? The same patch applies
> cleanly to me (currently, on top of v5.15.67).
>
> > Possible dependencies:
> >
> > 47311db8e8f3 ("tracefs: Only clobber mode/uid/gid on remount if asked")
>
> That's $subject patch. OK, so not that one.
>
> > 851e99ebeec3 ("tracefs: Set the group ownership in apply_options() not parse_options()")
>
> That one *is* a dependency, but it's already backported to 5.15.y as
> of several months ago:
>
> commit 6db927ce66ac68bf732f0b14190791458e75047a
> Author: Steven Rostedt (Google) <rostedt@goodmis.org>
> AuthorDate: Fri Feb 25 15:34:26 2022 -0500
> Commit: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> CommitDate: Wed Mar 2 11:48:05 2022 +0100
>
> tracefs: Set the group ownership in apply_options() not parse_options()
>
> commit 851e99ebeec3f4a672bb5010cf1ece095acee447 upstream.
>
> So I'm not sure what to do to fix the backporting, other than ping back here.
>
> I think the same applies to the 5.10.y rejection notice, and possibly
> a few others.
Here is what patch says:
Applying tracefs-only-clobber-mode-uid-gid-on-remount-if-asked.patch to linux-5.15.y
Applying patch tracefs-only-clobber-mode-uid-gid-on-remount-if-asked.patch
patching file fs/tracefs/inode.c
Hunk #3 FAILED at 278.
1 out of 5 hunks FAILED -- rejects in file fs/tracefs/inode.c
Patch tracefs-only-clobber-mode-uid-gid-on-remount-if-asked.patch does not apply (enforce with -f)
quilt returned 1, with 0 fuzz and 1 rejects
How did you apply the patch to 5.15.y that worked?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: FAILED: patch "[PATCH] tracefs: Only clobber mode/uid/gid on remount if asked" failed to apply to 5.15-stable tree
2022-09-13 11:34 ` Greg Kroah-Hartman
@ 2022-09-13 20:01 ` Brian Norris
0 siblings, 0 replies; 4+ messages in thread
From: Brian Norris @ 2022-09-13 20:01 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Steven Rostedt, stable
On Tue, Sep 13, 2022 at 4:34 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> Here is what patch says:
>
> Applying tracefs-only-clobber-mode-uid-gid-on-remount-if-asked.patch to linux-5.15.y
> Applying patch tracefs-only-clobber-mode-uid-gid-on-remount-if-asked.patch
> patching file fs/tracefs/inode.c
> Hunk #3 FAILED at 278.
> 1 out of 5 hunks FAILED -- rejects in file fs/tracefs/inode.c
> Patch tracefs-only-clobber-mode-uid-gid-on-remount-if-asked.patch does not apply (enforce with -f)
> quilt returned 1, with 0 fuzz and 1 rejects
>
> How did you apply the patch to 5.15.y that worked?
Hmm, I suppose I have 'git am' doing 3-way merges for me, which resolve OK:
$ curl https://lore.kernel.org/all/166274826116451@kroah.com/raw | git am -
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6614 100 6614 0 0 27768 0 --:--:-- --:--:-- --:--:-- 27789
Applying: FAILED: patch "[PATCH] tracefs: Only clobber mode/uid/gid on
remount if asked" failed to apply to 5.15-stable tree
Using index info to reconstruct a base tree...
M fs/tracefs/inode.c
Falling back to patching base and 3-way merge...
Auto-merging fs/tracefs/inode.c
And originally, I guess I was testing 'git cherry-pick', not literally
this patch. That also does some "auto-merging":
$ git cherry-pick 47311db8e8f33011d90dee76b39c8886120cdda4
Auto-merging fs/tracefs/inode.c
[detached HEAD e9f574cc9df9] tracefs: Only clobber mode/uid/gid on
remount if asked
Date: Fri Aug 26 17:44:17 2022 -0700
1 file changed, 23 insertions(+), 8 deletions(-)
I'll generate a clean patch based on the above, but it'll look awfully
similar. (I think there's a single line of context that looks
different, a few lines away.) Stay tuned.
Brian
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-13 20:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-09 18:31 FAILED: patch "[PATCH] tracefs: Only clobber mode/uid/gid on remount if asked" failed to apply to 5.15-stable tree gregkh
2022-09-12 22:23 ` Brian Norris
2022-09-13 11:34 ` Greg Kroah-Hartman
2022-09-13 20:01 ` Brian Norris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).