From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94039262FD0 for ; Mon, 17 Nov 2025 18:24:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763403884; cv=none; b=GkOHnrU3N1uvXe/dRGm/BrJ+oXAMxsClCLrt4pQAlbT+VyUlOdXjxnjpHv52p0FL8p8APuNSTakfH2BdFvRd3x71OT8/sYd27+aw4kCa+6HD1zPWeotQfecFBiPbJPIuJaItb0T41BWZjHvXR6aFXsfYjHEDwnXViKvyqopEjhM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763403884; c=relaxed/simple; bh=XL+qUOd7RV3j8vsGdi1ctkEINtKuMSHDhZAQCEi1tSA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tUkb9drFSkyyGR1tUkyVveDkMp+1HpH61nYEH6QUg4OiXp+pQ/FhPLi4EuRPNfd26KSCAMDEJZmy8DetAJAHDBvru8RY5SIqC/+hl59F46sFLPui36saGbItT5s4LqGVBn5zixvJ2xsBhUbX3BBNH2WIloOGNjWgDr4clTTCCiU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AM506H44; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AM506H44" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0E90C2BCC6; Mon, 17 Nov 2025 18:24:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763403883; bh=XL+qUOd7RV3j8vsGdi1ctkEINtKuMSHDhZAQCEi1tSA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=AM506H44V5oRIC80byEiNMrWLvJjwImaEBbmjzHdGJLic52OWSq3TXBbMilFI2myh 2G5hGy+fTHkowM1tTbJFmboPpt8KJwyxFDkuJt1c77WIzBvae3AcJFLFn1MZ5DzkYR xb9LfMtv5qm6+5MJ2rkvM1B34vTPaUXQpnuSK4cJKexvz04EGj2X6HoSdqx5XC2MkT TmOJSbakfiwcko1i0QTV0zTzU1rWQyiBSKfE2qTrKjRSbUCeHZPvqTvQ5j8LxXFC2N P3rkdRaPDv7fX/Iq8pjZmBih9Mbxw/21Rki6Qsa4RX54auqn+GFlxbd6x45K+maThT 2nezhqkQKPpSA== Message-ID: <08790cc2-0db4-4920-8331-9061114e8645@kernel.org> Date: Mon, 17 Nov 2025 19:24:37 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Linux 6.18-rc6 To: Linus Torvalds 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 References: <20251117082023.90176-1-00107082@163.com> <6c09aaea.aa4a.19a91e379ab.Coremail.00107082@163.com> <37bad560-a8f3-4ae2-aa34-1edc635062c0@kernel.org> <1c14c47e.ab83.19a92102b26.Coremail.00107082@163.com> <25e4c75c-097d-44bb-8739-136a0238d5bf@kernel.org> <189cfb08-2593-4ff1-a3fa-3c7957cb6b60@kernel.org> From: "David Hildenbrand (Red Hat)" Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 17.11.25 18:59, Linus Torvalds wrote: > On Mon, 17 Nov 2025 at 09:53, David Hildenbrand (Red Hat) > 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. > > Either way it's a win. Either it's simpler, or it gives us better coverage. > > No? Staring a bit more at the arm64 fallback in tag_clear_highpage() I agree that it might help to find arm64 issues we might run into in the fallback. But the interaction of KASAN config options are not particularly easy to understand -- and if this would actually break non-arm configs. I'll have to dig ... -- Cheers David