Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1839651lqp; Mon, 15 Apr 2024 21:36:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWV92V7RURW252K8vAIsc+SFI9MoHkXyw1PNNrvdXjCVQLlwyg5HhN6ltmSwPu0bdTCKWjwWiFnYfXrtOFwBBcYnVHhnwMTfvmfmgViWQ== X-Google-Smtp-Source: AGHT+IHhNGFdc3A1wU8osUcLHInxgT+SuApF3nS+XQ79eX+fvTSZoqaV/qN6PYYU9O8oQyql14yd X-Received: by 2002:a05:620a:3cd:b0:78d:5d64:317d with SMTP id r13-20020a05620a03cd00b0078d5d64317dmr11601746qkm.75.1713242161344; Mon, 15 Apr 2024 21:36:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713242161; cv=pass; d=google.com; s=arc-20160816; b=VM1yVe0Fnd2qaF4yvQC0ZqiWbam9iKScWB6Wa2A6r27x9ylaBFrhMXWXoLPTB+YdHX BkN9Av3TgXSHskoMwEUSHcpMEwY3Ux5nI5wh0g8IINErSDiaf2ZkZwsAaSTdOx2VgB1J pHEY+HxCiNKe0FldjJ+0l1fiMi3ice75oQU6TElbCW62asptYrLEn0t24Rzwr5BtmMiC Xex7JbJErVfzlOTV1R4NtS5txbqMbFCbkbCrRo2H5jiNB2cAUCOfHParDWttjzMQzJsl dJVbLbkXn77MjlEMF2WuE6fakgqUZa/rxKCoZtAiJBd9jABPWi8P1ZjxugeZ0ok1uBrl Tb/A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=y4OQjG/SQObAypZdOJmY4oLcZqFzZ75jK2QHH/IhD6I=; fh=Fit3tSs8aKAssy7EUSJGTPHciqOHiOOw4KTIh4cYLoE=; b=b3g57xLhv6heyoss6EKFWLEeb73rTloBNY+HxxhAfV85AeA9ylxmtM2NATzpPkyjmj 5gFO8K3frTvBY3rqcZu8AtMmh8YUQHBRjjHKE0PJzK5gmpBHr1nX7LvQx9bpnohnLi2g TFrrMrnwoKtkWsG+V30MpMrzaO37y1DIu4SO2LnlQA6giUef8+4kBy2HM8H1j4FqdT1W drbxPn4e61lPZ4+5hzJvmWwsVptAdeM4nzvanXijJSVqJ/bC0dpqw4jLw2bKdqmiF2be 4pW/nqFH1R4SlFKbY+6+lHVXihvh2yPGDlYaCMmQE3iy+z2S1xZZpV3CRWl16ULXfVGh lGjg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=dWZHFX+9; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-146230-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146230-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 f20-20020a05620a12f400b0078842405561si11754665qkl.734.2024.04.15.21.36.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 21:36:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146230-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=dWZHFX+9; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-146230-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146230-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 18C541C21407 for ; Tue, 16 Apr 2024 04:36:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EBD7127715; Tue, 16 Apr 2024 04:35:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="dWZHFX+9" 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 D9FD31E53A for ; Tue, 16 Apr 2024 04:35:53 +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=1713242155; cv=none; b=Iw2drTjlq+lbo0wu+maip4sYTxVKBtm47/zZRGjGVbzFZIsqbLhQGYeOqYOCBlFOz/qjvX1qxnbIizPhjINoFphoJOqcrABgrjofz8d8JNeoF4oIMt1xn0+NnRbQVNNYucTqzncqOdbNo8rABSSBE/nIuTSSlZik7qZOxLPNqEQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713242155; c=relaxed/simple; bh=rLUQL0Q6AoIyYHgQy5JyiMrJ9GqKGQXJZrP3QqVCS+c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZiBzhKzeipV/llbQNnwTogvZRr2CNfcIrPQP2ZkzvjFGa7rMx0ktVSLGLzw4TrOQ78gdo4Ef9QY1YZMiGKwbDbWauMHhN+CjALljG6CNqziknvQiX6k7n7Vhjrwl82C+ccCJuRoH4Ug5KZ/F2As31hyteXm5isQEzX4+2Nmuky8= 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=dWZHFX+9; 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-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=y4OQjG/SQObAypZdOJmY4oLcZqFzZ75jK2QHH/IhD6I=; b=dWZHFX+9nkrpBo6cOqeNwr/T4n sOBtxyh8FEbubvkmTZgBr6/vA9tGQiFanRwgth+sOeXonRCq4QfGvgrCy/0qpOQKsqJIowfypJ/Ae rgIxh9n6zPup9xadU4Jvz6eRe6MR6VrASk5fbilYhTVOdRAfAr8yXO8gA80OZ+bvOk3UdowvBUmrB jjlrja4LlipBzMN3yYufhNDsW9ICmnNqIBk34nANY5yvb2wK6BeoHkcw0xdIMIvWEM34a1gvloFWu FbavR9iTCatx/3s7N6XhjFmorIdgd56yRIFOzn8JA5ruLm3eDT8f1cJdN32he9F8v9NPuQXafIAA1 /vuIDmDA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwaXu-0000000HETq-2Pis; Tue, 16 Apr 2024 04:35:50 +0000 Date: Tue, 16 Apr 2024 05:35:50 +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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Apr 15, 2024 at 04:02:48PM -0700, Vishal Moola wrote: > On Mon, Apr 15, 2024 at 3:15 PM Matthew Wilcox wrote: > > > > 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. > > That's true. Though that can be addressed through something like: > > if (!(vma->vm_flags & VM_MAYSHARE)) { > ret = vmf_anon_prepare(vmf); > if (unlikely(ret)) > goto out; > } Why does hugetlbfs use VM_MAYSHARE while regular faults use VM_SHARED?