From: Andrew Morton <akpm@linux-foundation.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Huang, Ying" <ying.huang@intel.com>,
linux-mm@kvack.org, mm-commits@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [GIT PULL] hotfixes for 6.3-rc1
Date: Sat, 4 Mar 2023 15:20:58 -0800 [thread overview]
Message-ID: <20230304152058.de91bf7abf424383ce31d500@linux-foundation.org> (raw)
In-Reply-To: <CAHk-=wj9guryjifHyr26w73ta+kNeoHtGde682Z5N6OSjKu4UQ@mail.gmail.com>
On Sat, 4 Mar 2023 14:35:00 -0800 Linus Torvalds <torvalds@linux-foundation.org> wrote:
> On Sat, Mar 4, 2023 at 1:15 PM Andrew Morton <akpm@linux-foundation.org> wrote:
> >
> > 17 hotfixes. Eight are for MM and seven are for other parts of the
> > kernel. Seven are cc:stable and eight address post-6.3 issues or were
> > judged unsuitable for -stable backporting.
>
> Hmm. Since this pull didn't fix the gcc note about playing pointer
> games that I get for my allmodconfig test build, and since I _really_
> don't want to have an rc1 release tomorrow with that (valid) warning,
> I fixed it up myself.
Ah. Ying did it this way:
From: Huang Ying <ying.huang@intel.com>
Subject: migrate_pages: silence gcc notes for mis-casting
Date: Thu, 2 Mar 2023 09:26:10 +0800
The following GCC notes was reported for commit 64c8902ed441
("migrate_pages: split unmap_and_move() to _unmap() and _move()").
mm/migrate.c: In function `__migrate_folio_extract':
mm/migrate.c:1050:20: note: randstruct: casting between randomized
structure pointer types (ssa): `struct anon_vma' and `struct
address_space'
1050 | *anon_vmap = (void *)dst->mapping;
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
The casting itself is safe. Because we only use dst->mapping to store the
pointer itself temporarily and dst is a newly allocated folio and not used
by anyone else during that. But the notes should be silenced and some
comments are deserved. So, we do that in this patch.
Link: https://lkml.kernel.org/r/20230302012610.17055-1-ying.huang@intel.com
Fixes: 64c8902ed441 ("migrate_pages: split unmap_and_move() to _unmap() and _move()")
Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Xin Hao <xhao@linux.alibaba.com>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Yang Shi <shy828301@gmail.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Bharata B Rao <bharata@amd.com>
Cc: Alistair Popple <apopple@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
--- a/mm/migrate.c~migrate_pages-silence-gcc-notes-for-mis-casting
+++ a/mm/migrate.c
@@ -1047,7 +1047,16 @@ static void __migrate_folio_extract(stru
int *page_was_mappedp,
struct anon_vma **anon_vmap)
{
- *anon_vmap = (void *)dst->mapping;
+ struct anon_vma *anon_vma;
+
+ /*
+ * 2 steps assignment to silence gcc notes for mis-casting. The
+ * casting is safe. Because we only use dst->mapping to store
+ * the pointer itself temporarily and dst is a newly allocated
+ * folio and not used by anyone else during that.
+ */
+ anon_vma = (void *)dst->mapping;
+ *anon_vmap = anon_vma;
*page_was_mappedp = (unsigned long)dst->private;
dst->mapping = NULL;
dst->private = NULL;
_
next prev parent reply other threads:[~2023-03-04 23:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-04 21:15 [GIT PULL] hotfixes for 6.3-rc1 Andrew Morton
2023-03-04 22:26 ` pr-tracker-bot
2023-03-04 22:35 ` Linus Torvalds
2023-03-04 23:20 ` Andrew Morton [this message]
2023-03-04 23:37 ` Linus Torvalds
2023-03-06 1:25 ` Huang, Ying
2023-03-08 10:39 ` Vlastimil Babka
2023-03-09 8:37 ` Huang, Ying
-- strict thread matches above, loose matches on Subject: below --
2023-03-14 23:54 Andrew Morton
2023-03-15 2:41 ` pr-tracker-bot
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=20230304152058.de91bf7abf424383ce31d500@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mm-commits@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=ying.huang@intel.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