From nobody Sun Feb 8 14:53:23 2026 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 BF42A4A22C9 for ; Thu, 8 Jan 2026 10:55:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869740; cv=none; b=JYSaXY3+sjdIXeHWHgLyJKGweNcdIe1XhH3E7nQFW0CxDqo4MGvU2g7vfRb7zqoTKksxKkuvwmZnt2O3b+MfaNJPFhSIPW57ct4YfXk2YGnSKMdCWQiX3cILKS5DGeIS/88rLtmtnw/zhzepL5hAoGlKM08cIuV3+b0EhKpEUFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869740; c=relaxed/simple; bh=XcRQg2G2o2SfOilA2XbJRGMWdrIfH4T33o69OmnUhPc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pJIimd2x09bfpI9h0oY+hObTysbcCX4zZu17WB7yWqznIXAZhBVfRD6vJGRqAb34uA3p0nqfrKVPL2NuvVkIRV6mpelS9Gd2NXgPDEzVhtGR73NBE0eem/r7n0S2kNOdzDZKkSgqfj81mQoP7QYOC0dtCGrWQz0gkEzag6xy+UY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KmKdBfSs; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KmKdBfSs" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2a0c20ee83dso29689105ad.2 for ; Thu, 08 Jan 2026 02:55:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767869730; x=1768474530; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=DHTzlN3ne4Ca1xHRIpbpm7OG9FOpF7oWM2iJIQY7fNo=; b=KmKdBfSspIMydRHhErzoSU2OpUNjBMIflW9kw0LFJA3jKQB7neesmWTELxSfOKO2ZC PT+H6e0hMa9FchwGtm45T2Z1JRxgaOV7EE9ufk7SkhOoCrdRCzGD9bfic2uFYged1ARP ol+nH4AB2rmnbEyhRcUisZRUVYBsqtQ/vMEctTyDktSdGV7Pcj4OsCOJ8zs30njNPMW6 WwlEjuc2pMrsy6iFEMRQ/5TxWHl+GnhHSn5k7K9WT+D1F9x8evm/NUjK+iuE49Z1SdoG QUYMaLQ85PcyMjZJ/9qg/eOwtfBkXR9nrWNb0AqkGKCGysi4f78MXZdttxKhaX/qa2Xr luow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767869730; x=1768474530; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=DHTzlN3ne4Ca1xHRIpbpm7OG9FOpF7oWM2iJIQY7fNo=; b=NGQgZ1YEHt2witAk9xgXsxQQJRO8j/doXcYr0/riBLH57orPQwITK6cOJ1Bgl9y/Yn nOF84M/bQqwmTRi51wGTZ4ur7XlCTUs3fKrZvbYq6lNY/nUCLRZLIaVk9Dzg2kH3n8pk 4n6YnsgMIjBRAISeCxlkUj99etpLteh+6GP62rc2am2QO8F3FB8VuXqHOgwWFtaIPWIW hspoYnmdYUkFXhVBQLGoOUIHovhgVhm1F/mBrFCd3SBcKFA1HqFriqDIdmqrpMqUJ4Ir ncH+fEt2Fvm/i9iCMzNVd9gkeYJS5dlUfa8GuVwawEMPgGa0h1NwX/FUGnM/yRTIHXzu 5BMA== X-Gm-Message-State: AOJu0YybMVu8DWCPsOEwvn2Nh9+JGfByNExBOpb/ijbEUx2AIY80WIml wbTtukrzeWFA7okxdWHRsh8Yf/Qm0YSKEzkK3M3PJ0ziKZij7lCerkf8+aJpkY2/to0= X-Gm-Gg: AY/fxX5GXmaTTQLWvMFAUdwJDxAyNNX7U11UuTrRwBAHOS0lQecZp+snBxWPHSmuXtI H/LEIGCqza/JpWtQtbsC9qFERkdnEu3rv/0WwGCiXh9BRrkKqoGP+Ft5EnEIn40wfSzxoCGR23u JTASb+ZpU8MosXPFkRpxSwFabqqZpG3dcOGj5HIOmUvZR1/gFjwDKlJdbzUnSkyXqJILhwl9LvM XcdEka7fNRAlbJ92UPfXJzBFTNkNw3MBpLh5+fGAtINyP4TlZgHkLh/68HD8CQsumbcOvqQC2jQ rbFbgdSC5t92DPuwLR1HF0tZDwjbbULdmS21yA2aPMX9UObPyK9BDzcaNYKFoSD82kiwmWWoEnD DvWrI3Qh1m/RR/8WiXTY6heshWoh4xsF444/cr2jhLxD2JxDTw6SzK+4FJ3AeOENbE4JCmpSE+k DwYKttJMg3MqlKsQ== X-Google-Smtp-Source: AGHT+IGWWzL/wGH2CTEZ68qfgzSl1CFGpFXI6w1x9o+3OgHfygck6KC4KLvi1Ni9pqchfgwJ1njxcQ== X-Received: by 2002:a17:902:ce88:b0:298:6a79:397b with SMTP id d9443c01a7336-2a3ee4b8d62mr51978865ad.56.1767869730541; Thu, 08 Jan 2026 02:55:30 -0800 (PST) Received: from localhost ([2a12:a304:100::205b]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a3e3cd4401sm76925475ad.92.2026.01.08.02.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 02:55:29 -0800 (PST) From: Jinchao Wang To: syzbot+2d9c96466c978346b55f@syzkaller.appspotmail.com Cc: linux-kernel@vger.kernel.org, Jinchao Wang Subject: [PATCH] try fix Date: Thu, 8 Jan 2026 18:55:10 +0800 Message-ID: <20260108105519.994856-2-wangjinchao600@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" #syz test --- fs/hugetlbfs/inode.c | 33 ++++++++++++++++++++++----------- include/linux/hugetlb.h | 2 +- include/linux/pagemap.h | 6 ++++++ 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 9c94ed8c3ab0..a8f33b72a8a6 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -643,17 +643,16 @@ static void hugetlb_vmtruncate(struct inode *inode, l= off_t offset) remove_inode_hugepages(inode, offset, LLONG_MAX); } =20 -static void hugetlbfs_zero_partial_page(struct hstate *h, - struct address_space *mapping, - loff_t start, - loff_t end) +static int hugetlbfs_zero_partial_page(struct hstate *h, + struct address_space *mapping, + loff_t start, loff_t end) { pgoff_t idx =3D start >> huge_page_shift(h); struct folio *folio; =20 folio =3D filemap_lock_hugetlb_folio(h, mapping, idx); if (IS_ERR(folio)) - return; + return PTR_ERR(folio); =20 start =3D start & ~huge_page_mask(h); end =3D end & ~huge_page_mask(h); @@ -673,6 +672,7 @@ static long hugetlbfs_punch_hole(struct inode *inode, l= off_t offset, loff_t len) struct hstate *h =3D hstate_inode(inode); loff_t hpage_size =3D huge_page_size(h); loff_t hole_start, hole_end; + int rc; =20 /* * hole_start and hole_end indicate the full pages within the hole. @@ -688,12 +688,18 @@ static long hugetlbfs_punch_hole(struct inode *inode,= loff_t offset, loff_t len) return -EPERM; } =20 +repeat: i_mmap_lock_write(mapping); =20 /* If range starts before first full page, zero partial page. */ - if (offset < hole_start) - hugetlbfs_zero_partial_page(h, mapping, - offset, min(offset + len, hole_start)); + if (offset < hole_start) { + rc =3D hugetlbfs_zero_partial_page(h, mapping, offset, + min(offset + len, hole_start)); + if (rc =3D=3D -EAGAIN) { + i_mmap_unlock_write(mapping); + goto repeat; + } + } =20 /* Unmap users of full pages in the hole. */ if (hole_end > hole_start) { @@ -704,9 +710,14 @@ static long hugetlbfs_punch_hole(struct inode *inode, = loff_t offset, loff_t len) } =20 /* If range extends beyond last full page, zero partial page. */ - if ((offset + len) > hole_end && (offset + len) > hole_start) - hugetlbfs_zero_partial_page(h, mapping, - hole_end, offset + len); + if ((offset + len) > hole_end && (offset + len) > hole_start) { + rc =3D hugetlbfs_zero_partial_page(h, mapping, hole_end, + offset + len); + if (rc =3D=3D -EAGAIN) { + i_mmap_unlock_write(mapping); + goto repeat; + } + } =20 i_mmap_unlock_write(mapping); =20 diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 8e63e46b8e1f..e7d99183361a 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -811,7 +811,7 @@ static inline unsigned int blocks_per_huge_page(struct = hstate *h) static inline struct folio *filemap_lock_hugetlb_folio(struct hstate *h, struct address_space *mapping, pgoff_t idx) { - return filemap_lock_folio(mapping, idx << huge_page_order(h)); + return filemap_lock_folio_nowait(mapping, idx << huge_page_order(h)); } =20 #include diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 09b581c1d878..94f31035fe1d 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -820,6 +820,12 @@ static inline struct folio *filemap_lock_folio(struct = address_space *mapping, return __filemap_get_folio(mapping, index, FGP_LOCK, 0); } =20 +static inline struct folio *filemap_lock_folio_nowait(struct address_space= *mapping, + pgoff_t index) +{ + return __filemap_get_folio(mapping, index, FGP_LOCK | FGP_NOWAIT, 0); +} + /** * filemap_grab_folio - grab a folio from the page cache * @mapping: The address space to search --=20 2.43.0