lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 4 Mar 2023 15:20:58 -0800
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     Linus Torvalds <torvalds@...ux-foundation.org>
Cc:     "Huang, Ying" <ying.huang@...el.com>, linux-mm@...ck.org,
        mm-commits@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [GIT PULL] hotfixes for 6.3-rc1

On Sat, 4 Mar 2023 14:35:00 -0800 Linus Torvalds <torvalds@...ux-foundation.org> wrote:

> On Sat, Mar 4, 2023 at 1:15 PM Andrew Morton <akpm@...ux-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@...el.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@...el.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Baolin Wang <baolin.wang@...ux.alibaba.com>
Cc: Xin Hao <xhao@...ux.alibaba.com>
Cc: Zi Yan <ziy@...dia.com>
Cc: Yang Shi <shy828301@...il.com>
Cc: Oscar Salvador <osalvador@...e.de>
Cc: Matthew Wilcox <willy@...radead.org>
Cc: Bharata B Rao <bharata@....com>
Cc: Alistair Popple <apopple@...dia.com>
Signed-off-by: Andrew Morton <akpm@...ux-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;
_

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ