From: Kees Cook <kees@kernel.org>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: "Matthew Brost" <matthew.brost@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Christian Koenig" <christian.koenig@amd.com>,
"Somalapuram Amaranath" <Amaranath.Somalapuram@amd.com>,
"Huang Rui" <ray.huang@amd.com>,
"Matthew Auld" <matthew.auld@intel.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org, linux-fsdevel@vger.kernel.org,
"Christian Brauner" <brauner@kernel.org>,
"Jan Kara" <jack@suse.cz>
Subject: Re: [PATCH v2] drm/ttm: Silence randstruct warning about casting struct file
Date: Thu, 1 May 2025 19:46:59 -0700 [thread overview]
Message-ID: <202505011944.E35A427@keescook> (raw)
In-Reply-To: <20250502023447.GV2023217@ZenIV>
On Fri, May 02, 2025 at 03:34:47AM +0100, Al Viro wrote:
> On Thu, May 01, 2025 at 07:13:12PM -0700, Matthew Brost wrote:
> > On Thu, May 01, 2025 at 05:24:38PM -0700, Kees Cook wrote:
> > > Casting through a "void *" isn't sufficient to convince the randstruct
> > > GCC plugin that the result is intentional. Instead operate through an
> > > explicit union to silence the warning:
> > >
> > > drivers/gpu/drm/ttm/ttm_backup.c: In function 'ttm_file_to_backup':
> > > drivers/gpu/drm/ttm/ttm_backup.c:21:16: note: randstruct: casting between randomized structure pointer types (ssa): 'struct ttm_backup' and 'struct file'
> > > 21 | return (void *)file;
> > > | ^~~~~~~~~~~~
> > >
> > > Suggested-by: Matthew Brost <matthew.brost@intel.com>
> >
> > I forgot the policy if suggest-by but will add:
> > Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> >
> > Thomas was out today I suspect he will look at this tomorrow when he is
> > back too.
>
> [fsdevel and the rest of VFS maintainers Cc'd]
>
> NAKed-by: Al Viro <viro@zeniv.linux.org.uk>
>
> Reason: struct file should *NOT* be embedded into other objects without
> the core VFS being very explicitly aware of those. The only such case
> is outright local to fs/file_table.c, and breeding more of those is
> a really bad idea.
>
> Don't do that. Same goes for struct {dentry, super_block, mount}
> in case anyone gets similar ideas.
Well, in that case, the NAK should be against commit e7b5d23e5d47
("drm/ttm: Provide a shmem backup implementation"), but that looks to
have had 15 revisions already...
But I will just back away slowly now. I was just fixing a warning
introduced by it. :)
--
Kees Cook
next prev parent reply other threads:[~2025-05-02 2:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250502002437.it.851-kees@kernel.org>
[not found] ` <aBQqOCQZrHBBbPbL@lstrano-desk.jf.intel.com>
2025-05-02 2:34 ` [PATCH v2] drm/ttm: Silence randstruct warning about casting struct file Al Viro
2025-05-02 2:46 ` Kees Cook [this message]
2025-05-02 4:26 ` Matthew Brost
2025-05-02 4:31 ` Al Viro
2025-05-02 4:52 ` Matthew Brost
2025-05-02 5:33 ` Al Viro
2025-05-02 7:49 ` Christian König
2025-05-02 10:44 ` Thomas Hellström
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=202505011944.E35A427@keescook \
--to=kees@kernel.org \
--cc=Amaranath.Somalapuram@amd.com \
--cc=airlied@gmail.com \
--cc=brauner@kernel.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=mripard@kernel.org \
--cc=ray.huang@amd.com \
--cc=simona@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tzimmermann@suse.de \
--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;
as well as URLs for NNTP newsgroup(s).