Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1717318lqp; Mon, 15 Apr 2024 15:15:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUAQMjMZLPenT8KWKTFB1qMiJ7ZVIuf1ddzIRgC/ZdxyULsCyLiWQxyjok5uLPqbhK1HeKTgaG9/RIie50Hj/W73Yj/IUSVDCEVaoO0Mg== X-Google-Smtp-Source: AGHT+IGBvwjza8ChE/8Ub7BJeAD+C0TUrth68UIabi31PAEieO9YMyPcWpsey3ccdCRlBl0YGjN0 X-Received: by 2002:a05:6214:949:b0:69b:4c1a:83ca with SMTP id dn9-20020a056214094900b0069b4c1a83camr10152688qvb.26.1713219316266; Mon, 15 Apr 2024 15:15:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713219316; cv=pass; d=google.com; s=arc-20160816; b=oC+pPtxSzdtyVehUvKkU4ckyEhxZDQAZYJr+VFJ8YlYwjDmOgTFxcvIhue+Q/y62Fp meoihJ7lyvu0xmDGSNjhI84nDInPRaSe1vPETiZmKqykxj7Xa8FSiaalgfI7hoC7DHVP fOvNBlVCzfaxy82cVVdT8EesSgf2vkv7YvI9OnV3ywEDif8jg+I0Cztv0wcz0IBxo9cE MOWNIR2fAjtRIy3jY5O0lg3kjC205wJ0Qm/iSCD4ODBu2yXypNUE+spBKnxOB3kXOaRG f7LM34r/S8brczuDiNafe6746DdjAIzrpOqLvEtab3QRScklOX3H9195jjISYZVgszRN 5pTw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=anUTzNn+XCSh5szgQ2VdZfjbgbKcul8tT9KISExHK4I=; fh=Fit3tSs8aKAssy7EUSJGTPHciqOHiOOw4KTIh4cYLoE=; b=TzspjNI8WpYHQp6ENslmc4BvM+vG9EVaryXP9ChvKpfbMUvb2Ej4zIyBjpQMamtUYf SGOmL+iFMZ34g1R8c/xxZAxCUVG4xuTuwqNK91eJjVQ5CSHoHP9C+jemT9uebMA876zk ssizhxqSg5eP7qz0xy9as2dOmWfr8xnJPVxIHYGw67l8CirucNtoVSBQISjq+1d9Ts3X PbJ+si0VV9Fe4D/Ak2V1j+kIslqWJxELVaGH3P6mBJp9I1sQ2S4qoKsHeQFXDAYwSWy4 /jWG8ClNuvZJv88+PdU1E2+5Tgk9804XrHptqXiU/LENGarLQi1Do7AjfFxZf4HAZztZ 61yA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="XQgDpiY/"; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-145968-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145968-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r8-20020a0cf608000000b006993ddfd4a5si10490888qvm.71.2024.04.15.15.15.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 15:15:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145968-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="XQgDpiY/"; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-145968-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145968-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E363E1C20BFE for ; Mon, 15 Apr 2024 22:15:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97D04157A61; Mon, 15 Apr 2024 22:15:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="XQgDpiY/" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 766FC25601 for ; Mon, 15 Apr 2024 22:15:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713219310; cv=none; b=YVrQ5ZTzYdufwePsdudLNOhKQ4mipnGXDs0WADBXn8GtKwdvPl059dTB26RB8bfRlVFfHE6pUXQPNGay/LaqT+tIqFmWPijOTZ6niVHeayimY7zIMwSATA+YxbPxSLC+fXwPAxE/irmww1r1aaEt1e+JwNYXTzdynSbDnh/N1ps= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713219310; c=relaxed/simple; bh=PY44UZjjjuhrlz20AyxwSiMqoFKLANo/z/GnBHE0Uj4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OGIwT4fSrCXr2Q4gOx3UK9/OGNk1ypfxH+ViaIzxnrkbsYjp7yILRkyGnrhb7Cr5dv47hVU6XP2tAqA9vpx1ekgbp4EU2mq4V1FE+DGTKeg5/5Ib5Ap6M/jWbKMdBpbuVaJMkzhnpQi1+s1CN/SIq5XiAWLEIm9EariKkw6kURs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=XQgDpiY/; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=anUTzNn+XCSh5szgQ2VdZfjbgbKcul8tT9KISExHK4I=; b=XQgDpiY/ZLRUxbAWj8QHZRpuce 4fLm0z3rwhAL7vNnOmZs49/ktsbPbNe/bfVJ+gLne6S0NkdmxIwWHOLW1fnQ6qVdQqsricx07yIbl 24ODbemxB4zUtxJQPL2MJ6GbdF1hxMR+NO1F2enzLcA0YLx1ZLepzUVK9BhHq17WoJ6bmt1vKgQvT U+qjyCIv9JwQUFvXfWbGDinewWPPPZzfrs5phOhykyIwxY2tTJGsDKJdDf86xbl7WP+Si2OfOOI6K GDTk08AtsfpucR24DmB2SdfWRdCtdc96FmIfUYPzHTEAR/EV6qhZShIgxi3hsVF6o2YmF0rfh1YnE tB/VKGeQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwUbP-0000000GbxN-28TT; Mon, 15 Apr 2024 22:15:03 +0000 Date: Mon, 15 Apr 2024 23:15:03 +0100 From: Matthew Wilcox To: Vishal Moola Cc: syzbot , akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, muchun.song@linux.dev, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [mm?] KASAN: slab-use-after-free Read in __vma_reservation_common Message-ID: References: <000000000000daf1e10615e64dcb@google.com> <000000000000ae5d410615fea3bf@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Apr 15, 2024 at 03:05:44PM -0700, Vishal Moola wrote: > Commit 9acad7ba3e25 ("hugetlb: use vmf_anon_prepare() instead of > anon_vma_prepare()") may bailout after allocating a folio if we do not > hold the mmap lock. When this occurs, vmf_anon_prepare() will release the > vma lock. Hugetlb then attempts to call restore_reserve_on_error(), > which depends on the vma lock being held. > > We can move vmf_anon_prepare() prior to the folio allocation in order to > avoid calling restore_reserve_on_error() without the vma lock. But now you're calling vmf_anon_prepare() in the wrong place -- before we've determined that we need an anon folio. So we'll create an anon_vma even when we don't need one for this vma. This is definitely a pre-existing bug which you've exposed by making it happen more easily. Needs a different fix though.