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 D40E8C3600C for ; Sun, 6 Apr 2025 22:43:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A9C306B0006; Sun, 6 Apr 2025 18:43:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A23A66B0007; Sun, 6 Apr 2025 18:43:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C4236B0008; Sun, 6 Apr 2025 18:43:52 -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 6D9A36B0006 for ; Sun, 6 Apr 2025 18:43:52 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 579DEB9ABA for ; Sun, 6 Apr 2025 22:43:54 +0000 (UTC) X-FDA: 83305097988.24.2479BD6 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf24.hostedemail.com (Postfix) with ESMTP id C4593180006 for ; Sun, 6 Apr 2025 22:43:52 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=wuPMvxVC; spf=pass (imf24.hostedemail.com: domain of akpm@linux-foundation.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743979432; 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=5aXBjYHPuPAoL4uJauQinfNlJhxfxUalJgRddUhZyWI=; b=YsBLQC52kFhk0LleSA5+9ZfUVuiZ1PrPVGqjt+DuohaxyQxd4wF0fzu186PPvNCtC1XObf 3xmd2uQZ01Haf28411e98sAW984XguyvRDT/I9/HHJEZ2pNC/U9xFCqxlNBBlP7BrvttI9 ezIrNHut/FogQgH3jtm5Nwk7VsWReQU= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=wuPMvxVC; spf=pass (imf24.hostedemail.com: domain of akpm@linux-foundation.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743979432; a=rsa-sha256; cv=none; b=frdYrX7s6r9ifMT/AQOxlVfXqrXmh4QmWQV5vYxEP0zJ9JsspiAMuYH6whZH6e5uHOq7bx hSs5ef/eWGvt3M9eZwZ5/z4Q+VenLYT24jsycSwDafOwvz6z30HAhqqbMwro2zQY8xR3hX EUf9q3wHh33HOL968n3DiEy67Q+WgzM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 36C13A446E1; Sun, 6 Apr 2025 22:38:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0044AC4CEE3; Sun, 6 Apr 2025 22:43:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1743979431; bh=PPnslXylEhTtIqcZP1zA7VjxCnH22TgyFdaY9P/3FW8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=wuPMvxVCE8+4aiqtGExDnopvHAcsq6uBA8+PJ8FwpBrL+wivAF84r8joG6Pjyaz5+ q10idyUKzG83mIdwq69Ww9afBWPyfglXGwhLXi//rJALgNHz2b/v0TjRSVNH/gJ83j B2LIp3iygXgBNHkRv5lx6JxN5sqeM31Gs38ANEAM= Date: Sun, 6 Apr 2025 15:43:50 -0700 From: Andrew Morton To: Lorenzo Stoakes Cc: Vlastimil Babka , Jann Horn , "Liam R . Howlett" , Pedro Falcato , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 6.15] mm/vma: add give_up_on_oom option on modify/merge, use in uffd release Message-Id: <20250406154350.c548ca25ef60b41fc86d5942@linux-foundation.org> In-Reply-To: <20250321100937.46634-1-lorenzo.stoakes@oracle.com> References: <20250321100937.46634-1-lorenzo.stoakes@oracle.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: C4593180006 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: buwc1umsex17uq6rokh5t8x467f1sspp X-HE-Tag: 1743979432-484447 X-HE-Meta: U2FsdGVkX18Ix2mlO65786yB529vvRcnSf83UcWc9nLTEahzSfZ+HIJU3POAfaRirMIFzQPnUaeRPFXiGFmVVY8flGHy1qKehhd2nJIKeBEx+Oi7e266VB4HIK2CiZkqY94v6J4v3fEnBzr6wBri4I7I33Gj5nPjahBAnbc6RtU3P/RQbN3sk1xBQj0G6/c7Db3KqPaNPOsU5ABnCVlLPM76qy1PjzBhO6QqoIka9Qx5U3lfTpDjj4zBRYVB7Ej6lZtrUYh99C8L2td0rUyAXVhkgrhgmqPkwyB7QUan6PZQXXAME7scccDi2WapI5VNfNWRDm8qukdY52kPbzEjKAn8PZZpwA9w3pXQNhTeyGXFCHpEKHbngotpOTXfh7sOY79lg7BSbX/6EZ8ZliR7bJwDKFSX19rQFC1t5mqR6OaStk03UJ+JKQdEGjffcj5EWGKUXXw0Us7FN0XCCApJ7j6l5vRFjWlno3AyKnkHKIU8FHZeAG1CUwv/NQCa//o42wdKWjVjW1RxWGUHc+P401WSzjQsCEQ8h9U4WeNNOISPjZMBB8DpHTw/kH9IYhWkjynvpJ5cTbIckbrMvd0p/zHlUT4fNG6/9n4RRAxda3h1FA91MlI6qHgq1eEDFhWe+4EmuxQQ6VX/Sf0W4PFxcMW0uuk52wx9v+QY9DPDK0H0axp38nFwgfvwpTEpauowfqjH2OB5VodWlwUoWADXLsnDKuSJ2dBd07N3sAb0lgPDmofPN1JbLEdRxIJKzFZUD1mFexCoeoMBysPJ/voagBj35APITYT9olSw2eu9K1jYQCpbfZbFbN1G+kjT+gVAwa1BmK66IniCXB+STC6GL1s+KuNJKCna3BG3gEwdp/UxA6//JxEw0rOQXuMo2YBqQ11teCIriHjGKAjZ+oti0bhMdIhBeowWKwaBlrvlhVvQXFiI2x3yyOBpY/MDdi/ktJhyAKNHVAb30H1QdH1 11w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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, 21 Mar 2025 10:09:37 +0000 Lorenzo Stoakes wrote: > Currently, if a VMA merge fails due to an OOM condition arising on commit > merge or a failure to duplicate anon_vma's, we report this so the caller > can handle it. > > However there are cases where the caller is only ostensibly trying a > merge, and doesn't mind if it fails due to this condition. > > Since we do not want to introduce an implicit assumption that we only > actually modify VMAs after OOM conditions might arise, add a 'give up on > oom' option and make an explicit contract that, should this flag be set, we > absolutely will not modify any VMAs should OOM arise and just bail out. > > Since it'd be very unusual for a user to try to vma_modify() with this flag > set but be specifying a range within a VMA which ends up being split (which > can fail due to rlimit issues, not only OOM), we add a debug warning for > this condition. > > The motivating reason for this is uffd release - syzkaller (and Pedro > Falcato's VERY astute analysis) found a way in which an injected fault on > allocation, triggering an OOM condition on commit merge, would result in > uffd code becoming confused and treating an error value as if it were a VMA > pointer. > > To avoid this, we make use of this new VMG flag to ensure that this never > occurs, utilising the fact that, should we be clearing entire VMAs, we do > not wish an OOM event to be reported to us. > > Many thanks to Pedro Falcato for his excellent analysis and Jann Horn for > his insightful and intelligent analysis of the situation, both of whom were > instrumental in this fix. > > Reported-by: syzbot+20ed41006cf9d842c2b5@syzkaller.appspotmail.com > Closes: https://lore.kernel.org/all/67dc67f0.050a0220.25ae54.001e.GAE@google.com/ > Fixes: 47b16d0462a4 ("mm: abort vma_modify() on merge out of memory failure") I've added a cc:stable to this.