From: Jan Kara <jack@suse.cz>
To: Arnd Bergmann <arnd@kernel.org>
Cc: linux-fsdevel@vger.kernel.org,
Mike Marshall <hubcap@omnibond.com>,
Arnd Bergmann <arnd@arndb.de>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Martin Brandenburg <martin@omnibond.com>,
devel@lists.orangefs.org, Vlastimil Babka <vbabka@suse.cz>,
Kees Cook <keescook@chromium.org>,
Justin Stitt <justinstitt@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [RESEND] orangefs: fix out-of-bounds fsid access
Date: Mon, 8 Apr 2024 16:36:23 +0200 [thread overview]
Message-ID: <20240408143623.t4uj4dbewl4hyoar@quack3> (raw)
In-Reply-To: <20240408075052.3304511-1-arnd@kernel.org>
On Mon 08-04-24 09:50:43, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> orangefs_statfs() copies two consecutive fields of the superblock into
> the statfs structure, which triggers a warning from the string fortification
> helpers:
>
> In file included from fs/orangefs/super.c:8:
> include/linux/fortify-string.h:592:4: error: call to '__read_overflow2_field' declared with 'warning' attribute: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror,-Wattribute-warning]
> __read_overflow2_field(q_size_field, size);
>
> Change the memcpy() to an individual assignment of the two fields, which helps
> both the compiler and human readers understand better what it does.
>
> Link: https://lore.kernel.org/all/20230622101701.3399585-1-arnd@kernel.org/
> Cc: Alexander Viro <viro@zeniv.linux.org.uk>
> Cc: Christian Brauner <brauner@kernel.org>
> Cc: Jan Kara <jack@suse.cz>
> Cc: linux-fsdevel@vger.kernel.org
> Cc: Mike Marshall <hubcap@omnibond.com>
> Cc: Martin Brandenburg <martin@omnibond.com>
> Cc: devel@lists.orangefs.org
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> Resending to VFS maintainers, I sent this a couple of times to the
> orangefs maintainers but never got a reply
> ---
> fs/orangefs/super.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c
> index fb4d09c2f531..152478295766 100644
> --- a/fs/orangefs/super.c
> +++ b/fs/orangefs/super.c
> @@ -201,7 +201,10 @@ static int orangefs_statfs(struct dentry *dentry, struct kstatfs *buf)
> (long)new_op->downcall.resp.statfs.files_avail);
>
> buf->f_type = sb->s_magic;
> - memcpy(&buf->f_fsid, &ORANGEFS_SB(sb)->fs_id, sizeof(buf->f_fsid));
> + buf->f_fsid = (__kernel_fsid_t) {{
> + ORANGEFS_SB(sb)->fs_id,
> + ORANGEFS_SB(sb)->id,
> + }};
Frankly, this initializer is hard to understand for me. Why not simple:
buf->f_fsid[0] = ORANGEFS_SB(sb)->fs_id;
buf->f_fsid[1] = ORANGEFS_SB(sb)->id;
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2024-04-08 14:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-08 7:50 [PATCH] [RESEND] orangefs: fix out-of-bounds fsid access Arnd Bergmann
2024-04-08 14:36 ` Jan Kara [this message]
2024-04-08 21:21 ` Justin Stitt
2024-04-09 5:54 ` Arnd Bergmann
2024-04-09 16:26 ` Mike Marshall
2024-04-09 19:33 ` Arnd Bergmann
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=20240408143623.t4uj4dbewl4hyoar@quack3 \
--to=jack@suse.cz \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=brauner@kernel.org \
--cc=devel@lists.orangefs.org \
--cc=hubcap@omnibond.com \
--cc=justinstitt@google.com \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin@omnibond.com \
--cc=vbabka@suse.cz \
--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