public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "David Hildenbrand (Red Hat)" <david@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: David Wang <00107082@163.com>,
	catalin.marinas@arm.com, lance.yang@linux.dev, b-padhi@ti.com,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	Jan Polensky <japo@linux.ibm.com>
Subject: Re: Linux 6.18-rc6
Date: Mon, 17 Nov 2025 20:17:47 +0100	[thread overview]
Message-ID: <5903ee6c-3774-47d6-b14a-51201fd75c0f@kernel.org> (raw)
In-Reply-To: <08790cc2-0db4-4920-8331-9061114e8645@kernel.org>

On 17.11.25 19:24, David Hildenbrand (Red Hat) wrote:
> On 17.11.25 18:59, Linus Torvalds wrote:
>> On Mon, 17 Nov 2025 at 09:53, David Hildenbrand (Red Hat)
>> <david@kernel.org> wrote:
>>>
>>> I had the same in mind for a second, but then I looked at
>>> kernel_init_pages() with the kasan_disable_current() handling and
>>> concluded that it's clearer to just disallow tag_clear_highpage() being
>>> abused in the first place and reduce the effective code footprint of
>>> post_alloc_hook().
>>
>> See, I had the exact opposite reaction: I think the one-liner is
>> better not just because it's simpler, but exactly *because* of the
>> mess that is kernel_init_pages().
> 
> Heh, I intuitively avoid runtime checks on the fast paths where avoidable :)
> 
>>
>> IOW, that one-liner is either correct *without* all that crud - and
>> it's unnecessary for the __GFP_ZEROTAGS case because that only happens
>> at init time - or it shows a bug in the arm64 code.
> 
> What sticks out is that we perform the tag_clear_highpage() before we do
> all the KASAN poison magic. And we perform the kernel_init_pages() after
> the kasan magic.
> 
> The clear_highpage() fallback in tag_clear_highpage() was just recently
> added by Catalin (in the same commit we are fixing here IIRC).
> 
> I am no expert on KASAN, but I would suspect that it is important for us
> to clear the pages after doing the
> kasan_unpoison_pages/page_kasan_tag_reset.
> 
> I'll have to dig into the history of tag_clear_highpage() a bit to
> understand how this would interact with non-hw-tag-based KASAN. IIRC,
> amd64 also supports SW-tag KASAN.

So, I briefly tried on x86 with KASAN and the one-liner. I was assuming 
that KASAN would complain because we are clearing the page before doing 
the kasan_unpoison_pages() (IOW, writing to a KASAN-poisoned page).

It didn't trigger, and I assume it is because clear_highpage() on x86 
will not be instrumented by KASAN (my theory).

The comment in kernel_init_pages() indicates that s390x uses memset() 
for that purpose and I would assume that that one would be instrumented.

So I'll give it a try on s390x with KASAN. I should be able to get my 
hands on a system later today.

-- 
Cheers

David

  reply	other threads:[~2025-11-17 19:17 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-16 22:42 Linux 6.18-rc6 Linus Torvalds
2025-11-17  8:20 ` David Wang
2025-11-17 10:33   ` Linus Torvalds
2025-11-17 12:56     ` David Wang
2025-11-17 13:30       ` David Hildenbrand (Red Hat)
2025-11-17 13:45         ` David Wang
2025-11-17 14:08           ` David Hildenbrand (Red Hat)
2025-11-17 15:28             ` David Wang
2025-11-17 16:59             ` Xi Ruoyao
2025-11-17 21:19               ` Joan Bruguera Micó
2025-11-17 17:28             ` Linus Torvalds
2025-11-17 17:53               ` David Hildenbrand (Red Hat)
2025-11-17 17:59                 ` Linus Torvalds
2025-11-17 18:24                   ` David Hildenbrand (Red Hat)
2025-11-17 19:17                     ` David Hildenbrand (Red Hat) [this message]
2025-11-18  1:10                       ` Linus Torvalds
2025-11-18  4:13                         ` David Wang
2025-11-18 13:55                           ` David Wang
2025-11-18 14:12                             ` David Hildenbrand (Red Hat)
2025-11-18 14:33                               ` David Wang
2025-11-18 14:44                               ` Carlos Llamas
2025-11-18 14:51                                 ` David Hildenbrand (Red Hat)
2025-11-18 14:53                                   ` Carlos Llamas
2025-11-18 15:09                                   ` David Wang
2025-11-18  7:28                         ` David Hildenbrand (Red Hat)
2025-11-18 16:49                           ` Linus Torvalds
2025-11-19 15:42                             ` Catalin Marinas
2025-11-18  3:59             ` Carlos Llamas
2025-11-17 16:42       ` Linus Torvalds
2025-11-17 18:13 ` Guenter Roeck
2025-11-18 17:23 ` Stephanie Gawroriski
2025-11-18 18:01   ` Linus Torvalds
2025-11-18 20:18     ` Stephanie Gawroriski
2025-11-19  9:08       ` Heikki Krogerus
2025-11-19 14:18         ` Stephanie Gawroriski
2025-11-19 15:04         ` Stephanie Gawroriski
2025-11-24  9:50           ` Heikki Krogerus
2025-11-26 16:01             ` Stephanie Gawroriski
2025-11-27  9:53               ` Heikki Krogerus

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=5903ee6c-3774-47d6-b14a-51201fd75c0f@kernel.org \
    --to=david@kernel.org \
    --cc=00107082@163.com \
    --cc=akpm@linux-foundation.org \
    --cc=b-padhi@ti.com \
    --cc=catalin.marinas@arm.com \
    --cc=japo@linux.ibm.com \
    --cc=lance.yang@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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