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 B43A0C27C5F for ; Fri, 7 Jun 2024 14:35:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B57A6B009C; Fri, 7 Jun 2024 10:35:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4660E6B00A3; Fri, 7 Jun 2024 10:35:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32DDB6B00A4; Fri, 7 Jun 2024 10:35:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 125326B009C for ; Fri, 7 Jun 2024 10:35:23 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 86B70140178 for ; Fri, 7 Jun 2024 14:35:22 +0000 (UTC) X-FDA: 82204340484.23.C88C24A Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf28.hostedemail.com (Postfix) with ESMTP id 10748C001A for ; Fri, 7 Jun 2024 14:35:18 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=zx2c4.com header.s=20210105 header.b=BBV00V0r; dmarc=pass (policy=quarantine) header.from=zx2c4.com; spf=pass (imf28.hostedemail.com: domain of "SRS0=OGeU=NJ=zx2c4.com=Jason@kernel.org" designates 145.40.73.55 as permitted sender) smtp.mailfrom="SRS0=OGeU=NJ=zx2c4.com=Jason@kernel.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717770920; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ajPZqckOBJFHBstUW7T2O0UQJC/naoL0j9njP215Xzs=; b=7Toeoto/i2bTZ8Aq7f/J+Bn7DSrePKOyRCErgNtA7phZ0SPuh619s7FWIPcJWODJjD1l2u DJmfSr+vXUdQwKKaVytASwXsZWD+DBUGjxg4p6iJJox7zOtuuk5o7uBYjl7bWItwlPQlKi 9J7GOdtDf0vKbnYbXaF706jb/Ugjh/o= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=zx2c4.com header.s=20210105 header.b=BBV00V0r; dmarc=pass (policy=quarantine) header.from=zx2c4.com; spf=pass (imf28.hostedemail.com: domain of "SRS0=OGeU=NJ=zx2c4.com=Jason@kernel.org" designates 145.40.73.55 as permitted sender) smtp.mailfrom="SRS0=OGeU=NJ=zx2c4.com=Jason@kernel.org" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717770920; a=rsa-sha256; cv=none; b=Cjdqk9wCzAEFKUhxH6bDA66sok0uesn6ZcRATqkchIcZq6hnboVgix1kd7s99/rLkSee2S h7c7oy+gk9vZo0H8WjmUf/+IK/wLuVFvyESGybYj0drSNvxrsCUiBcmprr3CHGzjDrxcT8 /10jhKB+ABduemAuHZGdW5dnwMDOeco= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 8BE88CE1D9E; Fri, 7 Jun 2024 14:35:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53995C3277B; Fri, 7 Jun 2024 14:35:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1717770911; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ajPZqckOBJFHBstUW7T2O0UQJC/naoL0j9njP215Xzs=; b=BBV00V0rOVi6HrMqRiRVMBCf116AxoPzpLtxDhj5y+tsyMd3Ym3ffI3cnLv8dHVT5N405b VvhpMa4UmoOiBZt/mGdrFWTc2f3MuBriCR9lDODxjJx4qa7Kzoi9sOnhwxM3+615q3OZXt qRoQv2RdtEaMVDJt1qoRdCuTADRmaYM= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 26266bc1 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 7 Jun 2024 14:35:11 +0000 (UTC) Date: Fri, 7 Jun 2024 16:35:06 +0200 From: "Jason A. Donenfeld" To: Jann Horn Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, tglx@linutronix.de, linux-crypto@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, Greg Kroah-Hartman , Adhemerval Zanella Netto , Carlos O'Donell , Florian Weimer , Arnd Bergmann , Christian Brauner , David Hildenbrand , linux-mm@kvack.org Subject: Re: [PATCH v16 1/5] mm: add VM_DROPPABLE for designating always lazily freeable mappings Message-ID: References: <20240528122352.2485958-1-Jason@zx2c4.com> <20240528122352.2485958-2-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 10748C001A X-Stat-Signature: ng74kxbq9x85dbsi13enua4roj8irjd7 X-HE-Tag: 1717770918-910694 X-HE-Meta: U2FsdGVkX19/7Cc1/1mjn2Ba85evS8P+CqUUh7HhNCFU0XHNbBfEKjv3Q7dml/r0IgVaf5XZ+dMy26YdwfsgDy0BA6XFyIQUy0/Vh/NtUjNaBNzDFVSloLLjUmzzb3X9aD7vTvgwsr59Hxu71Y2577KxK3LoD2xYLefUwf0uEnm8sjld+l/STjQeQb5cfjHu4xsGvmSfK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oi5LzZ3O5K3Yw3Neq7RE3CTyrcQOKI4zNiO1aPp2mCp4+hHHLi6iVYKERsvAZbUPHMldiMkgAjKTZ4cu2nTDCf3RnNaTysCZDL33NxeieO74AVBPORdjT4JdvCwsVNSk60Encp03EKzhUvGenXST2NwbKhbtemwm0IsmTg/mR4fMvhRyH9fcd7NIzG5Kh4YrdZKHdIdGrJiHlORgrFumgmjASKgcO69lth X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 Fri, May 31, 2024 at 03:00:26PM +0200, Jann Horn wrote: > On Fri, May 31, 2024 at 2:13 PM Jason A. Donenfeld wrote: > > On Fri, May 31, 2024 at 12:48:58PM +0200, Jann Horn wrote: > > > On Tue, May 28, 2024 at 2:24 PM Jason A. Donenfeld wrote: > > > > c) If there's not enough memory to service a page fault, it's not fatal. > > > [...] > > > > @@ -5689,6 +5689,10 @@ vm_fault_t handle_mm_fault(struct vm_area_struct *vma, unsigned long address, > > > > > > > > lru_gen_exit_fault(); > > > > > > > > + /* If the mapping is droppable, then errors due to OOM aren't fatal. */ > > > > + if (vma->vm_flags & VM_DROPPABLE) > > > > + ret &= ~VM_FAULT_OOM; > > > > > > Can you remind me how this is supposed to work? If we get an OOM > > > error, and the error is not fatal, does that mean we'll just keep > > > hitting the same fault handler over and over again (until we happen to > > > have memory available again I guess)? > > > > Right, it'll just keep retrying. I agree this isn't great, which is why > > in the 2023 patchset, I had additional code to simply skip the faulting > > instruction, and then the userspace code would notice the inconsistency > > and fallback to the syscall. This worked pretty well. But it meant > > decoding the instruction and in general skipping instructions is weird, > > and that made this patchset very very contentious. Since the skipping > > behavior isn't actually required by the /security goals/ of this, I > > figured I'd just drop that. And maybe we can all revisit it together > > sometime down the line. But for now I'm hoping for something a little > > easier to swallow. > > In that case, since we need to be able to populate this memory to make > forward progress, would it make sense to remove the parts of the patch > that treat the allocation as if it was allowed to silently fail (the > "__GFP_NOWARN | __GFP_NORETRY" and the "ret &= ~VM_FAULT_OOM")? I > think that would also simplify this a bit by making this type of > memory a little less special. The whole point, though, is that it needs to not fail or warn. It's memory that can be dropped/zeroed at any moment, and the code is deliberately robust to that. Jason