From patchwork Mon Jun 17 22:18:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 13701488 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3CD6C27C79 for ; Mon, 17 Jun 2024 22:18:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1A4396B0299; Mon, 17 Jun 2024 18:18:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12DA86B029A; Mon, 17 Jun 2024 18:18:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC1976B029B; Mon, 17 Jun 2024 18:18:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id CADC86B0299 for ; Mon, 17 Jun 2024 18:18:32 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5384740116 for ; Mon, 17 Jun 2024 22:18:32 +0000 (UTC) X-FDA: 82241795664.14.1605487 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by imf03.hostedemail.com (Postfix) with ESMTP id 7D3B220014 for ; Mon, 17 Jun 2024 22:18:30 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nQH+hS9H; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.215.179 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718662705; a=rsa-sha256; cv=none; b=Nyl2X1txggc8KxFH0J7bYmW9ALQcBZczL6+SA/5qortglJQ7jbM/U7JDKvg0ZkZo8dVXUQ AXpYMYkzWEs2DVzJ/dFjJSWlhEz/xO6CthHf9EnoxUXyhsS8coGAkkQ9bujxJAtx0KeQYb p2B6REErJ1ULsZraDDRgEFT5zWENmX0= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nQH+hS9H; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.215.179 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718662705; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=WgpPhgSpGnuAzgyitgZqw4rkMCpmuPP+oURq7WdfToI=; b=PtXRn+nftclVHqBZCX8sP7uPA0Qh21IuZU1JWAeMg1mLNGxEClDIl8fHUG9gD523pheZ7I K3Goi3qBK53P5g4DRreNBF+lfTwO4qriuOFTV7IN5fF/1pdwzAEvU7lCLYwifDAcMXwyEs 2vfkGTwW5GEzxnt5eEOnmPQJ3b3YBac= Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-6c53a315c6eso3349327a12.3 for ; Mon, 17 Jun 2024 15:18:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718662709; x=1719267509; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=WgpPhgSpGnuAzgyitgZqw4rkMCpmuPP+oURq7WdfToI=; b=nQH+hS9H99dn9Oavf78tJ3UIqw5k7kx1zMW/zZL55MVhH2SrqZXY99r/XLHx7nuc5R YML/vQ52nZa/KzCzINIWn5PekVIE0SVN17yt1+nNSjYWHD3Xb9Bp+Wbx0DWuMioGx33H JCMfbpgxbjFBfoPncs3vW4jvsay0OScoQ5e2hZ7bIJ5As8subaADvUrK5FPp3p0GiMaD XMALc+MdrG8OmB6/SvghP/FAhYeCKWW6BNHJuCDrhAI4kMTnhe/gm4xwc+lssk+n1A3l KUXiK/WCMErsPUJpKxOWkFo49V3Go8h3zd5q5hKOwOrMsYl86baaRIff5MhdqqL8gn3x Ww3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718662709; x=1719267509; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WgpPhgSpGnuAzgyitgZqw4rkMCpmuPP+oURq7WdfToI=; b=Uvytw5ulh68oSohMToYv0CNe2DqYouRTvi3W6jjNXo6bsWVbeIjxB/W4XVczboWfNl BdsbTPlB0YTvDfUeTBrQwqZ3EyoXwrBCWqF3UYj3kFbkWVax/iWAzH+tRp2xyI84zdGS m4p6X04Gq/ROpVjrhRd751t8F3Q6dSp7cSN9NM3Mwo11se9I0AuKPSEHTaAJpA2yjs7H yfmsoCQqwUIQTOnqaLBnVi4xvW1pCiksPTbDc1MlJ+iG6EoZhypWSCzpomU9vU2J3hjv ZxDGnttsuHLEdEfYNbK30RgCyiezV4y7hor+/WvMhJTHuFng9I+pvrk1LjxejYj7xZmK PndA== X-Forwarded-Encrypted: i=1; AJvYcCVFlHZZ3gHYSVJNfWIlMSrzn8aNKe1Ywnm7NXFUXeCv3Q+eCtXP+7r5vQhZfHjUBdxVDN2oBJNltKAogEi8rdvMvO0= X-Gm-Message-State: AOJu0Yzij6lc5/USfP0gU8V7T5t3FAD51UAB0ZYr4CpFk51gXD7RvFNT tW896fOS/GohbN48xqRW0nV8hj2dAyjzcQwncMg4FXNnI/RbSKIK X-Google-Smtp-Source: AGHT+IFXZ4im6gENWa2acZ8xmU8vtV5qgUZB3zXzpkFv4olxojNSGSoqXbVj1YMNI4OecFpSuz2idg== X-Received: by 2002:a17:903:2348:b0:1f8:67e4:3977 with SMTP id d9443c01a7336-1f867e453b5mr102032975ad.34.1718662709286; Mon, 17 Jun 2024 15:18:29 -0700 (PDT) Received: from localhost.localdomain ([2407:7000:8942:5500:aaa1:59ff:fe57:eb97]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f855ee6e7esm83944365ad.139.2024.06.17.15.18.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 15:18:28 -0700 (PDT) From: Barry Song <21cnbao@gmail.com> To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org Cc: linux-cifs@vger.kernel.org, sfrench@samba.org, Barry Song , Christoph Hellwig , NeilBrown , Anna Schumaker , Trond Myklebust , Chuanhua Han , Ryan Roberts , Chris Li , "Huang, Ying" , Jeff Layton , stable@vger.kernel.org Subject: [PATCH] cifs: fix the incorrect assertion in cifs_swap_rw() Date: Tue, 18 Jun 2024 10:18:13 +1200 Message-Id: <20240617221813.58244-1-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 7D3B220014 X-Stat-Signature: c4weqx4s1abpg3aphqna9omtxfma8f9c X-Rspam-User: X-HE-Tag: 1718662710-826454 X-HE-Meta: U2FsdGVkX1+aFICRnJVc009qV1At7Tq+3bFnlXw18a2BNY6cUIgiKt7/tpmXnIptog8szpnzROssnhS74azDzo63C0qyt9TaTFDAybCe5/LMbja6KW8v3eBEffIFTQ7tA46QQ8n7ZmG3mMfX5JVaPauUrpHXO4mcScM77C+RBnMgec18aH9L7HtPSr4TlI+9HcbstQ1uaeI4lrj1VRzk5e9E2Ns6sJE7XH5q7pXsg9FGdhdGpwJ2ADktNDvR2zh9xmQR8z67oyQx7azfpk5d/T3cc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zcOBm79dzv47K/stpC41CmqOmpw2Gg2j7nHrXCvAmnRN4t34xHvn5qvuKBCUQfmrl7M0KtsneJ8ycWINQBbm4/yg/QKcygha8MxOQxtdUbVsCMsRfk8yP2A3hZ3rslayBQ43Bj1Jveh2cYMQNl5FT04rV63WNNVjBYLdgsPJKjbmAJ2a13dSX7IuC7DphagZbwoJ6KipnC+JBA+CXG/yEEEl9uJHmjfMyh/fBDxxMTBM13Cn/Zk3W5XzJ42dhHlgoIrEqeLW+sU8PIf6Nu2SF+ccaUIkcsIAK0JYG8/98D9wHMouHEw5pHQkUAbC2a61/g7jeIlJcA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Barry Song Since commit 2282679fb20b ("mm: submit multipage write for SWP_FS_OPS swap-space"), we can plug multiple pages then unplug them all together. That means iov_iter_count(iter) could be way bigger than PAGE_SIZE, it actually equals the size of iov_iter_npages(iter, INT_MAX). Note this issue has nothing to do with large folios as we don't support THP_SWPOUT to non-block devices. Fixes: 2282679fb20b ("mm: submit multipage write for SWP_FS_OPS swap-space") Reported-by: Christoph Hellwig Closes: https://lore.kernel.org/linux-mm/20240614100329.1203579-1-hch@lst.de/ Cc: NeilBrown Cc: Anna Schumaker Cc: Steve French Cc: Trond Myklebust Cc: Chuanhua Han Cc: Ryan Roberts Cc: Chris Li Cc: "Huang, Ying" Cc: Jeff Layton Cc: Signed-off-by: Barry Song --- fs/smb/client/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index 9d5c2440abfc..2f11f138c57d 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -3200,7 +3200,7 @@ static int cifs_swap_rw(struct kiocb *iocb, struct iov_iter *iter) { ssize_t ret; - WARN_ON_ONCE(iov_iter_count(iter) != PAGE_SIZE); + WARN_ON_ONCE(iov_iter_count(iter) != iov_iter_npages(iter, INT_MAX) * PAGE_SIZE); if (iov_iter_rw(iter) == READ) ret = netfs_unbuffered_read_iter_locked(iocb, iter);