From patchwork Fri Oct 14 08:48:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hrutvik Kanabar X-Patchwork-Id: 2592 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp71748wrs; Fri, 14 Oct 2022 01:52:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7GidPUEH4dIy5NgwcU04lIzu7wW7LeZ0LvMXW0MXwxwko1WNpUQZ2exflVhyqI6xMAv0BR X-Received: by 2002:a17:902:d2c4:b0:178:32c4:6648 with SMTP id n4-20020a170902d2c400b0017832c46648mr4173315plc.88.1665737563808; Fri, 14 Oct 2022 01:52:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665737563; cv=none; d=google.com; s=arc-20160816; b=iZWLYgtzC/PSiG/wsYvCzTTeF52NG3Xxd4X0Tc85Ij0ZoSJrrrZM0ofjMyI19LQA3L pEBUgSt3DQ7O1eeHi1h7GNkVxy0lvaLlqDQstrrnZB9XlVkGGmwAnmwTMpn+o3wOqTEP 3o41tNpd9yZKx0tjndYVyrqnt0bgNHT6I3Gh6tCLzwbVGU46DWoPZmkKQzQq4kJLVttt rXAoXrizoYoU9Z/3VGDpBGFtg0BSV99XJUYfRQCm67ZlrnD6Ol/OLy69O6qFhYkTjqFz bFBSwAqwWQiV250Gcd6eechnQzm2kCvpxGovVLNIrzOxrZAHMbmVmkXpLALJRuZpHeGE YxQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=e7OO4yxaPUsVNNTpu1wi+buwSaoss8IhgddIo1BpRyE=; b=pn+jrLJy2o3pQ7O6YBmWalCfKAe+FjUFAXJd+htX0kL1Q3Euex+UYr0Yev0vmQOTeU 7tJ+ygvzL/fBVKDMPKxEhWitWzrtYLiKySExt6p98fUqpFJsd1sunNu0bO5YD4VjhGe2 KKVVO6IiMyNomUYzi6wCzwEkw/ET2uc4npYP3nvjQUAMZlJhp124bEzAgYF/6TOVLcu3 lNvQt3PSVzODAw2XDzELXrN9GyrfkBOFd8dkuZma/VxXBs00e38IMC2ky5aGBnYnrgzM qO9F766FbWRYAwwAajgAUPSS0Myt/9Vyk+JqgKctO/amKTAzUVFYhoS22iZj1BtAHlDK HY7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oC6tSxas; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w15-20020a17090a8a0f00b0020d459bef63si7619499pjn.55.2022.10.14.01.52.30; Fri, 14 Oct 2022 01:52:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oC6tSxas; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229709AbiJNIty (ORCPT + 99 others); Fri, 14 Oct 2022 04:49:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229843AbiJNItt (ORCPT ); Fri, 14 Oct 2022 04:49:49 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ED7A14D0D; Fri, 14 Oct 2022 01:49:47 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id r8-20020a1c4408000000b003c47d5fd475so4907154wma.3; Fri, 14 Oct 2022 01:49:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e7OO4yxaPUsVNNTpu1wi+buwSaoss8IhgddIo1BpRyE=; b=oC6tSxasgYZK7HLegRBPiSvjZcFyUQ6VxaiXUsn9DOOqsgYUd3GwVU3xpX+MEuUcs6 5Zyo5II4xi0HIqzm0H97V7F94fYQdDLt8AuD+JZzU47QQ/LuGMQdYOOGSKw2dxumvRKB h7m582fFWyx3oprKN1q8FSc+To8Y6JDmPTRnd4hkSq/AbbkLHlkBJXB8Q+TOCpRRhl2y d/+ZTjaaMTxKRAiVLHhe3QjKwq7Ra5hv6vxdw+Sr9ECBJR0PxYgvhE2OVPZwv9ed7dwQ BaLglkid8PnXT/nXhWq1sEkYBW8NVoxmsiJn/yjvdRctbBZZqCVrgn4QIC2aa5IUvmbp Ws2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e7OO4yxaPUsVNNTpu1wi+buwSaoss8IhgddIo1BpRyE=; b=XL74i7SrnEafyygwqndPmYzgZsyz5xv8aRX3nShDUB8UZzMW102kvWTgMzksiJ0QBj a9QTCq2slBog93m1ZY8taiHPlODB7uUphx0qWTqPlXqP528EcFi20QRVXxW/80uidg1D KcM0JTqHJulo/eO1XuF4+aUQmVczEBq892sKD30mWC3aYDGWmsQUMr+hQB+cFy20vqMW cCUhyZpECT2D3EwyzoQ3OV+IT414hcKurS/1sI0x3bzYAZSn9Al5cMNSIDSYBZDF2S+w Bc6eLy8VsZykfn4JOEIyb7iExzqUl6vagSCzFi3zIjU9h0a4iVsV6Hr9gO8e2wRYkvuW E6VQ== X-Gm-Message-State: ACrzQf1OSgvpomURKArEPa1ZinvZdmslNjbAINvcHXGu/IFFF0EjbNLj 4EraoY7iB02sUePlInCrM40= X-Received: by 2002:a05:600c:5388:b0:3c5:4c1:a1f6 with SMTP id hg8-20020a05600c538800b003c504c1a1f6mr2698975wmb.11.1665737385463; Fri, 14 Oct 2022 01:49:45 -0700 (PDT) Received: from hrutvik.c.googlers.com.com (120.142.205.35.bc.googleusercontent.com. [35.205.142.120]) by smtp.gmail.com with ESMTPSA id 123-20020a1c1981000000b003c6c4639ac6sm1547372wmz.34.2022.10.14.01.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 01:49:45 -0700 (PDT) From: Hrutvik Kanabar To: Hrutvik Kanabar Cc: Marco Elver , Aleksandr Nogikh , kasan-dev@googlegroups.com, Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Theodore Ts'o , Andreas Dilger , linux-ext4@vger.kernel.org, Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Namjae Jeon , Sungjong Seo , Anton Altaparmakov , linux-ntfs-dev@lists.sourceforge.net Subject: [PATCH RFC 1/7] fs: create `DISABLE_FS_CSUM_VERIFICATION` config option Date: Fri, 14 Oct 2022 08:48:31 +0000 Message-Id: <20221014084837.1787196-2-hrkanabar@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221014084837.1787196-1-hrkanabar@gmail.com> References: <20221014084837.1787196-1-hrkanabar@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746652431611043137?= X-GMAIL-MSGID: =?utf-8?q?1746652431611043137?= From: Hrutvik Kanabar When implemented and enabled, this should circumvent all redundant checksum verification in filesystem code. However, setting of checksums is not affected. The aim is to aid fuzzing efforts which randomly mutate disk images and so invalidate checksums. Checksum verification often rejects these mutated disk images, hindering fuzzer coverage of deep code paths. By disabling checksum verification, all mutated images are considered valid and so exploration of interesting code paths can continue. This option requires the `DEBUG_KERNEL` option, and is not intended to be used on production systems. Signed-off-by: Hrutvik Kanabar --- fs/Kconfig.debug | 20 ++++++++++++++++++++ lib/Kconfig.debug | 6 ++++++ 2 files changed, 26 insertions(+) create mode 100644 fs/Kconfig.debug diff --git a/fs/Kconfig.debug b/fs/Kconfig.debug new file mode 100644 index 000000000000..bc1018e3d580 --- /dev/null +++ b/fs/Kconfig.debug @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config DISABLE_FS_CSUM_VERIFICATION + bool "Disable redundant checksum verification for filesystems" + depends on DEBUG_KERNEL + help + Disable filesystem checksum verification for checksums which can be + trivially recomputed from the on-disk data (i.e. no encryption). + Note that this does not affect setting of checksums. + + This option is useful for filesystem testing. For example, fuzzing + with randomly mutated disk images can uncover bugs exploitable by + specially-crafted disks. Redundant checksums are orthogonal to these + exploits, as they can be recomputed for crafted disks. However, for + testing it is more reliable to disable checksums within the kernel + than to maintain image generators which faithfully reimplement + per-filesystem checksum recomputation. + + Say N if you are unsure. Disable this for production systems! + diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 73178b0e43a4..4689ae527993 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -979,6 +979,12 @@ source "lib/Kconfig.kmsan" endmenu # "Memory Debugging" +menu "Filesystem Debugging" + +source "fs/Kconfig.debug" + +endmenu # "Filesystem Debugging" + config DEBUG_SHIRQ bool "Debug shared IRQ handlers" depends on DEBUG_KERNEL From patchwork Fri Oct 14 08:48:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hrutvik Kanabar X-Patchwork-Id: 2588 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp71330wrs; Fri, 14 Oct 2022 01:51:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM67knyURQe3N3QJcFugIE8G+Vdq1IfXFSuGHMmh9owzWQHeraR55vtwaHzmP/DSJ/09HaGx X-Received: by 2002:a17:907:b11:b0:78d:e71a:6e6 with SMTP id h17-20020a1709070b1100b0078de71a06e6mr2921242ejl.14.1665737489187; Fri, 14 Oct 2022 01:51:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665737489; cv=none; d=google.com; s=arc-20160816; b=hTBCqaOhrp9MWlSxUkUiBkZxkHOX1n80Gp8G8UA/xDGkGr/HWXuPyiOHE9hHBWPC/p T1OWhOeoneivpoDGk+w2i9HkyDZkaIPIgFWb80eGnGCNpHUqFiw3WiZvmyd6qlidl9zk JaSy0qyYh/mgo5O3scNhAFHwJv883KjvKWjYv+JOTvP1GfdovB0Nt7gUWDe0o6krDbBb uQeDM1t1gonfaa5ZFrL1Dof4My/K/grd1+eQT7eD7mzg2ijgozO3wpD+JFTEFARtwCE0 T+sZcNNKXmA7+Ha8GdcUHsOqdu1kpIfXOJdPiddL7aJ31/Fn5fGHl2d+UywAtnGQGI4g 5BkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=s+9yJ7ltRwZDViylHimzxt5trfp3/YyMYP1DALt6daQ=; b=w/ahTv4W7iTSFWqkRawDNjj97RJB48A/+9R99UeavUZi4B52PY02kl+Z9i3wucCNEt QoWOu378mEBpSpNPM0UjyIkSQLiuXyqR/QzXRyPdX2Z8c1UYay2oGuiDn41KGi6wSLp+ /jzsIQY7z3XOfoz2ANLpKQJF1ZMDwNN0eSmmeAn/GlkvT0sYNURQ8JZPx6xlSK3/RasA vL3f/ETz2criRplqv4xpeWAqmrL4rLaR2GaOWru2R0VEAqupC+GfdJTqUWNle1HxSkJu yj6I84fTZtrTr/MV5XVofwjT37gbLdYJMl1DcbBQLgMxf/6761sUlmWsmPVjhpSsn/Vo 0xWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=p63rFDk+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp14-20020a170906c14e00b0078d5d4a6b64si1645482ejc.662.2022.10.14.01.51.02; Fri, 14 Oct 2022 01:51:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=p63rFDk+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229965AbiJNIuC (ORCPT + 99 others); Fri, 14 Oct 2022 04:50:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbiJNItv (ORCPT ); Fri, 14 Oct 2022 04:49:51 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5BBB1F2C0; Fri, 14 Oct 2022 01:49:48 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id iv17so2671139wmb.4; Fri, 14 Oct 2022 01:49:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s+9yJ7ltRwZDViylHimzxt5trfp3/YyMYP1DALt6daQ=; b=p63rFDk+7fHDtSHqdHbh5UTErR2KUpqMpgr3HkVCyL03aJpfelAlYk+zA1kvLcUK4x oCy0NMYDZh+H50rQcR49ml2HNBTBYxQHuyUYk2CSX54YfuXf3DWjLKdUiCPT4+EiIFSi nHSQMC7c9mLxjAkq4yLJ0/P9F8eN2RlUOEqc8NA2In2jz47ELklEdKHjSYs0ZELx4ixz 5/vUWh5rIIInW9un9b84c/P8CPLnarDABeMuwBY6OaHUr8e6bA2Wo85vskn9BuK/Ho1v LOW3LE2S8qlC9e+TcP7T6auaCAsi9PDl3bTPIkBQTVkixT16squswDJ53Vty9EoVnl7l vcFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s+9yJ7ltRwZDViylHimzxt5trfp3/YyMYP1DALt6daQ=; b=dXlIpapOdYfjq/cBfLsuHJNo0YtoojAqAHaM8sZaFbBBpGE6fC/i1u6otIjy7pOMp6 12DmG0CFo9sNnf3Z5DgKsIxJULptICGxF+znGgLgJ5RRbjjUAKPnr5lKhQ2i9NUAKrX/ vG74OJzbBR90I+8gulLItCgA0rNqgyg1h9y0EUyUCwEjSG2UgZEmXOMyhP/u+Znxk9jq MLnawy9GSpFSgGpAyEVzyRpKQ/Gk1ti3snkvIfcz27N9BscF2JV7ruFNLKZFehK91/4o jMPcfDjcLv3bygeaso5GZ4eMJjSK9A8rtfGq5fm9i9n+UuLewccgKYHVSIb7u8S607OA 56Fg== X-Gm-Message-State: ACrzQf2KGSiKC5tL4dixY4AWg1RATtkrFmQPvpJqycM0ZJi1nGk7MTCl i38f2oa1MZay2MJcjJFNu38= X-Received: by 2002:a05:600c:19ce:b0:3b9:c36f:f9e2 with SMTP id u14-20020a05600c19ce00b003b9c36ff9e2mr2761365wmq.110.1665737387337; Fri, 14 Oct 2022 01:49:47 -0700 (PDT) Received: from hrutvik.c.googlers.com.com (120.142.205.35.bc.googleusercontent.com. [35.205.142.120]) by smtp.gmail.com with ESMTPSA id 123-20020a1c1981000000b003c6c4639ac6sm1547372wmz.34.2022.10.14.01.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 01:49:47 -0700 (PDT) From: Hrutvik Kanabar To: Hrutvik Kanabar Cc: Marco Elver , Aleksandr Nogikh , kasan-dev@googlegroups.com, Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Theodore Ts'o , Andreas Dilger , linux-ext4@vger.kernel.org, Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Namjae Jeon , Sungjong Seo , Anton Altaparmakov , linux-ntfs-dev@lists.sourceforge.net Subject: [PATCH RFC 2/7] fs/ext4: support `DISABLE_FS_CSUM_VERIFICATION` config option Date: Fri, 14 Oct 2022 08:48:32 +0000 Message-Id: <20221014084837.1787196-3-hrkanabar@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221014084837.1787196-1-hrkanabar@gmail.com> References: <20221014084837.1787196-1-hrkanabar@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746652353682471229?= X-GMAIL-MSGID: =?utf-8?q?1746652353682471229?= From: Hrutvik Kanabar When `DISABLE_FS_CSUM_VERIFICATION` is enabled, bypass checks in key checksum verification functions. Signed-off-by: Hrutvik Kanabar --- fs/ext4/bitmap.c | 6 ++++-- fs/ext4/extents.c | 3 ++- fs/ext4/inode.c | 3 ++- fs/ext4/ioctl.c | 3 ++- fs/ext4/mmp.c | 3 ++- fs/ext4/namei.c | 6 ++++-- fs/ext4/orphan.c | 3 ++- fs/ext4/super.c | 6 ++++-- fs/ext4/xattr.c | 3 ++- 9 files changed, 24 insertions(+), 12 deletions(-) diff --git a/fs/ext4/bitmap.c b/fs/ext4/bitmap.c index f63e028c638c..04ce8e4149ee 100644 --- a/fs/ext4/bitmap.c +++ b/fs/ext4/bitmap.c @@ -24,7 +24,8 @@ int ext4_inode_bitmap_csum_verify(struct super_block *sb, ext4_group_t group, __u32 provided, calculated; struct ext4_sb_info *sbi = EXT4_SB(sb); - if (!ext4_has_metadata_csum(sb)) + if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) || + !ext4_has_metadata_csum(sb)) return 1; provided = le16_to_cpu(gdp->bg_inode_bitmap_csum_lo); @@ -63,7 +64,8 @@ int ext4_block_bitmap_csum_verify(struct super_block *sb, ext4_group_t group, struct ext4_sb_info *sbi = EXT4_SB(sb); int sz = EXT4_CLUSTERS_PER_GROUP(sb) / 8; - if (!ext4_has_metadata_csum(sb)) + if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) || + !ext4_has_metadata_csum(sb)) return 1; provided = le16_to_cpu(gdp->bg_block_bitmap_csum_lo); diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index f1956288307f..c1b7c8f4862c 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -63,7 +63,8 @@ static int ext4_extent_block_csum_verify(struct inode *inode, { struct ext4_extent_tail *et; - if (!ext4_has_metadata_csum(inode->i_sb)) + if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) || + !ext4_has_metadata_csum(inode->i_sb)) return 1; et = find_ext4_extent_tail(eh); diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 2b5ef1b64249..8ec8214f1423 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -86,7 +86,8 @@ static int ext4_inode_csum_verify(struct inode *inode, struct ext4_inode *raw, { __u32 provided, calculated; - if (EXT4_SB(inode->i_sb)->s_es->s_creator_os != + if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) || + EXT4_SB(inode->i_sb)->s_es->s_creator_os != cpu_to_le32(EXT4_OS_LINUX) || !ext4_has_metadata_csum(inode->i_sb)) return 1; diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 4d49c5cfb690..bae33cd83d05 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -142,7 +142,8 @@ static int ext4_update_backup_sb(struct super_block *sb, es = (struct ext4_super_block *) (bh->b_data + offset); lock_buffer(bh); - if (ext4_has_metadata_csum(sb) && + if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) && + ext4_has_metadata_csum(sb) && es->s_checksum != ext4_superblock_csum(sb, es)) { ext4_msg(sb, KERN_ERR, "Invalid checksum for backup " "superblock %llu\n", sb_block); diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c index 9af68a7ecdcf..605f1867958d 100644 --- a/fs/ext4/mmp.c +++ b/fs/ext4/mmp.c @@ -21,7 +21,8 @@ static __le32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp) static int ext4_mmp_csum_verify(struct super_block *sb, struct mmp_struct *mmp) { - if (!ext4_has_metadata_csum(sb)) + if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) || + !ext4_has_metadata_csum(sb)) return 1; return mmp->mmp_checksum == ext4_mmp_csum(sb, mmp); diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index d5daaf41e1fc..84a59052c51d 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -396,7 +396,8 @@ int ext4_dirblock_csum_verify(struct inode *inode, struct buffer_head *bh) { struct ext4_dir_entry_tail *t; - if (!ext4_has_metadata_csum(inode->i_sb)) + if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) || + !ext4_has_metadata_csum(inode->i_sb)) return 1; t = get_dirent_tail(inode, bh); @@ -491,7 +492,8 @@ static int ext4_dx_csum_verify(struct inode *inode, struct dx_tail *t; int count_offset, limit, count; - if (!ext4_has_metadata_csum(inode->i_sb)) + if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) || + !ext4_has_metadata_csum(inode->i_sb)) return 1; c = get_dx_countlimit(inode, dirent, &count_offset); diff --git a/fs/ext4/orphan.c b/fs/ext4/orphan.c index 69a9cf9137a6..8a488d5521cb 100644 --- a/fs/ext4/orphan.c +++ b/fs/ext4/orphan.c @@ -537,7 +537,8 @@ static int ext4_orphan_file_block_csum_verify(struct super_block *sb, struct ext4_orphan_block_tail *ot; __le64 dsk_block_nr = cpu_to_le64(bh->b_blocknr); - if (!ext4_has_metadata_csum(sb)) + if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) || + !ext4_has_metadata_csum(sb)) return 1; ot = ext4_orphan_block_tail(sb, bh); diff --git a/fs/ext4/super.c b/fs/ext4/super.c index d733db8a0b02..cb6e53163441 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -287,7 +287,8 @@ __le32 ext4_superblock_csum(struct super_block *sb, static int ext4_superblock_csum_verify(struct super_block *sb, struct ext4_super_block *es) { - if (!ext4_has_metadata_csum(sb)) + if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) || + !ext4_has_metadata_csum(sb)) return 1; return es->s_checksum == ext4_superblock_csum(sb, es); @@ -3198,7 +3199,8 @@ static __le16 ext4_group_desc_csum(struct super_block *sb, __u32 block_group, int ext4_group_desc_csum_verify(struct super_block *sb, __u32 block_group, struct ext4_group_desc *gdp) { - if (ext4_has_group_desc_csum(sb) && + if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) && + ext4_has_group_desc_csum(sb) && (gdp->bg_checksum != ext4_group_desc_csum(sb, block_group, gdp))) return 0; diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 36d6ba7190b6..b22a0f282474 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -154,7 +154,8 @@ static int ext4_xattr_block_csum_verify(struct inode *inode, struct ext4_xattr_header *hdr = BHDR(bh); int ret = 1; - if (ext4_has_metadata_csum(inode->i_sb)) { + if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) && + ext4_has_metadata_csum(inode->i_sb)) { lock_buffer(bh); ret = (hdr->h_checksum == ext4_xattr_block_csum(inode, bh->b_blocknr, hdr)); From patchwork Fri Oct 14 08:48:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hrutvik Kanabar X-Patchwork-Id: 2590 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp71487wrs; Fri, 14 Oct 2022 01:51:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6iobOwf663yG0dYt0/ON4RV8DwaRktjAfBrFksQoyQnfrcDzAY7xHcudYPM4EpsTJzHB4w X-Received: by 2002:a05:6402:5202:b0:45c:9525:9bc4 with SMTP id s2-20020a056402520200b0045c95259bc4mr3477039edd.380.1665737517169; Fri, 14 Oct 2022 01:51:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665737517; cv=none; d=google.com; s=arc-20160816; b=LATcUoKpZ4WvKIWlrwurlpSICIvrn4hX4XYD+LePwte4afQxhNY+x8fgqGHCicPYzY DTi4+SI0DTeivqW4p/wN9VIN7rfHwiHDBSxJYLgbckmkfnqlx+8glzVFf4/IkNWAtzFH LG+NzTyBOz2INb+wWdsFGB5zovvd/07L2Q9bJRg6n1x/olAnPQuyygjk2O+MDhqQeOrD DPyizG4ZXWH/riEy63BJ8YRLwfdyu340twtQJEAR2sIJ7JswW+OPC8EbxU+PUAHgPghg XgbNOQlkYJ+aQaBxUdeQH7Z8KydEf1Pd3FaCDMqkgAPu6z6Oi8sKjhDxPcwdSzppWbvo nVrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=noZwzVYPpBsDl5CECnOrP5rsHRqU5K36GF5tioVqhvo=; b=CnUtPnvKvQyaieMLkK+pGUKmT9nvA8B0gzayQO5Nfd5jCCkTsZj+Y0LYKK0IcfrVLT 6opZEXBT7tJeytLja4f0k78mONToT1lj66WYVXoNSASupAPyTXGqsEMV8ZB/LO88o80V Z/5sYisL8ouX26kT26a/d0mzNndizrFu5KCd+l65YQ0NMzCB5kFPzxZpUxy/6BZp5cUl 1BwIcYfmXCrlcYd4HSmdpxSU5Cq01bBHHxhJhw+nUusgUvbi9LuTrS4sVnZnGer1z8Nf mDfVSNHn5KHSr1CRI3Jl1BDdR0EbcJfVhosBbmxV++bOp8hJtnk5YiMbaSk+zF00CRra Fm0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FQxuL83N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bx26-20020a170906a1da00b0078d45e9d485si1482052ejb.709.2022.10.14.01.51.30; Fri, 14 Oct 2022 01:51:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FQxuL83N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229991AbiJNIuJ (ORCPT + 99 others); Fri, 14 Oct 2022 04:50:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229887AbiJNItw (ORCPT ); Fri, 14 Oct 2022 04:49:52 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C8F521E36; Fri, 14 Oct 2022 01:49:50 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id r3-20020a05600c35c300b003b4b5f6c6bdso3069601wmq.2; Fri, 14 Oct 2022 01:49:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=noZwzVYPpBsDl5CECnOrP5rsHRqU5K36GF5tioVqhvo=; b=FQxuL83NlA1dTcPa+tFZaBKev/381N92shWjcokB6Cq01pDQV8v3dKmLzskweZmrg7 Jz6tAKO28qyNZhcKa1omEDpp9WjDAaZzKcErysdgfT7V0um+TyLLNk2Cij8EO/EsRY7j mM4PW1pXSuwF/LnXS5kzwEDyOA+AX2w5cE1DhAa9FuWqFFyXvj/NZ+KCCIthXLghAk0u a86+6OK4+3IB+C4bjSyDRdPIS9Ojxhjig1vaZtK+KEGWoBJunSCvCvMdY3KFEsTnmGGH vhkRbzjwDO4lnOX6LHYeQne4mhhiyroqBB3oVZA+u+phCefTTmPtrCeo3CV7uh6afgQ3 Zvrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=noZwzVYPpBsDl5CECnOrP5rsHRqU5K36GF5tioVqhvo=; b=NrYTcHyfyF2rCxRI0gZ9j8/v593JThtMk8Wb75cFABf3iEp2qMMRgHa6xnQhYpgBok 9B81ZfW1GsL4olM2FIbse3pKdtDJytbjmXrWQWSkpXxCUdV/5oXYRux4t4tFIFaJWfQU ek68m1cWTYDNEjPi+3HYab98s5UFxWdBU9vLrtcMRlpWc8MZOEaB+GX1G+U3x4in6w// vSPQuIR/eQ//NSgJ/BwuLspKmolFxYPEpt0nkIHlfx6XVbxKN7o6Mcm4abqZop4IoycZ NNS1lgWyUJG+MkNIzfSDAuuNtn6OFaoQaJ33fNSq1E28mkX1CU7EE2d4P3+N/TduJ8tj YkdA== X-Gm-Message-State: ACrzQf296Zl8SR5ElvHDEUevggqMsiFhOun/La7+sksb3MNAVR/y99oA K/0vyj5pbr6ta5Yo+f1kmwo= X-Received: by 2002:a05:600c:288:b0:3c6:c44a:1d30 with SMTP id 8-20020a05600c028800b003c6c44a1d30mr9545255wmk.46.1665737388927; Fri, 14 Oct 2022 01:49:48 -0700 (PDT) Received: from hrutvik.c.googlers.com.com (120.142.205.35.bc.googleusercontent.com. [35.205.142.120]) by smtp.gmail.com with ESMTPSA id 123-20020a1c1981000000b003c6c4639ac6sm1547372wmz.34.2022.10.14.01.49.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 01:49:48 -0700 (PDT) From: Hrutvik Kanabar To: Hrutvik Kanabar Cc: Marco Elver , Aleksandr Nogikh , kasan-dev@googlegroups.com, Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Theodore Ts'o , Andreas Dilger , linux-ext4@vger.kernel.org, Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Namjae Jeon , Sungjong Seo , Anton Altaparmakov , linux-ntfs-dev@lists.sourceforge.net Subject: [PATCH RFC 3/7] fs/btrfs: support `DISABLE_FS_CSUM_VERIFICATION` config option Date: Fri, 14 Oct 2022 08:48:33 +0000 Message-Id: <20221014084837.1787196-4-hrkanabar@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221014084837.1787196-1-hrkanabar@gmail.com> References: <20221014084837.1787196-1-hrkanabar@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746652383152264792?= X-GMAIL-MSGID: =?utf-8?q?1746652383152264792?= From: Hrutvik Kanabar When `DISABLE_FS_CSUM_VERIFICATION` is enabled, bypass checksum verification. Signed-off-by: Hrutvik Kanabar --- fs/btrfs/check-integrity.c | 3 ++- fs/btrfs/disk-io.c | 6 ++++-- fs/btrfs/free-space-cache.c | 3 ++- fs/btrfs/inode.c | 3 ++- fs/btrfs/scrub.c | 9 ++++++--- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index 98c6e5feab19..eab82593a325 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c @@ -1671,7 +1671,8 @@ static noinline_for_stack int btrfsic_test_for_metadata( crypto_shash_update(shash, data, sublen); } crypto_shash_final(shash, csum); - if (memcmp(csum, h->csum, fs_info->csum_size)) + if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) && + memcmp(csum, h->csum, fs_info->csum_size)) return 1; return 0; /* is metadata */ diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index a2da9313c694..7cd909d44b24 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -184,7 +184,8 @@ static int btrfs_check_super_csum(struct btrfs_fs_info *fs_info, crypto_shash_digest(shash, raw_disk_sb + BTRFS_CSUM_SIZE, BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE, result); - if (memcmp(disk_sb->csum, result, fs_info->csum_size)) + if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) && + memcmp(disk_sb->csum, result, fs_info->csum_size)) return 1; return 0; @@ -494,7 +495,8 @@ static int validate_extent_buffer(struct extent_buffer *eb) header_csum = page_address(eb->pages[0]) + get_eb_offset_in_page(eb, offsetof(struct btrfs_header, csum)); - if (memcmp(result, header_csum, csum_size) != 0) { + if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) && + memcmp(result, header_csum, csum_size) != 0) { btrfs_warn_rl(fs_info, "checksum verify failed on logical %llu mirror %u wanted " CSUM_FMT " found " CSUM_FMT " level %d", eb->start, eb->read_mirror, diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index f4023651dd68..203c8a9076a6 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -574,7 +574,8 @@ static int io_ctl_check_crc(struct btrfs_io_ctl *io_ctl, int index) io_ctl_map_page(io_ctl, 0); crc = btrfs_crc32c(crc, io_ctl->orig + offset, PAGE_SIZE - offset); btrfs_crc32c_final(crc, (u8 *)&crc); - if (val != crc) { + if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) && + val != crc) { btrfs_err_rl(io_ctl->fs_info, "csum mismatch on free space cache"); io_ctl_unmap_page(io_ctl); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index b0807c59e321..1a49d897b5c1 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3434,7 +3434,8 @@ int btrfs_check_sector_csum(struct btrfs_fs_info *fs_info, struct page *page, crypto_shash_digest(shash, kaddr, fs_info->sectorsize, csum); kunmap_local(kaddr); - if (memcmp(csum, csum_expected, fs_info->csum_size)) + if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) && + memcmp(csum, csum_expected, fs_info->csum_size)) return -EIO; return 0; } diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index f260c53829e5..a7607b492f47 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -1997,7 +1997,8 @@ static int scrub_checksum_data(struct scrub_block *sblock) crypto_shash_digest(shash, kaddr, fs_info->sectorsize, csum); - if (memcmp(csum, sector->csum, fs_info->csum_size)) + if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) && + memcmp(csum, sector->csum, fs_info->csum_size)) sblock->checksum_error = 1; return sblock->checksum_error; } @@ -2062,7 +2063,8 @@ static int scrub_checksum_tree_block(struct scrub_block *sblock) } crypto_shash_final(shash, calculated_csum); - if (memcmp(calculated_csum, on_disk_csum, sctx->fs_info->csum_size)) + if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) && + memcmp(calculated_csum, on_disk_csum, sctx->fs_info->csum_size)) sblock->checksum_error = 1; return sblock->header_error || sblock->checksum_error; @@ -2099,7 +2101,8 @@ static int scrub_checksum_super(struct scrub_block *sblock) crypto_shash_digest(shash, kaddr + BTRFS_CSUM_SIZE, BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE, calculated_csum); - if (memcmp(calculated_csum, s->csum, sctx->fs_info->csum_size)) + if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) && + memcmp(calculated_csum, s->csum, sctx->fs_info->csum_size)) ++fail_cor; return fail_cor + fail_gen; From patchwork Fri Oct 14 08:48:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hrutvik Kanabar X-Patchwork-Id: 2594 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp72345wrs; Fri, 14 Oct 2022 01:54:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7EkjfS3w3TtD6Yr8MysvGXYNPiYmklIXS1cuPZkpwUAz6jdu+Yz6OKOq9+q74uJSECCoKT X-Received: by 2002:a17:907:7f05:b0:78d:e869:f2fe with SMTP id qf5-20020a1709077f0500b0078de869f2femr2635441ejc.684.1665737692148; Fri, 14 Oct 2022 01:54:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665737692; cv=none; d=google.com; s=arc-20160816; b=1GZetoRi35ira32yenTB+dyVqb+iEgXpCF4e8OMkVE45KJ28RU916zvBjwpP3LZD8b +CSAEx12KLGneL5HYjhoSFu0SuWaJL4WWkZj3Yn0dQIplEMr+DRH8kqnEoVEGrmCrBFd HAGOxMmeC+hvEcV+v7MdlRSvZDUqI12WxomT/6vzOfcXp869zF3lhL4h1WM+uS9TnGzv cSgog3mbnAJ9RRZKhvoCysTsULIkyEGioCWjWeBHUCAuIoIdg7WG1zVvQfTAlHGWudlj aYPK48gr56fJq+kSfZ6FksmjmlHH3i5bOWLoXctGd/UWYSMaV6XVnXU25fv/mhjd1shF FAdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FSLibGjWy/nIs1Cd+IM0NiQuRQgBV8RHoXsPr1HGgA4=; b=X+JWgwXvjYoo2la6N6NKrfQYdUkunlbK2gSLbZQbWynnUM9NBF5/mXVJdWZCiupuwK Buw9Ro8n7+yWGNbOYhdNLYLbQJ6IWvtLSjSt9dDCswbkH+lLqXw5Rmw9rCX2Tdx1g7eb i9yuBmvP3w0dzz6k3sahHgKjvIMyT5+JCDqiupMMhue2yRcuQZuYnit6EgaLjq+aJIc8 C/TnVFF2Jc9OKJZTy3IYbSGhxHtky8+FKFiGcktjKzgfjVYyBsPfghIC026MoQvdNwbJ TlC8VSGMIDrsLbfDiuF7Dd40T4XEi7mKHBX8TtZ2o1HIQHCy3e3+PbnreUp8wXmG+2vC oL0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="jUVoj/7b"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s3-20020a17090699c300b0078e254ae43fsi1433244ejn.787.2022.10.14.01.54.26; Fri, 14 Oct 2022 01:54:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="jUVoj/7b"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229925AbiJNIua (ORCPT + 99 others); Fri, 14 Oct 2022 04:50:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229921AbiJNIty (ORCPT ); Fri, 14 Oct 2022 04:49:54 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50F10275D1; Fri, 14 Oct 2022 01:49:52 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id w18so6502418wro.7; Fri, 14 Oct 2022 01:49:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FSLibGjWy/nIs1Cd+IM0NiQuRQgBV8RHoXsPr1HGgA4=; b=jUVoj/7b6E4+o16YX/zkS7mGl1/zWyDsJt9qivb9kCg2BhWvw2bMcttep9H3CV3YBJ ZjdSShNRgKcSC+Zk87vJh8JBMp8k2uWWSPXubm+PHqQyF1hqELTu4EtXfa6Lqj6SpsVp 9g2nh60gWPaU4054v3HwSy7DbEKSebYdF2n63JxmbBM9l0cnT4BXQqNVgGqeFBH6oz7e r9um5udVerI7dyDwk7asIA2BKGEpG0dam2OwGNjSZ1t09gZfumg1EtSPwIKRA4vbClpA 5cTAxCqbYjGbvCCEAaVDLZCLqw8UCb06c7MOK1zgpzkC1fe577/DvfmcLc1yH4yXX9EQ +Prw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FSLibGjWy/nIs1Cd+IM0NiQuRQgBV8RHoXsPr1HGgA4=; b=jEjseO5pRkZWo05TSwEOz55LYzl3RST2zEf9VNhzbeTF9O1c3wpP0wKEHPiRQoVQWg s8gA2zjmJt/QmsoEvbcZ6K08sZL6kJzwAA5nA3OGcmlrR8zbVAdyKChNe7ZTzYu42PNH aJfYKyaHHyr2kjVateIW8JljsI5GrFiqacnMaje/R1lq+gsGCbjfBO3ts6vXB9niWkSL 3II26Ogadz5ShUAUHT1wfOVxcD+8UviX4MvW+OgGQd0VXmxOhpLOPdBY6FQ1TXV5hXgR vw28/etNpFzkZSD+lHKvh19IhP+hglBRycefoCrJr/ZL3lvoBciBGJkQdfjGH8vz6e0g iwEw== X-Gm-Message-State: ACrzQf1uMHDYfbEcj3v/FNptvNHWCHJJFH5J9YbkD7fUwfE7ojIWwcrN YR9Tboh3IFcaa2/BMgNp2O0= X-Received: by 2002:a5d:5b1f:0:b0:22e:51b0:2837 with SMTP id bx31-20020a5d5b1f000000b0022e51b02837mr2605593wrb.132.1665737390355; Fri, 14 Oct 2022 01:49:50 -0700 (PDT) Received: from hrutvik.c.googlers.com.com (120.142.205.35.bc.googleusercontent.com. [35.205.142.120]) by smtp.gmail.com with ESMTPSA id 123-20020a1c1981000000b003c6c4639ac6sm1547372wmz.34.2022.10.14.01.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 01:49:50 -0700 (PDT) From: Hrutvik Kanabar To: Hrutvik Kanabar Cc: Marco Elver , Aleksandr Nogikh , kasan-dev@googlegroups.com, Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Theodore Ts'o , Andreas Dilger , linux-ext4@vger.kernel.org, Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Namjae Jeon , Sungjong Seo , Anton Altaparmakov , linux-ntfs-dev@lists.sourceforge.net Subject: [PATCH RFC 4/7] fs/exfat: support `DISABLE_FS_CSUM_VERIFICATION` config option Date: Fri, 14 Oct 2022 08:48:34 +0000 Message-Id: <20221014084837.1787196-5-hrkanabar@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221014084837.1787196-1-hrkanabar@gmail.com> References: <20221014084837.1787196-1-hrkanabar@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746652565939018110?= X-GMAIL-MSGID: =?utf-8?q?1746652565939018110?= From: Hrutvik Kanabar When `DISABLE_FS_CSUM_VERIFICATION` is enabled, bypass checksum verification. Signed-off-by: Hrutvik Kanabar --- fs/exfat/nls.c | 3 ++- fs/exfat/super.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/exfat/nls.c b/fs/exfat/nls.c index 705710f93e2d..f0f92eaf6ccc 100644 --- a/fs/exfat/nls.c +++ b/fs/exfat/nls.c @@ -696,7 +696,8 @@ static int exfat_load_upcase_table(struct super_block *sb, brelse(bh); } - if (index >= 0xFFFF && utbl_checksum == chksum) + if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) || + (index >= 0xFFFF && utbl_checksum == chksum)) return 0; exfat_err(sb, "failed to load upcase table (idx : 0x%08x, chksum : 0x%08x, utbl_chksum : 0x%08x)", diff --git a/fs/exfat/super.c b/fs/exfat/super.c index 35f0305cd493..7418858792b3 100644 --- a/fs/exfat/super.c +++ b/fs/exfat/super.c @@ -564,6 +564,9 @@ static int exfat_verify_boot_region(struct super_block *sb) if (!bh) return -EIO; + if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION)) + return 0; + for (i = 0; i < sb->s_blocksize; i += sizeof(u32)) { p_chksum = (__le32 *)&bh->b_data[i]; if (le32_to_cpu(*p_chksum) != chksum) { From patchwork Fri Oct 14 08:48:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hrutvik Kanabar X-Patchwork-Id: 2591 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp71523wrs; Fri, 14 Oct 2022 01:52:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4pzDNlM13th0u6dex3yUKZd/iMKzv1hSov8TW6zAUbKpQAfAiY6+DSA/osHqARs3FRw8Gk X-Received: by 2002:a05:6402:40d4:b0:45d:1351:3f9d with SMTP id z20-20020a05640240d400b0045d13513f9dmr2719645edb.199.1665737525371; Fri, 14 Oct 2022 01:52:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665737525; cv=none; d=google.com; s=arc-20160816; b=boiQFi2LKBMBSHk8C2f5nBQYv1jXkU+ViZkG7DRG447JuUmMiIsHbrTbLqYwoPzvrG XEMUgUwe6GuFvDG/wV75ljagRBdT+Wfy9ZUzs53oKG5fpLLcTImhG/aaCJ71v86kw7yq c8jRK8nLpxLsNfSDmYOkc43GCFLjInNFHCE9ZwW8SzO7MFjDhyDBCYo7n+8XYYQZYemL Wk2lLIVQoALXk3633ubSvdeAu8OOKnWTV5EUpbRcmGuSfwM6lobGBD/Kj71UzEUk/b85 XoQc06uVlmwy4VT8ifY+pbyPHzrTk5thatndA8EOdBnr1NFGKi1f0pK3tnR2Hx1iCcJU 0iSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Gi1PiA14Xvf0/+DfXuVtXD45G5BgebCQf9p57BfhR6s=; b=Itbp5t8gMCKThHlyI0bsakHtE2vSqGIYGQ2BQULQTXMM+f46UTErr3qFRBNmkG0nZp e+6ZyrFSfEkUDwKBwDnGgm3vcMm5OFITLdHOaBESZsO6TgWrM1knupBwtNOiBbx4bRQF Q5W6X8lMSH/zMzbLNqm5vkpIGwbWlARxPdtS7SlRTk6bdCY1suUX5DSjylm39c4v8Blp paznOekfl/HBEP3dwM4TaWrQ1p4tVzi0WWnMyVk5LybMI1ZPmOyw36vJV1eebJgY4Yl+ OAx2a4RiGsEAGH7vhwaVB7ZaXWiwTLnhCNW42LBz4T9n/KQRPZEi0p5b1gJR3TA1xKox VtFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UxT7gVP8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn20-20020a1709070d1400b0078d514ace6bsi2113993ejc.282.2022.10.14.01.51.38; Fri, 14 Oct 2022 01:52:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UxT7gVP8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230011AbiJNIuP (ORCPT + 99 others); Fri, 14 Oct 2022 04:50:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229922AbiJNIty (ORCPT ); Fri, 14 Oct 2022 04:49:54 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 510372793A; Fri, 14 Oct 2022 01:49:52 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id n9so2681111wms.1; Fri, 14 Oct 2022 01:49:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Gi1PiA14Xvf0/+DfXuVtXD45G5BgebCQf9p57BfhR6s=; b=UxT7gVP8q9ze5Ggh2xvvktN6Ml02oBmfbyNFVTxcbcy6qgnZqVwI+fd54u0LJL+LjK y9EfYIAWCha0O2HVLdo55pAxb/IFOyVB4eHwuuXfLb3Q+WnwPgMtjSKPzu2oQKEhgIW1 8w0WFdRg+RSJnOotAcs1Y+eSeMLVjAcWDFJda2lYZblubtGGGkakV9MIfwsDN7apZ3yC Rg00X0lJRAafbj8ZJHp9DjnqhMJlcm3+NYiLzY/y+FmG8gOcaLVVoEvJhhCVshISMbUn 79bKI/g91GDk/8Ucsg8DPhwD6is+bLLgsNqiPgi18MPBUAdCAjxbT3q7n7tlSgWXhmL1 RzAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gi1PiA14Xvf0/+DfXuVtXD45G5BgebCQf9p57BfhR6s=; b=Ndm+9e02EkIh90achuXSbJ5Oz39gvrY2P+g9PWS0pkPEAZUSDRXxaZvfu68vFJWtvD k4Cqs7CVRog3bv3EkdFXhLdDTyrqzNKbugAC2rVjujcRHo6l1jn7yx3UTuWfpV2WsDyq VmWuW8YMZ57QSM5DYYLqCnjg5EtWPjMAeIDIZLrWdiIayKRAkuxsgz/amZJdREd04Uw7 f4aTyhdWNQVrY74PnXttlnKRfOj7PLareYj0vnpeoNRdUJ6xWhc0MPHQ6H3MOCfsDGGm Cz4AMRPrLGDOfST/JYIqoW3bE5iXXKdefy/vtpJ4h+zQ11uQKjAEadQ90q/94LX4SEBo z23A== X-Gm-Message-State: ACrzQf0fiECU0BIEkYhgWm8MpfiHLZZwOT1HFtoIj+8Mf93VAjBH+N4k WnmgNldrEaELq/nDtoslTr4= X-Received: by 2002:a05:600c:3044:b0:3c4:8af4:ecc5 with SMTP id n4-20020a05600c304400b003c48af4ecc5mr2758757wmh.52.1665737391668; Fri, 14 Oct 2022 01:49:51 -0700 (PDT) Received: from hrutvik.c.googlers.com.com (120.142.205.35.bc.googleusercontent.com. [35.205.142.120]) by smtp.gmail.com with ESMTPSA id 123-20020a1c1981000000b003c6c4639ac6sm1547372wmz.34.2022.10.14.01.49.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 01:49:51 -0700 (PDT) From: Hrutvik Kanabar To: Hrutvik Kanabar Cc: Marco Elver , Aleksandr Nogikh , kasan-dev@googlegroups.com, Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Theodore Ts'o , Andreas Dilger , linux-ext4@vger.kernel.org, Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Namjae Jeon , Sungjong Seo , Anton Altaparmakov , linux-ntfs-dev@lists.sourceforge.net Subject: [PATCH RFC 5/7] fs/xfs: support `DISABLE_FS_CSUM_VERIFICATION` config option Date: Fri, 14 Oct 2022 08:48:35 +0000 Message-Id: <20221014084837.1787196-6-hrkanabar@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221014084837.1787196-1-hrkanabar@gmail.com> References: <20221014084837.1787196-1-hrkanabar@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746652391447047400?= X-GMAIL-MSGID: =?utf-8?q?1746652391447047400?= From: Hrutvik Kanabar When `DISABLE_FS_CSUM_VERIFICATION` is enabled, return truthy value for `xfs_verify_cksum`, which is the key function implementing checksum verification for XFS. Signed-off-by: Hrutvik Kanabar --- fs/xfs/libxfs/xfs_cksum.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_cksum.h b/fs/xfs/libxfs/xfs_cksum.h index 999a290cfd72..ba55b1afa382 100644 --- a/fs/xfs/libxfs/xfs_cksum.h +++ b/fs/xfs/libxfs/xfs_cksum.h @@ -76,7 +76,10 @@ xfs_verify_cksum(char *buffer, size_t length, unsigned long cksum_offset) { uint32_t crc = xfs_start_cksum_safe(buffer, length, cksum_offset); - return *(__le32 *)(buffer + cksum_offset) == xfs_end_cksum(crc); + if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION)) + return 1; + else + return *(__le32 *)(buffer + cksum_offset) == xfs_end_cksum(crc); } #endif /* _XFS_CKSUM_H */ From patchwork Fri Oct 14 08:48:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hrutvik Kanabar X-Patchwork-Id: 2593 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp72183wrs; Fri, 14 Oct 2022 01:54:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM46XaQfPoRDx9905xOO717SZeGyZpPHm+Ggp22WWT7+U9bQmWMGtIiPyi6oXCSq6GNW1YNg X-Received: by 2002:a17:906:770d:b0:73c:a08f:593c with SMTP id q13-20020a170906770d00b0073ca08f593cmr2904818ejm.182.1665737653871; Fri, 14 Oct 2022 01:54:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665737653; cv=none; d=google.com; s=arc-20160816; b=TLFFHWNGHjV0dIxgqmIEa7q97226VwR3oOB1zjRYWv/Aij+huthC1r1oejMQSXM7ut kDCPYT11FcM0En0NvKtnFtcPYxLBiUxurPLG7y81bOMkCcO2TYOBivKB+2W95aVDH30v wYQ4jFuE/u0F3n1XKvCquF1b458sAM+6ndxB0UE9wsuMaZwV9FfqPuPMeRlfvIX9o6TV VRpnKGgl2WpNR95E0ccRQddz9BvdBwZeD4VV6CQUIY0wxTONL6nWKcT8Btsav9GBv6xy eQ5hyvp2ouOSpgZDFA5bGYxxNK6vMFLp6F04QoCZ++hvIhXb91tYmFOClID+Ci5ccVpo RSxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uiJoxGZJlGz3xwdy8ebCPccYWzJULAWBypBIpnExuaw=; b=DWfqyqdbvaUEoAv3NWOBXNUj09jgBiREnqGW1kGT7W8/LNv6nySKtHabcdvLK5K6F1 jxKA3GmuVxA6UKIAetPUvWwwhRhPF0F2CqCEiNcl7tepybpS+H9sbjIx2RJsAxuBpdNk hecxYeD/x/Ku2GKnnnruo4WHLNfFUyNK9nlPMEcbEnPWv3IfhJ+5a/78gM6emC7TN5+p /gn+ebwXUVZac0lNPw3uPBl/6tk0sVsUKPEX3+QbMf4WBoz+zzEpDsnhYp3OvXUXElY7 WGOKUo+B0504hfKUlur4DT57OLlRYOhit8vBJHiw54GqvgvLVyWLmikhJ4CqfTr19m8P pb5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aQXy8rp4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b14-20020a17090630ce00b00782da4ff18dsi1714465ejb.668.2022.10.14.01.53.47; Fri, 14 Oct 2022 01:54:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aQXy8rp4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230050AbiJNIuT (ORCPT + 99 others); Fri, 14 Oct 2022 04:50:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229936AbiJNIt7 (ORCPT ); Fri, 14 Oct 2022 04:49:59 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E58292CE31; Fri, 14 Oct 2022 01:49:54 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id c3-20020a1c3503000000b003bd21e3dd7aso4910366wma.1; Fri, 14 Oct 2022 01:49:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uiJoxGZJlGz3xwdy8ebCPccYWzJULAWBypBIpnExuaw=; b=aQXy8rp4jlY1YgDvBq1bWyBZHXn7pusOKrg/5bG7Ec06kepOaaMYlnWN31PAE1PhO0 TiKU6+usEJZY4E0qpN1rIEdfB92GVvNMKknsSFgjYfgeV3g+pzSFATmKMeE04UQL4scQ XjyUVRGfqMnFvZ7+ekfDI2ipLglMQJSCdWubbw9vB3pWX5ZABwG8+g26g3rlQoNdpz27 C/0CQ6oChQqs+ufVKybV/tfloQQhEVBx2g+7BsjAS96KG2vlZDeo1BThWz9v5Fe5Xwvi Sf8I1muhzR3/vs9pECQZgEQhe44GnS7aptOVx0dr6ahIvicPhqcmhnIlZ5BnWfoJOlSa FNvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uiJoxGZJlGz3xwdy8ebCPccYWzJULAWBypBIpnExuaw=; b=efZDUhKpKdad40f70/izo/m8NbEOB4kcco+G+KS0gOBpciwGWBGUp3JC3gfV1dcGGp oYirj2ehDpZKN2uA7ytOa4yvWG6Mn6m/hc+zzNU8uvoIgovr8ZM1Ch9413/VbEfcipGY 2XQzUKqlgQSCIWvcIH2xc1pWqYmY6/L+esZrov2ZyiZoOcM3l3oP2xWNcQdi/nE3cbPU 5H3D1qMgA65b37PMKBseSqjgJFH3Wsc0CvYaFO6D0BkXViRoWnsH+u4Te6JuNAIsJhMI fbbjQCMmDEn7xHJYlgQv0EIa860wbGUKRdYNCC6+uBnfMagUgpV8ge4rzyXD9DNV+JYb U1Jg== X-Gm-Message-State: ACrzQf1vrVoFe/ABJC1Bj92pOaZbd/cqdhIJm21zXQdvtuRoQNTR+N6Z 2cb52MVxZDALTx56owFb4hM= X-Received: by 2002:a05:600c:3c8e:b0:3b4:d224:addf with SMTP id bg14-20020a05600c3c8e00b003b4d224addfmr9435669wmb.132.1665737392984; Fri, 14 Oct 2022 01:49:52 -0700 (PDT) Received: from hrutvik.c.googlers.com.com (120.142.205.35.bc.googleusercontent.com. [35.205.142.120]) by smtp.gmail.com with ESMTPSA id 123-20020a1c1981000000b003c6c4639ac6sm1547372wmz.34.2022.10.14.01.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 01:49:52 -0700 (PDT) From: Hrutvik Kanabar To: Hrutvik Kanabar Cc: Marco Elver , Aleksandr Nogikh , kasan-dev@googlegroups.com, Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Theodore Ts'o , Andreas Dilger , linux-ext4@vger.kernel.org, Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Namjae Jeon , Sungjong Seo , Anton Altaparmakov , linux-ntfs-dev@lists.sourceforge.net Subject: [PATCH RFC 6/7] fs/ntfs: support `DISABLE_FS_CSUM_VERIFICATION` config option Date: Fri, 14 Oct 2022 08:48:36 +0000 Message-Id: <20221014084837.1787196-7-hrkanabar@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221014084837.1787196-1-hrkanabar@gmail.com> References: <20221014084837.1787196-1-hrkanabar@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746652526446586357?= X-GMAIL-MSGID: =?utf-8?q?1746652526446586357?= From: Hrutvik Kanabar When `DISABLE_FS_CSUM_VERIFICATION` is enabled, bypass checksum verification in `is_boot_sector_ntfs`. Signed-off-by: Hrutvik Kanabar --- fs/ntfs/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index 001f4e053c85..428c65ce9a80 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c @@ -582,7 +582,8 @@ static bool is_boot_sector_ntfs(const struct super_block *sb, for (i = 0, u = (le32*)b; u < (le32*)(&b->checksum); ++u) i += le32_to_cpup(u); - if (le32_to_cpu(b->checksum) != i) + if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) && + le32_to_cpu(b->checksum) != i) ntfs_warning(sb, "Invalid boot sector checksum."); } /* Check OEMidentifier is "NTFS " */ From patchwork Fri Oct 14 08:48:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hrutvik Kanabar X-Patchwork-Id: 2595 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp72372wrs; Fri, 14 Oct 2022 01:54:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM72uJpVT0hraEUXhXlT5p8N5qT434nCczH3jqsBQDF32Mq/XwDvqnDe4ZNkupSAulFdRFBK X-Received: by 2002:a17:907:94c3:b0:78e:2866:f89f with SMTP id dn3-20020a17090794c300b0078e2866f89fmr500068ejc.617.1665737699254; Fri, 14 Oct 2022 01:54:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665737699; cv=none; d=google.com; s=arc-20160816; b=g4PR1MXOWjYhl1iAupYriYdP/S9jgfYq6qVDGWzjrvevCL+uC+QJb5LnhO6J6sd28W 9/NNo4FY/v3Hfj7K0MaS1JPI/2Elu1Ecz53sromEltaXUNURcJkqULVliy4c6IZXZ7ZH ZwfgXU71SHS54FimDWOGFghPuDLdbJ0puV1aK4+kXj6jjmfNansFozKBGbxScfxUe21S yiPAgmrzo0lvn6CdtH9f9AzabBjGPAIZBRKhwS9OBPvWa2obVccGUyRc6alpuPKDQ7+M ZluIPk8HaOJkPaERonDIahVdZOB4ciklPA3Awxy5BoYqJ5Vj8x/BsoAGWiIETN+fer2W ruFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gOV3h57ut5GHhGlnLsxkEHBnkvFbonX9ORLLuFusyi0=; b=XQDSREO0kC2jS01ORDjYg5V0mMmkeOX8gieB2NyCryrq3ZelPjgZsI5BFEOad3PJ/N X4KrnhrDVUdLqkmNvSvGA+x19nvQ3t+2ERG7EagU/sNhx82vkfjpBTf5eShSaWem5KBa rI9uh/RMxfC7gvV3p3Y2EijRheIqWjWmPwpB9OHJNtRA2GPJzBnTdc3UaQqAwu0pf+1i UZfs/jnh4YxUrHamb3y9qypawt9MLDa3vZxjU4S51aSyGa9U37/a9Hrjo6RW922d2IUJ PZfyyJcWtd3uAS6WgLqLjOVKKdJ0LneOLHN6bgq/7QSP7WkCAUldvdODjp/ja+H0uSkQ TFZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GfG0sfEg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u29-20020a50d51d000000b00459141c6f75si1838051edi.100.2022.10.14.01.54.33; Fri, 14 Oct 2022 01:54:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GfG0sfEg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229994AbiJNIui (ORCPT + 99 others); Fri, 14 Oct 2022 04:50:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbiJNIt7 (ORCPT ); Fri, 14 Oct 2022 04:49:59 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86D5832BA7; Fri, 14 Oct 2022 01:49:56 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id c9-20020a05600c100900b003c6da0f9b62so2546530wmc.1; Fri, 14 Oct 2022 01:49:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gOV3h57ut5GHhGlnLsxkEHBnkvFbonX9ORLLuFusyi0=; b=GfG0sfEgh2ptierbWCnoguBubKf8JDmmicxf1uJSpFpGObOsFWBqAhZpEYJ5Krl+yo ZD1cwtaOtRSGc/If6NW2e99cfjHy447Mfkim3JBoO6lFHYVO43xdxReqY6l8QyFBn4Qc tGp1dAr825o3wC1fJ3+NYRhGU424uQwhoZSV5IZH/fycyAueUF0kXNr3kuIlzRScRjEM aqxVZim71FxWOLPQbEMG0l3htKZad0jBeYIJY2DLYtsbqGW8wiG+xF4GplnsrmQkllp0 oM0aAGnq+3SiJfldcLJyIp7maRrgbF8Lv6EtCNGsqquNz1rjsbw3Zxsk5zbVXT/52SAq oChQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gOV3h57ut5GHhGlnLsxkEHBnkvFbonX9ORLLuFusyi0=; b=yFc18Ic5uajmvY858S5SmYtEssLPjsgZ3xhbt5SLxBd5DKgGxNVdPiEKVGqQcyiRVx hOYbYRKrNermmCe3SP/LNZrws7EhYTeigD8acNBYogs4HL3q1t/oryvNT0GKvT3DQ/vL ASvTa9n4jk01jTgw/pty0FaBVcQOp7Fd8oEFtN7rXdsvEFXIkp0ljWQpwfboFF6bArc3 H1a2JhbnJYZKSUpQPynem1jCiNBLmeh9vXDhInQtZOUywg7QAGrYweNLFT8t9a+o2jIG A5/RbJgP5ZAlal12VYy1tiq6LUlR8P8HYAH6tm62y37HbLePfFlN/pm6ZR8UaYEP888E mefw== X-Gm-Message-State: ACrzQf3+WPZYFCGsXiYY2zWNaDDGanw5mkjHffyFN+3lEqjki/eraPHS DpNQ/Rn2M9k1CHTWYbgLgs8= X-Received: by 2002:a05:600c:4f93:b0:3b4:c026:85a1 with SMTP id n19-20020a05600c4f9300b003b4c02685a1mr9583025wmq.39.1665737394358; Fri, 14 Oct 2022 01:49:54 -0700 (PDT) Received: from hrutvik.c.googlers.com.com (120.142.205.35.bc.googleusercontent.com. [35.205.142.120]) by smtp.gmail.com with ESMTPSA id 123-20020a1c1981000000b003c6c4639ac6sm1547372wmz.34.2022.10.14.01.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 01:49:54 -0700 (PDT) From: Hrutvik Kanabar To: Hrutvik Kanabar Cc: Marco Elver , Aleksandr Nogikh , kasan-dev@googlegroups.com, Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Theodore Ts'o , Andreas Dilger , linux-ext4@vger.kernel.org, Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Namjae Jeon , Sungjong Seo , Anton Altaparmakov , linux-ntfs-dev@lists.sourceforge.net Subject: [PATCH RFC 7/7] fs/f2fs: support `DISABLE_FS_CSUM_VERIFICATION` config option Date: Fri, 14 Oct 2022 08:48:37 +0000 Message-Id: <20221014084837.1787196-8-hrkanabar@gmail.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221014084837.1787196-1-hrkanabar@gmail.com> References: <20221014084837.1787196-1-hrkanabar@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746652573641417084?= X-GMAIL-MSGID: =?utf-8?q?1746652573641417084?= From: Hrutvik Kanabar When `DISABLE_FS_CSUM_VERIFICATION` is enabled, bypass checksum verification. Signed-off-by: Hrutvik Kanabar --- fs/f2fs/checkpoint.c | 3 ++- fs/f2fs/compress.c | 3 ++- fs/f2fs/f2fs.h | 2 ++ fs/f2fs/inode.c | 3 +++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 0c82dae082aa..cc5043fbffcb 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -864,7 +864,8 @@ static int get_checkpoint_version(struct f2fs_sb_info *sbi, block_t cp_addr, } crc = f2fs_checkpoint_chksum(sbi, *cp_block); - if (crc != cur_cp_crc(*cp_block)) { + if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) && + crc != cur_cp_crc(*cp_block)) { f2fs_put_page(*cp_page, 1); f2fs_warn(sbi, "invalid crc value"); return -EINVAL; diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index d315c2de136f..d0bce92dbf38 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -772,7 +772,8 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task) u32 provided = le32_to_cpu(dic->cbuf->chksum); u32 calculated = f2fs_crc32(sbi, dic->cbuf->cdata, dic->clen); - if (provided != calculated) { + if (!IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION) && + provided != calculated) { if (!is_inode_flag_set(dic->inode, FI_COMPRESS_CORRUPT)) { set_inode_flag(dic->inode, FI_COMPRESS_CORRUPT); printk_ratelimited( diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index e6355a5683b7..b27f1ec9b49f 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1976,6 +1976,8 @@ static inline u32 f2fs_crc32(struct f2fs_sb_info *sbi, const void *address, static inline bool f2fs_crc_valid(struct f2fs_sb_info *sbi, __u32 blk_crc, void *buf, size_t buf_size) { + if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION)) + return true; return f2fs_crc32(sbi, buf, buf_size) == blk_crc; } diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index 9f0d3864d9f1..239bb08e45b1 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -181,6 +181,9 @@ bool f2fs_inode_chksum_verify(struct f2fs_sb_info *sbi, struct page *page) #endif return true; + if (IS_ENABLED(CONFIG_DISABLE_FS_CSUM_VERIFICATION)) + return true; + ri = &F2FS_NODE(page)->i; provided = le32_to_cpu(ri->i_inode_checksum); calculated = f2fs_inode_chksum(sbi, page);