From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Alessandro Zanni <alessandro.zanni87@gmail.com>,
syzbot+6c55f725d1bdc8c52058@syzkaller.appspotmail.com,
Jan Kara <jack@suse.cz>, Christian Brauner <brauner@kernel.org>,
Sasha Levin <sashal@kernel.org>,
mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com,
ocfs2-devel@lists.linux.dev
Subject: [PATCH AUTOSEL 6.1 3/8] fs: Fix uninitialized value issue in from_kuid and from_kgid
Date: Mon, 28 Oct 2024 06:52:44 -0400 [thread overview]
Message-ID: <20241028105252.3560220-3-sashal@kernel.org> (raw)
In-Reply-To: <20241028105252.3560220-1-sashal@kernel.org>
From: Alessandro Zanni <alessandro.zanni87@gmail.com>
[ Upstream commit 15f34347481648a567db67fb473c23befb796af5 ]
ocfs2_setattr() uses attr->ia_mode, attr->ia_uid and attr->ia_gid in
a trace point even though ATTR_MODE, ATTR_UID and ATTR_GID aren't set.
Initialize all fields of newattrs to avoid uninitialized variables, by
checking if ATTR_MODE, ATTR_UID, ATTR_GID are initialized, otherwise 0.
Reported-by: syzbot+6c55f725d1bdc8c52058@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=6c55f725d1bdc8c52058
Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com>
Link: https://lore.kernel.org/r/20241017120553.55331-1-alessandro.zanni87@gmail.com
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/ocfs2/file.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index f502bb2ce2ea7..cac806174d10c 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1129,9 +1129,12 @@ int ocfs2_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
trace_ocfs2_setattr(inode, dentry,
(unsigned long long)OCFS2_I(inode)->ip_blkno,
dentry->d_name.len, dentry->d_name.name,
- attr->ia_valid, attr->ia_mode,
- from_kuid(&init_user_ns, attr->ia_uid),
- from_kgid(&init_user_ns, attr->ia_gid));
+ attr->ia_valid,
+ attr->ia_valid & ATTR_MODE ? attr->ia_mode : 0,
+ attr->ia_valid & ATTR_UID ?
+ from_kuid(&init_user_ns, attr->ia_uid) : 0,
+ attr->ia_valid & ATTR_GID ?
+ from_kgid(&init_user_ns, attr->ia_gid) : 0);
/* ensuring we don't even attempt to truncate a symlink */
if (S_ISLNK(inode->i_mode))
--
2.43.0
next prev parent reply other threads:[~2024-10-28 10:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 10:52 [PATCH AUTOSEL 6.1 1/8] xfrm: extract dst lookup parameters into a struct Sasha Levin
2024-10-28 10:52 ` [PATCH AUTOSEL 6.1 2/8] ASoC: fsl_esai: change dev_warn to dev_dbg in irq handler Sasha Levin
2024-10-28 10:52 ` Sasha Levin [this message]
2024-10-28 10:52 ` [PATCH AUTOSEL 6.1 4/8] HID: multitouch: Add quirk for Logitech Bolt receiver w/ Casa touchpad Sasha Levin
2024-10-28 10:52 ` [PATCH AUTOSEL 6.1 5/8] HID: lenovo: Add support for Thinkpad X1 Tablet Gen 3 keyboard Sasha Levin
2024-10-28 10:52 ` [PATCH AUTOSEL 6.1 6/8] LoongArch: Use "Exception return address" to comment ERA Sasha Levin
2024-10-28 10:52 ` [PATCH AUTOSEL 6.1 7/8] platform/x86: dell-wmi: Ignore suspend notifications Sasha Levin
2024-10-28 10:52 ` [PATCH AUTOSEL 6.1 8/8] net: usb: qmi_wwan: add Fibocom FG132 0x0112 composition Sasha Levin
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=20241028105252.3560220-3-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=alessandro.zanni87@gmail.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=jlbec@evilplan.org \
--cc=joseph.qi@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=ocfs2-devel@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=syzbot+6c55f725d1bdc8c52058@syzkaller.appspotmail.com \
/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