From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1561CCDDE6F for ; Wed, 23 Oct 2024 11:32:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A3586B007B; Wed, 23 Oct 2024 07:32:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 453026B0082; Wed, 23 Oct 2024 07:32:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 319E66B0083; Wed, 23 Oct 2024 07:32:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 12F8E6B007B for ; Wed, 23 Oct 2024 07:32:03 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E55E91C59AE for ; Wed, 23 Oct 2024 11:31:42 +0000 (UTC) X-FDA: 82704652338.26.A7FC795 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf12.hostedemail.com (Postfix) with ESMTP id 1B1FF40018 for ; Wed, 23 Oct 2024 11:31:52 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=FGMUYQQf; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf12.hostedemail.com: domain of elver@google.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=elver@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729683009; a=rsa-sha256; cv=none; b=4n5N/q9tXdWATlPkVU/eBKp4UjKPhekym4sa9L1bQLyovsIZxM191qtA/lbWuGHiwhlDOL e9tKSrou3i6XEjyld96sden5l+e2ETWNP7mPmi1Qp09Ik7nlwOl8/NtCdpkVvO6GPPW2qW 8QCS5gJqT3vdIhbXN6vuB/UswDmdfyg= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=FGMUYQQf; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf12.hostedemail.com: domain of elver@google.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=elver@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729683009; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PifyftziAf8djQkPyvbqMUdH0ri6kdYCgtQLuMyRp+U=; b=QboDcxYxNlJFx5O6uDGZAbdRRBdocVud8GWjOAh0nn0wwnlxDFqcLo1ZNxfILjkeU2nLFQ JtMCmYGo1hvMPtobCvMBbFOMmvsnbecI/dsZgxYxnWn4HgxDUEGWkEsUX1uf70gOUk2/j3 9cvkJmgOw7XwMR9rdyY9b4rPaPDjUtM= Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-20bb39d97d1so62297235ad.2 for ; Wed, 23 Oct 2024 04:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729683119; x=1730287919; darn=kvack.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=PifyftziAf8djQkPyvbqMUdH0ri6kdYCgtQLuMyRp+U=; b=FGMUYQQfSQHICikw+DM1GrASEbl3Bn3uXnlpF0OceQUxeIW7+HPRFA41XuWUV0yXKg nBXZN/L2ciV1jirx89YuD4ewQs39nisk+2yID+bID+81V42DhbxfNGXWgp0J8sFuNVtF 5qf5YDEdLzl4/WoVS2xr2zgbWAeso1JeIm6unUtTNII9dixUzhL6yeHAnmngl7/SyKAE c8y2NX5Z9E1Md9gE8Y7dXnt+1CFmjWA/ig8czXDZItcA02PvWYigtWtldaJh4DZY5+tV trdt/0gHKGiB5ywBDVak68vzFT34yqM444uBSmc3SsPBsvyBquCi28cvEbLyfH5fMIMZ 7Vzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729683119; x=1730287919; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PifyftziAf8djQkPyvbqMUdH0ri6kdYCgtQLuMyRp+U=; b=U/pcQBMm6b7MWcGTwGX+JpeXGpsFxmhA7IyCVNJNqcTAlcHIEVFfd409IkgmxWIJVV /xMuq9SXveZRdPp3+lz+U5SvNTcWw0VHzJTKKC+W0AlR8IMPhvoglzx9v5Opfc8g5ByT 3Wir8IY3gEujKcCcHBtfalcmzGM5AdU+7CnlNpG9bnGKMz40uSwAx/0MTINHCDToFvX6 rhZshiMcphp8CyJavEYNQ3UbwLZcsGeFucCU1szDqh2IIcKJLM8NoVt2iYjuE3HTADH4 1yubRUo8WlRS85Qm6LWwL8nKwPIf7o2chZlMKjw90w9girEmsa2gY3RctzF6n6zrH1Rw X9ZA== X-Forwarded-Encrypted: i=1; AJvYcCWgQL8lJRbzQ7BBZVJC3OyrfD8uDPohzyZ+qPRZbWvsy0k36wmGy7JscM9pI9p8wD6CdckcbVT0TA==@kvack.org X-Gm-Message-State: AOJu0YwBBjA0GXTIo+FMmsz49UgHSaaC0zePOISmdXrQFnpvQRjLw0hx GmFFSuW8VKYWnHnFTjZOJ5R/K3ho8k3mVCyJEC4DVeGrddGvDLAKE/1k2UhfsRGM7sTyofpNNd+ RGvcPnfG1yaO9+Ae1vKWVrxLAffg4CbxMjKfp X-Google-Smtp-Source: AGHT+IHP+7htcJ8BgPEpFBfWaxFnQpKq7JObNjsHz6Dygzj4nAQwcf6cdlKATTACXhbxMaOm10i6V6GwxULSmHcVeAY= X-Received: by 2002:a17:90a:5d15:b0:2e2:8fb4:502d with SMTP id 98e67ed59e1d1-2e76b5e65a6mr2138687a91.16.1729683119198; Wed, 23 Oct 2024 04:31:59 -0700 (PDT) MIME-Version: 1.0 References: <87a5eysmj1.fsf@mid.deneb.enyo.de> <20241023062417.3862170-1-dvyukov@google.com> <8471d7b1-576b-41a6-91fb-1c9baae8c540@redhat.com> <5a3d3bc8-60db-46d0-b689-9aeabcdb8eab@lucifer.local> <1768ef5d-7289-4d2b-ae02-f5d2a20d5320@redhat.com> In-Reply-To: <1768ef5d-7289-4d2b-ae02-f5d2a20d5320@redhat.com> From: Marco Elver Date: Wed, 23 Oct 2024 13:31:21 +0200 Message-ID: Subject: Re: [PATCH v2 0/5] implement lightweight guard pages To: David Hildenbrand Cc: Lorenzo Stoakes , Vlastimil Babka , Dmitry Vyukov , fw@deneb.enyo.de, James.Bottomley@hansenpartnership.com, Liam.Howlett@oracle.com, akpm@linux-foundation.org, arnd@arndb.de, brauner@kernel.org, chris@zankel.net, deller@gmx.de, hch@infradead.org, ink@jurassic.park.msu.ru, jannh@google.com, jcmvbkbc@gmail.com, jeffxu@chromium.org, jhubbard@nvidia.com, linux-alpha@vger.kernel.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-parisc@vger.kernel.org, mattst88@gmail.com, muchun.song@linux.dev, paulmck@kernel.org, richard.henderson@linaro.org, shuah@kernel.org, sidhartha.kumar@oracle.com, surenb@google.com, tsbogend@alpha.franken.de, willy@infradead.org, Linus Torvalds Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 1B1FF40018 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 4dutwxb3scy59tceywz1jk7ssaqersai X-HE-Tag: 1729683112-417131 X-HE-Meta: U2FsdGVkX1/05Nx3a5mWcA9XqLksBorNE3Ff98Fw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Cs0PIZmt/zhvA5lylECZrCw3I4FdF0P8UeAGuFq7JnkZ+vdKvGMx6ARVPsQeZx7ST/sWNfJ3aIVaO0uuPaJw1tu79e8NsibOUMSveL05IpJ4tq9BlOfagDxEPvbQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000020, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, 23 Oct 2024 at 11:29, David Hildenbrand wrote: > > On 23.10.24 11:18, Lorenzo Stoakes wrote: > > On Wed, Oct 23, 2024 at 11:13:47AM +0200, David Hildenbrand wrote: > >> On 23.10.24 11:06, Vlastimil Babka wrote: > >>> On 10/23/24 10:56, Dmitry Vyukov wrote: > >>>>> > >>>>> Overall while I sympathise with this, it feels dangerous and a pretty major > >>>>> change, because there'll be something somewhere that will break because it > >>>>> expects faults to be swallowed that we no longer do swallow. > >>>>> > >>>>> So I'd say it'd be something we should defer, but of course it's a highly > >>>>> user-facing change so how easy that would be I don't know. > >>>>> > >>>>> But I definitely don't think a 'introduce the ability to do cheap PROT_NONE > >>>>> guards' series is the place to also fundmentally change how user access > >>>>> page faults are handled within the kernel :) > >>>> > >>>> Will delivering signals on kernel access be a backwards compatible > >>>> change? Or will we need a different API? MADV_GUARD_POISON_KERNEL? > >>>> It's just somewhat painful to detect/update all userspace if we add > >>>> this feature in future. Can we say signal delivery on kernel accesses > >>>> is unspecified? > >>> > >>> Would adding signal delivery to guard PTEs only help enough the ASAN etc > >>> usecase? Wouldn't it be instead possible to add some prctl to opt-in the > >>> whole ASANized process to deliver all existing segfaults as signals instead > >>> of -EFAULT ? > >> > >> Not sure if it is an "instead", you might have to deliver the signal in > >> addition to letting the syscall fail (not that I would be an expert on > >> signal delivery :D ). > >> > >> prctl sounds better, or some way to configure the behavior on VMA ranges; > >> otherwise we would need yet another marker, which is not the end of the > >> world but would make it slightly more confusing. > >> > > > > Yeah prctl() sounds sensible, and since we are explicitly adding a marker > > for guard pages here we can do this as a follow up too without breaking any > > userland expectations, i.e. 'new feature to make guard pages signal' is not > > going to contradict the default behaviour. > > > > So all makes sense to me, but I do think best as a follow up! :) > > Yeah, fully agreed. And my gut feeling is that it might not be that easy > ... :) > > In the end, what we want is *some* notification that a guard PTE was > accessed. Likely the notification must not necessarily completely > synchronous (although it would be ideal) and it must not be a signal. > > Maybe having a different way to obtain that information from user space > would work. For bug detection tools (like GWP-ASan [1]) it's essential to have useful stack traces. As such, having this signal be synchronous would be more useful. I don't see how one could get a useful stack trace (or other information like what's stashed away in ucontext like CPU registers) if this were asynchronous. [1] https://arxiv.org/pdf/2311.09394