mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: daurnimator <quae@daurnimator.com>
To: unlisted-recipients:; (no To-header on input)
Cc: quae@daurnimator.com, Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] fs: only pass valid chmod mode_t bits to security_path_chmod
Date: Mon, 13 Apr 2020 18:56:45 +1000	[thread overview]
Message-ID: <20200413085645.135829-1-quae@daurnimator.com> (raw)

chmod only pays attention to some of the flags in umode_t, don't pass
on irrelevant flags to security_path_chmod.

Signed-off-by: daurnimator <quae@daurnimator.com>
---
 fs/open.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/open.c b/fs/open.c
index b69d6eed67e6..a2d8bee88a3c 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -551,12 +551,13 @@ static int chmod_common(const struct path *path, umode_t mode)
 	error = mnt_want_write(path->mnt);
 	if (error)
 		return error;
+	mode &= S_IALLUGO;
 retry_deleg:
 	inode_lock(inode);
 	error = security_path_chmod(path, mode);
 	if (error)
 		goto out_unlock;
-	newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
+	newattrs.ia_mode = mode | (inode->i_mode & ~S_IALLUGO);
 	newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
 	error = notify_change(path->dentry, &newattrs, &delegated_inode);
 out_unlock:
-- 
2.26.0


                 reply	other threads:[~2020-04-13  9:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200413085645.135829-1-quae@daurnimator.com \
    --to=quae@daurnimator.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®