* [PATCH] fs/stat.c: avoid harmless garbage value problem in vfs_statx_path()
@ 2025-01-19 2:59 Su Hui
2025-01-20 15:20 ` Christian Brauner
0 siblings, 1 reply; 2+ messages in thread
From: Su Hui @ 2025-01-19 2:59 UTC (permalink / raw)
To: viro, brauner, jack, nathan, ndesaulniers, morbo, justinstitt
Cc: Su Hui, linux-fsdevel, linux-kernel, llvm, kernel-janitors
Clang static checker(scan-build) warning:
fs/stat.c:287:21: warning: The left expression of the compound assignment is
an uninitialized value. The computed value will also be garbage.
287 | stat->result_mask |= STATX_MNT_ID_UNIQUE;
| ~~~~~~~~~~~~~~~~~ ^
fs/stat.c:290:21: warning: The left expression of the compound assignment is
an uninitialized value. The computed value will also be garbage.
290 | stat->result_mask |= STATX_MNT_ID;
When vfs_getattr() failed because of security_inode_getattr(), 'stat' is
uninitialized. In this case, there is a harmless garbage problem in
vfs_statx_path(). It's better to return error directly when
vfs_getattr() failed, avoiding garbage value and more clearly.
Signed-off-by: Su Hui <suhui@nfschina.com>
---
fs/stat.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/stat.c b/fs/stat.c
index 0870e969a8a0..14eb3d01d98a 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -281,6 +281,8 @@ static int vfs_statx_path(struct path *path, int flags, struct kstat *stat,
u32 request_mask)
{
int error = vfs_getattr(path, stat, request_mask, flags);
+ if (error)
+ return error;
if (request_mask & STATX_MNT_ID_UNIQUE) {
stat->mnt_id = real_mount(path->mnt)->mnt_id_unique;
@@ -302,7 +304,7 @@ static int vfs_statx_path(struct path *path, int flags, struct kstat *stat,
if (S_ISBLK(stat->mode))
bdev_statx(path, stat, request_mask);
- return error;
+ return 0;
}
static int vfs_statx_fd(int fd, int flags, struct kstat *stat,
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] fs/stat.c: avoid harmless garbage value problem in vfs_statx_path()
2025-01-19 2:59 [PATCH] fs/stat.c: avoid harmless garbage value problem in vfs_statx_path() Su Hui
@ 2025-01-20 15:20 ` Christian Brauner
0 siblings, 0 replies; 2+ messages in thread
From: Christian Brauner @ 2025-01-20 15:20 UTC (permalink / raw)
To: Su Hui
Cc: Christian Brauner, linux-fsdevel, linux-kernel, llvm,
kernel-janitors, viro, jack, nathan, ndesaulniers, morbo,
justinstitt
On Sun, 19 Jan 2025 10:59:47 +0800, Su Hui wrote:
> Clang static checker(scan-build) warning:
> fs/stat.c:287:21: warning: The left expression of the compound assignment is
> an uninitialized value. The computed value will also be garbage.
> 287 | stat->result_mask |= STATX_MNT_ID_UNIQUE;
> | ~~~~~~~~~~~~~~~~~ ^
> fs/stat.c:290:21: warning: The left expression of the compound assignment is
> an uninitialized value. The computed value will also be garbage.
> 290 | stat->result_mask |= STATX_MNT_ID;
>
> [...]
Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes
[1/1] fs/stat.c: avoid harmless garbage value problem in vfs_statx_path()
https://git.kernel.org/vfs/vfs/c/7984cbe223e0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-20 15:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-19 2:59 [PATCH] fs/stat.c: avoid harmless garbage value problem in vfs_statx_path() Su Hui
2025-01-20 15:20 ` Christian Brauner
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®