From: Tejun Heo <tj@kernel.org>
To: Josef Bacik <josef@bacik.io>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Christian Brauner <brauner@kernel.org>,
driver-core@lists.linux.dev, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kernfs: use the refreshed mode to drop setid on chown
Date: Fri, 04 Dec 2026 05:58:55 -1000 [thread overview]
Message-ID: <e3669fce339728935f5ef621c5844ede@kernel.org> (raw)
In-Reply-To: <20261203-b4-kernfs-chown-mode-v1-1-8dfef37010fb@bacik.io>
On Fri, Dec 04, 2026 at 10:35:15AM -0500, Josef Bacik wrote:
> A chown through an inode with an old copy of the mode can leave setuid
> or setgid set on the node, drop a setgid bit that should stay, or fail
> with EPERM for a caller that neither owns the node nor has CAP_FOWNER.
> All three reproduce with sysfs mounted in two network namespaces, a
> chmod through one mount and the chown through the other.
>
> notify_change() sets ATTR_MODE only if the copy has a bit to drop, and
> chown_common() goes by the copy for ATTR_KILL_SGID. "kernfs: refresh
> the inode before changing attributes", which this builds on, computes
> the mode again but keeps both decisions.
>
> Fix by making both decisions again from the refreshed inode, which also
> means EPERM for such a caller where only the node has a bit to drop, as
> with a current copy.
>
> Fixes: 3ff195b011d7 ("sysfs: Implement sysfs tagged directory support.")
> Reported-by: Tejun Heo <tj@kernel.org>
> Closes: https://lore.kernel.org/all/1347ee3f0a83e14e2ef5db37147e3966@kernel.org/
> Signed-off-by: Josef Bacik <josef@bacik.io>
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
prev parent reply other threads:[~2026-12-04 15:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 15:35 [PATCH] kernfs: use the refreshed mode to drop setid on chown Josef Bacik
2026-12-04 15:58 ` Tejun Heo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e3669fce339728935f5ef621c5844ede@kernel.org \
--to=tj@kernel.org \
--cc=brauner@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=josef@bacik.io \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox