From mboxrd@z Thu Jan 1 00:00:00 1970 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 D917C283FDB for ; Tue, 25 Nov 2025 04:27:24 +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=1764044849; cv=none; b=ZAv00pdXL8IDfd3R5HcTQE1qMTOOfsCtIXPhsqSJGfPz3Adicoy3eS7pUPL1HO8sfWQFk7rKXWQleAh9c/KFl6b6KydZLmYQLAdh7hCZPLlVcwui1KuS9AnqHweORTgl5aZb+X1rOOvMZpFG9HUznPzkPYVnOppI/B+fV3mUlFo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764044849; c=relaxed/simple; bh=fzCe4T/FtQrGB68rnYOmD36SmIR7RAT4dXlwWBHz8S4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=h+rgNFG7TsyWMCPoDzSZapenHzmfFur6f7zo7B7pKxkU2nvhin6vkPZ/ohK+Fh18z69OkUijoancz9vSQVKZkOoxl4eRSk7FMJshCVwDA5vCmmJbxrdObp7hCKuOCFRX979CxOKSvY4SqZyZXjOcN6P+e1pYa686PgZaesoT22k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (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=pDROx3U+; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="pDROx3U+" 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=nETtmOazMk8q5bK36CAyeBJ2Wh5i5mbm/naGgQItvz4=; b=pDROx3U+76x7CWF1RqpD+nR/db jDnWA/BImv3oPDRAfy4FBEaMhBOPZVNcdyGc7EQZmH1Dau8kKwWoH07vCbcAcuTx2xi13Gxux97T1 xa6RYHt8qxjZE4JG+erltQa5Yy7GR+ocLM7Qe6a0pxi+C2kV/bvC31kB8A7xQ8ZKRj5RcQvLtQb9j ku5RLGYhm/Gq9GDY9YnqFOz2OoHFNz1jXw0/A4CBVj2YqVgdQSHKNR2nqnkV5IMS/9nI1Rs+pdrOs Wm/jFmQbLPtd+VECwIOKxGm2Jx1aBIMZJjrPatP870489XnkAo3we/+D7RbB1Q+SQwGXI/EO4fb8J 5MXzK6BA==; Received: from willy by casper.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1vNke8-000000080je-34Bu; Tue, 25 Nov 2025 04:27:20 +0000 Date: Tue, 25 Nov 2025 04:27:20 +0000 From: Matthew Wilcox To: syzbot Cc: Liam.Howlett@oracle.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, lorenzo.stoakes@oracle.com, shakeel.butt@linux.dev, surenb@google.com, syzkaller-bugs@googlegroups.com, vbabka@suse.cz Subject: Re: [syzbot] [mm?] WARNING: refcount bug in __vma_enter_locked Message-ID: References: <69252076.a70a0220.d98e3.009b.GAE@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: <69252076.a70a0220.d98e3.009b.GAE@google.com> On Mon, Nov 24, 2025 at 07:20:22PM -0800, syzbot wrote: > refcount_t: saturated; leaking memory. Umm. Something like this? #syz test diff --git a/mm/mmap_lock.c b/mm/mmap_lock.c index e6e5570d1ec7..71af7f0a5fe1 100644 --- a/mm/mmap_lock.c +++ b/mm/mmap_lock.c @@ -74,9 +74,18 @@ static inline int __vma_enter_locked(struct vm_area_struct *vma, refcount_read(&vma->vm_refcnt) == tgt_refcnt, state); if (err) { + if (refcount_sub_and_test(VMA_LOCK_OFFSET, &vma->vm_refcnt)) { + /* Oh cobblers. While we got a fatal signal, we + * raced with the last user. Pretend we didn't notice + * the signal + */ + refcount_set(&vma->vm_refcnt, VMA_LOCK_OFFSET); + goto acquired; + } rwsem_release(&vma->vmlock_dep_map, _RET_IP_); return err; } +acquired: lock_acquired(&vma->vmlock_dep_map, _RET_IP_); return 1;