From nobody Wed Oct 1 23:35:02 2025 Received: from mail-il1-f197.google.com (mail-il1-f197.google.com [209.85.166.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 374DD2E9756 for ; Thu, 25 Sep 2025 23:19:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758842395; cv=none; b=tdjf/fdE+0PmyyrWD+pLoozUAjCkSTLPttqrHwEwoQgbLYcQGRt4JitjW6sOJgD4f+eSW58E6sBAqJxedHoAwUQqmyHKri4k5ovxfYEGHOQe+BJZ3+zKVDSgQBCToOrEJkpad7N5WSRy9KR2dkO7pF5QzZ6HFRXH4nSercQ61rk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758842395; c=relaxed/simple; bh=V/CdUada7iXZR4rEyz9RDA2ZDVmTnpw3JSIv64HjZ14=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=DJW2LI7WI0juSMJeP6Xh5Pg98VYSXgSROYL39KG71qgpI1EhIWjMi9hAQC8K8MHOMQiC9/divdAfqw2i+tISUiMmQgaTsErgi990JBi83jtMwgetDiddMVSqdWFLzjr/Ibn2p/48fGbvWZB1WcjQwOk3ONkuAXNadDbTmJZUoIk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.166.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-il1-f197.google.com with SMTP id e9e14a558f8ab-42594b7f2ddso23232485ab.2 for ; Thu, 25 Sep 2025 16:19:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758842393; x=1759447193; h=content-transfer-encoding:to:from:subject:message-id:in-reply-to :date:mime-version:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xUY5B0L3NTVJlK2+SN5PD/Pw6QTKWkT/zpDzKOEtagM=; b=wkF7DHT/2wtYjem/fUJh/isaU1okUmMxKWnp4ZzBYhXaE+qetOmHMCK24lC2jsgoes tXRvEvTPWRlaBsZhkjH4nGPwe/MskntkfMUHC45E3rs3YVRJ4NpI4DDyIbojvHDijDRS aSROAgxIq8uozbgjUksAfpVvER8yC9EfwGSGN5Y/lvokAg24pDQivu2yLyuW0RkvCt9p 57GKI4wfsa/CTTKC9LjQ6LEl8NUv/1fv2GbXcuhMGUPDzZc0Np7FaCYNXAmraE3rxaWm /VwiLumo05vwHvN537OMXVM3Zjxym4Buw+0PndVRR5cOcoO1++43GEgUYHjoXYCvx+U4 cqoQ== X-Gm-Message-State: AOJu0YxCustPJG/I/A/myH8v3vCLKHBbqq15bwlLJA7Oonc38mPOD7sL y1Cf8sArkOJr5/hfApo/vyjNCOR06/EwFIl3xzkMZPH7ycS1/T6C0rqdUg1ncVRz1ajyW4kSAw/ 1Wo/p/eOe1riJkJ3n95og5znLCV81JVlpRKJ/aOy44gvJzty+mymYYc/DavE= X-Google-Smtp-Source: AGHT+IFseW8JqtFyaAxHzrhVYKwZzv2K71DRS+tn+TqrC2x6lDL8xbsxiiKHHMxhU69sYEIAV59ccORxciBbuBaWcvy1TWWXy3EG Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6e02:218f:b0:424:b862:8329 with SMTP id e9e14a558f8ab-425955cc9a8mr84146725ab.6.1758842393423; Thu, 25 Sep 2025 16:19:53 -0700 (PDT) Date: Thu, 25 Sep 2025 16:19:53 -0700 In-Reply-To: <68d26261.a70a0220.4f78.0003.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <68d5ce19.050a0220.25d7ab.00ac.GAE@google.com> Subject: Forwarded: [PATCH v2] hugetlbfs: skip VMAs without shareable locks in hugetlb_vmdelete_list From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH v2] hugetlbfs: skip VMAs without shareable locks in hugetlb= _vmdelete_list Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.gi= t master hugetlb_vmdelete_list() uses trylock to acquire VMA locks during truncate operations. As per the original design in commit 40549ba8f8e0 ("hugetlb: use new vma_lock for pmd sharing synchronization"), if the trylock fails or the VMA has no lock, it should skip that VMA. Any remaining mapped pages are handled by remove_inode_hugepages() which is called after hugetlb_vmdelete_list() and uses proper lock ordering to guarantee unmapping success. Currently, when hugetlb_vma_trylock_write() returns success (1) for VMAs without shareable locks, the code proceeds to call unmap_hugepage_range(). This causes assertion failures in huge_pmd_unshare() =E2=86=92 hugetlb_vma_= assert_locked() because no lock is actually held: WARNING: CPU: 1 PID: 6594 Comm: syz.0.28 Not tainted Call Trace: hugetlb_vma_assert_locked+0x1dd/0x250 huge_pmd_unshare+0x2c8/0x540 __unmap_hugepage_range+0x6e3/0x1aa0 unmap_hugepage_range+0x32e/0x410 hugetlb_vmdelete_list+0x189/0x1f0 Fix by checking for shareable lock before attempting trylock, avoiding both the assertion failure and potential lock leaks from skipping VMAs after locks are acquired. Reported-by: syzbot+f26d7c75c26ec19790e7@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=3Df26d7c75c26ec19790e7 Fixes: 40549ba8f8e0 ("hugetlb: use new vma_lock for pmd sharing synchroniza= tion") Signed-off-by: Deepanshu Kartikey --- Changes in v2: - Check for shareable lock before trylock to avoid lock leaks (Andrew Morto= n) - Add comment explaining why non-shareable VMAs are skipped (Andrew Morton) --- fs/hugetlbfs/inode.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 9e0625167517..44943e97adb0 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -484,6 +484,13 @@ hugetlb_vmdelete_list(struct rb_root_cached *root, pgo= ff_t start, pgoff_t end, vma_interval_tree_foreach(vma, root, start, end ? end - 1 : ULONG_MAX) { unsigned long v_start; unsigned long v_end; + /* + * Skip VMAs without shareable locks. Per the design in commit + * 40549ba8f8e0, these will be handled by remove_inode_hugepages() + * called after this function with proper locking. + */ + if (!__vma_shareable_lock(vma)) + continue; =20 if (!hugetlb_vma_trylock_write(vma)) continue; --=20 2.43.0