Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp285120rbe; Wed, 28 Feb 2024 22:10:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU3AXMoydthAIYLbb+GIA3BMN8BPU33o1KyLXdkEM0BmU8ST6QKXb4WGe0SXOq/ynmfrQMsDr8okpKwEsXF46zTPye31ne1EJ160/VBIA== X-Google-Smtp-Source: AGHT+IG5/h3ULzDyLY8WQWDuPjjAEJxVUkVA4Z0L/DavY3xND1TDJhblp0HzP9SbTCgtdjd1Ao/0 X-Received: by 2002:a9d:4d89:0:b0:6e4:7968:9b8d with SMTP id u9-20020a9d4d89000000b006e479689b8dmr1007449otk.36.1709187031252; Wed, 28 Feb 2024 22:10:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709187031; cv=pass; d=google.com; s=arc-20160816; b=CDWnK5BAUWU9LKcFmqFXLOQTh3mIdVDB2NHH+XoczAuChgy82699Ve9q9DpfvtKJOc qMPClNVdB/Yr/nyOwNimP/RgAM9a4L1HuoQ/lNsAInTfwKSkQnJqRHAv+PmWtW231SVu IVrjU6oXHHBZvv8hQMHvO69pGCFaWpbqQFpySd6k2cz20UlMXhnLYRbzsbqwTyK/lmJT vNJ+ou3FSxujPAVgGzTFhBo2h1WbzhdW7fKqLD5/W3qNLVldWR3sq2cvn25ghsTcC6A3 HxlyVccNJgCVp5t9zYlgRPCUoS6ZPxA8jxH/LXff7BJlSpa48PkmL+OsxBGLkFZ8pVBi DI5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Q5P8oG1c/7DSESFr6JtoQmKhazwi5rpIXaMqKZ57x4o=; fh=ckMwSCpmkdxydHxZzbx5FVVl6AjeS2z7qZi7l/V4yE4=; b=vavAnEt7ADs6wq76CzWAw8BeDLC8lafB/ewujQa41tZ5l0JeUrb8LrItdmeWA1Gd30 wkbK65YL5N+c1LrkM9dWB3I5bdQ9UyyswSFo7uuuMnHUKFn4ZytLTAsKjM8Yisd7SpIb V0j2A6qcIBHx23Lq2mEf/fwaflwjIEMYK5jPPgb73yshIvfy//3/IpBQnniZz/jkHFdG Nty5xIhqBI12nwSPKqETKTM+2tAymuPsqAzZTxHmhWwMROLvjv1Owj08C2/T5n4O0DxV b6BaX4KIEK2SW3ZSPZgD4GB7fvGWCsxIh3Yzris9Y+WrZvwmJMJpliRPlwsine3swtJV ZGnw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gLpM2LI2; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-ext4+bounces-1422-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1422-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 22-20020a631356000000b005dc504e597csi701624pgt.513.2024.02.28.22.10.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 22:10:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1422-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gLpM2LI2; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-ext4+bounces-1422-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1422-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 61F73289C1A for ; Thu, 29 Feb 2024 06:10:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E5293BBFD; Thu, 29 Feb 2024 06:10:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gLpM2LI2" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 5E0363BBF4 for ; Thu, 29 Feb 2024 06:10:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709187024; cv=none; b=DtpaTp109s8bX2qVZkrkb2MCnqa29TojEurx+5qx8ENGz9rS/zRNY/6s5E0tpcylPkvhy8fyL1/dckrcOPkmGyYW1GNn3P6jFVYwWgk3EwJ6LCWokb8WF2S8xPTdwNYykm8bIVlOqh+9Ucgg/k6hLzxKorFne6Q76Uat6w0/Fkc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709187024; c=relaxed/simple; bh=5mtKV3lq32PRHhvk5ozP22Uq/yyEIZ/zp9p0r0Gxp58=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=awcWEM6vAvXMtK82cHtN8OjynntkZKAsPlco3GIGnjGOybM0dGvhvjBWtOIDCVfMXkWep0h7IadBFEjATOsNQuh5+ZKvzOFcRgs0dXPXr8uIKhtjLprt1TTDPS3COFpxi8ZbDi96wf5yatUPPQvgXufI0S4xEfaeyReKVIwpm/I= 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=gLpM2LI2; arc=none smtp.client-ip=209.85.210.176 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 Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6e55afcf513so306623b3a.1 for ; Wed, 28 Feb 2024 22:10:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709187021; x=1709791821; 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=Q5P8oG1c/7DSESFr6JtoQmKhazwi5rpIXaMqKZ57x4o=; b=gLpM2LI249tXMRigMw2S5H52XsInSDWOgB5G5znFuVaMCcQLNCGwSspYCHxJau9xZL FP+DDJIJHiw+aLlShaym3inFLUsRhZad/hv1ZZja3cQNJ0AX8TgK9raVGPjC/2BJRwVM XPXI/u8WYwzb0WZlAWEBIhoUcswW6YIivHJUa7d67CPAAbQ5SUzRJmzqB5yLq3J+yIAv F2QhgczIlzflT2BSKB/gS3UaH28vS8ulXVwcxG27twrcGWcUR84CoW2dHpvZS73LKMNM 51n4a2Wpli0/fWgSmspYmvMgRgF+33SLBY6ePEqKWgFL38x5+PghvEwpSSuDQzWOWkpc 1HHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709187021; x=1709791821; 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=Q5P8oG1c/7DSESFr6JtoQmKhazwi5rpIXaMqKZ57x4o=; b=qEbA5Hg92oTnfRPoZc8Fdlfcreb+ZM32YElxFSE2zVRGnQe4wpO0psVZ1hOZZRRFqF GWm1GZ6XjrWF4XLS1jJpk6PsJifevKe3hJCA4hJrOzb46W2avF3IL+tXEqIiIRyco8uE FTbaLr9UZJKpnNR9kMZb28bg1V/C05CxKeZxYfxYmwGpzH8cbX9FqbN8TFxWYN5wP9f3 teN0ggBrqiEPCQzgc3pS+VQX9WLhXtXRXpD+LHQtfwwT7rVYQOgjQ+J2fkRoYkMeWWV4 jh1n05WrA6BwJYyVZQvrPAVs/IYA8UXche+DkGbdkHT/6Y4P6MtMFRCo3L1ktgMb1eKz qkKw== X-Gm-Message-State: AOJu0YzQuceMa7+j/rkcu+P5F+z85cD/Bc+6c2c7/o+ANKaLpcn3mxgn i9oUhsrrkhVJ5xS694y6sZYKuLmDoCet6q1oz6qKEzL+j5fGtLFE58KF07MlzEc= X-Received: by 2002:a05:6a00:4fc5:b0:6e4:d3b1:76ca with SMTP id le5-20020a056a004fc500b006e4d3b176camr1451309pfb.16.1709187021483; Wed, 28 Feb 2024 22:10:21 -0800 (PST) Received: from dw-tp.. ([49.205.218.89]) by smtp.gmail.com with ESMTPSA id c25-20020a62e819000000b006e506ff670fsm448996pfi.147.2024.02.28.22.10.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 22:10:20 -0800 (PST) From: "Ritesh Harjani (IBM)" To: linux-ext4@vger.kernel.org Cc: Jan Kara , "Ritesh Harjani (IBM)" , stable@kernel.org Subject: [PATCH 1/2] ext4: Fixes len calculation in mpage_journal_page_buffers Date: Thu, 29 Feb 2024 11:40:13 +0530 Message-ID: X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Truncate operation can race with writeback, in which inode->i_size can get truncated and therefore size - folio_pos() can be negative. This fixes the len calculation. However this path doesn't get easily triggered even with data journaling. Cc: # v6.5 Fixes: 80be8c5cc925 ("Fixes: ext4: Make mpage_journal_page_buffers use folio") Signed-off-by: Ritesh Harjani (IBM) --- fs/ext4/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 537803250ca9..bab9223d94ac 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2334,7 +2334,7 @@ static int mpage_journal_page_buffers(handle_t *handle, if (folio_pos(folio) + len > size && !ext4_verity_in_progress(inode)) - len = size - folio_pos(folio); + len = size & (len - 1); return ext4_journal_folio_buffers(handle, folio, len); } -- 2.39.2