From nobody Wed Sep 10 21:48:04 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09BD4C61DA4 for ; Wed, 22 Feb 2023 13:12:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232164AbjBVNMc (ORCPT ); Wed, 22 Feb 2023 08:12:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231971AbjBVNM1 (ORCPT ); Wed, 22 Feb 2023 08:12:27 -0500 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D32F73928D for ; Wed, 22 Feb 2023 05:12:21 -0800 (PST) Received: by mail-lf1-x129.google.com with SMTP id x24so10069624lfr.1 for ; Wed, 22 Feb 2023 05:12:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=HLDojPRW+ZsQOIZwIAXgd8EkXB16fF3Bt+6jaMZKqbM=; b=nU2G1RacBkWrQaKi7zeLDSxeZxVWZRQKGxUf7GNywf2v3SnZj4hmFyzNz/LOWA7SNZ bCW+WXZoJvLPZP/SFL6rCpAaTnX4pxC4cDsAv844DFRgarExvvrRMU0xFZgTR+UkUINK tfnwYi9GStRcs6WIjc1jwrCnFKWeNjiGox+sHWPigIGVb/UfCr+B1hgLbd6l+y9+KMyQ V6YlLSYGkjl5hcVhsC0n93fHI9DEcbyGNO+WN48CKPm70NjJKRvYU5IC5tScCcC28W7Y PmXt8svVEGb8Z4g3TYuTU8UuYdOneTGmEoDaWRJUHLIdSc4mMHCsVei7LVaUlpX3JmoN TefA== 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=HLDojPRW+ZsQOIZwIAXgd8EkXB16fF3Bt+6jaMZKqbM=; b=fXXJTbFy1A29aVc8Og6ccVxEX8VFVGHTDxdd/UXl6cSoopJ3soJRDpmto8baXVodXW rAHktwnlmRPCFmxcaOyCBm36LSRhnEqKBqL5PH/peOtdqrAOdpeGyg32g/Xfkgm++Zip 28B5PTbQQg+ChxUvnEhE6aIMtqeaukn8+MrEt/BLuyQ1NXXaWubZpBJ+DAb3aMnbFszc VB601wa9MDdIj0Y86PylbxmuUpYHH0Wp5Ms1CD8QGjpPRqCwP+Lc3xmMvtODhNsobvlJ DYu7hSAHt4oRZVy3ZvSmEHQ4vK7CRVTG3yoVEZqRAVNcN4LleubV9urncUpELu1V3fKe nGiA== X-Gm-Message-State: AO0yUKURWJFiszy3/ucYNzNNkBZ7c4+X9ks1Wtrfd8wG3Ga4LKlDi/O6 TcnzY4jd2t/Eg0mv9u0FI5blBA== X-Google-Smtp-Source: AK7set8fH43IkYA7We+tyutXd5OWGe8JqBzTuF8HKl2nyATWWc0yMbZS9LtIBPXZvNohHQBH9nSVuQ== X-Received: by 2002:a19:f612:0:b0:4d5:8f3e:7852 with SMTP id x18-20020a19f612000000b004d58f3e7852mr2937893lfe.49.1677071539975; Wed, 22 Feb 2023 05:12:19 -0800 (PST) Received: from ta1.c.googlers.com.com (138.58.228.35.bc.googleusercontent.com. [35.228.58.138]) by smtp.gmail.com with ESMTPSA id y25-20020a2e7d19000000b0029335c12997sm564383ljc.58.2023.02.22.05.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 05:12:19 -0800 (PST) From: Tudor Ambarus To: tytso@mit.edu, darrick.wong@oracle.com, djwong@kernel.org, adilger.kernel@dilger.ca Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, joneslee@google.com, Tudor Ambarus , stable@vger.kernel.org, syzbot+6be2b977c89f79b6b153@syzkaller.appspotmail.com Subject: [PATCH 1/3] ext4: fsmap: Fix crash caused by poor key validation Date: Wed, 22 Feb 2023 13:12:09 +0000 Message-Id: <20230222131211.3898066-2-tudor.ambarus@linaro.org> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog In-Reply-To: <20230222131211.3898066-1-tudor.ambarus@linaro.org> References: <20230222131211.3898066-1-tudor.ambarus@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The following crash was seen on a 1k-block ext4 filesystem when the user passed a fmr_physical of value zero for the high key: kernel BUG at fs/ext4/ext4.h:3354! invalid opcode: 0000 [#1] PREEMPT SMP KASAN CPU: 0 PID: 422 Comm: syz-executor339 Not tainted 5.15.74-syzkaller-00001-g= 4ec71a9ec769 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Goo= gle 10/26/2022 RIP: 0010:ext4_get_group_info fs/ext4/ext4.h:3354 [inline] RIP: 0010:ext4_mb_load_buddy_gfp+0xe9d/0xeb0 fs/ext4/mballoc.c:1498 Code: 99 ed c1 ff e9 47 f4 ff ff e8 5f a0 7f ff 48 c7 c7 c0 c3 a9 86 48 89 = de 4c 89 ea e8 ad 8e 92 00 e9 a1 f2 ff ff e8 43 a0 7f ff <0f> 0b e8 3c a0 7= f ff 0f 0b e8 35 a0 7f ff 0f 0b 0f 1f 00 55 48 89 RSP: 0018:ffffc9000044f320 EFLAGS: 00010293 RAX: ffffffff81f1f14d RBX: 0000000000000001 RCX: ffff888106194f00 RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000001 RBP: ffffc9000044f3b0 R08: ffffffff81f1e3a4 R09: ffffc9000044f440 R10: fffff52000089e8f R11: 1ffff92000089e88 R12: ffff888100a553c8 R13: dffffc0000000000 R14: 0000000000000001 R15: ffff888105f9a000 FS: 000055555675b300(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055c4f7cde3e8 CR3: 000000011c064000 CR4: 00000000003506b0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: ext4_mb_load_buddy fs/ext4/mballoc.c:1620 [inline] ext4_mballoc_query_range+0xb8/0x7b0 fs/ext4/mballoc.c:6560 ext4_getfsmap_datadev+0x1c8a/0x28c0 fs/ext4/fsmap.c:537 ext4_getfsmap+0xcff/0x1040 fs/ext4/fsmap.c:708 ext4_ioc_getfsmap fs/ext4/ioctl.c:660 [inline] __ext4_ioctl fs/ext4/ioctl.c:862 [inline] ext4_ioctl+0x3020/0x50e0 fs/ext4/ioctl.c:1276 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:874 [inline] __se_sys_ioctl+0x115/0x190 fs/ioctl.c:860 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:860 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x61/0xcb RIP: 0033:0x7f8d2372e3e9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 14 00 00 90 48 89 f8 48 89 f7 = 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff f= f 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007ffcae7c2578 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00000000000f4240 RCX: 00007f8d2372e3e9 RDX: 0000000020000200 RSI: 00000000c0c0583b RDI: 0000000000000004 RBP: 0000000000000000 R08: 000000000000000d R09: 000000000000000d R10: 00000000000003f1 R11: 0000000000000246 R12: 00007f8d236ed5c0 R13: 00007ffcae7c25a0 R14: 00007ffcae7c258c R15: 00007ffcae7c2590 The crash is due to insufficient key validation. When high_key->fmr_physical is zero for a 1k-block ext4 filesystem we encounter an underflow in the second call to ext4_get_group_no_and_offset(): blocknr =3D blocknr - le32_to_cpu(es->s_first_data_block); blocknr comes with value zero (high_key->fmr_physical is zero) and the first_data_block is one, thus blocknr becomes -1. Since blocknr is of type ext4_fsblk_t (unsigned long long) the value is all ones. Due to the high values for blocknr and offset we hit the BUG_ON in ext4_get_group_info() as the groupnr exceeds EXT4_SB(sb)->s_groups_count). Fix it by returning early when keys[1].fmr_physical is less than or equal to the first data block, as there's no data to return. This replicates the behavior of returning zero, like in keys[0].fmr_physical >=3D eofs. In both cases -EINVAL could be returned but for some reason the author decided to just ignore out of bounds requests. One may notice that the check introduced addresses just the ext4_getfsmap_datadev() handler. This is intentional, because for the ext4_getfsmap_logdev() handler, the value of the high key passed by the user is ignored and instead the code uses: memset(&info->gfi_high, 0xFF, sizeof(info->gfi_high)); Cc: stable@vger.kernel.org Fixes: 0c9ec4beecac ("ext4: support GETFSMAP ioctls") Link: https://syzkaller.appspot.com/bug?id=3D79d5768e9bfe362911ac1a5057a36f= c6b5c30002 Reported-by: syzbot+6be2b977c89f79b6b153@syzkaller.appspotmail.com Signed-off-by: Tudor Ambarus --- fs/ext4/fsmap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c index 4493ef0c715e..b5289378a761 100644 --- a/fs/ext4/fsmap.c +++ b/fs/ext4/fsmap.c @@ -479,6 +479,8 @@ static int ext4_getfsmap_datadev(struct super_block *sb, int error =3D 0; =20 bofs =3D le32_to_cpu(sbi->s_es->s_first_data_block); + if (keys[1].fmr_physical <=3D bofs) + return 0; eofs =3D ext4_blocks_count(sbi->s_es); if (keys[0].fmr_physical >=3D eofs) return 0; --=20 2.39.2.637.g21b0678d19-goog From nobody Wed Sep 10 21:48:04 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88367C636D6 for ; Wed, 22 Feb 2023 13:12:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232113AbjBVNMa (ORCPT ); Wed, 22 Feb 2023 08:12:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231931AbjBVNM0 (ORCPT ); Wed, 22 Feb 2023 08:12:26 -0500 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83CB13B0D9 for ; Wed, 22 Feb 2023 05:12:24 -0800 (PST) Received: by mail-lj1-x235.google.com with SMTP id t14so5011606ljd.5 for ; Wed, 22 Feb 2023 05:12:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=oK0AQMNR90IXprBf0YC2HUcZwjPfMUnLVMauRW7h31s=; b=Amwg5UumUVioyg9RHsXp9Ky0ggwyvXUUex/yDlVHBYVKK4ZzERhOMjLnqmQDrXGUCJ AbDIrSuzxaB3L7YvGRen5J6uCTScsXQd4WQEBgxqFEE3RydANniKu3lvVYfZ2DHXdjZo y2yKTlu40cJm+MOTI/0E6PBOVFIA5ovuEeNOgCT3fpZgLSzYL9FzJEfOYgB0kHmPa+O1 iVTVWiD1ZixelS8sz2qvOsGdUZU/ocr/hQFEA4Bp98cWzlkSHUGF6XOe3xIUQRq1m/58 W6qPLP3vfy8qm7PdMa4z5S7i7pjCHXG1RMXjhpmI1upU1fNPpjpHXsrkDkhKAfFkf7lo G83Q== 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=oK0AQMNR90IXprBf0YC2HUcZwjPfMUnLVMauRW7h31s=; b=EVBCTBpRY4c8x3ny9fPPUOrhDC8Mxfa3V/zzFmUjPzEXiCloxdh/eqfJOSIqS299My rd8EF+tpvR3+RfFoUsWkl60oqlqxr8Eid4MXlUuiw71WZNEVnjS5+sZ1IqdjfsxYrJzc m4RiTOAdZmokE5O0ZDorleoMvbfJBSDUZq+E/LBLlCumCG3ZclWVOeF+/XThrMi4o4Rd N2HPKxKbHyGmeryZ6H1fQ7BCdKK9R5mWVa5T+2xXWRAXsWbrWfy5shzIpEfit8X6KYTm LljKl/t7DNBI8Dtsu7LsKzcBfxycDk616pnXDPizh+S+B5s+Gun5BEADAnqA9qkMivZz KZVA== X-Gm-Message-State: AO0yUKXqtKIwacFH5dALlqbqORJ8wnmToPHKSv6OUC+t5OI6QC69p/T2 /knmLG+J7sxMZY8OEiCQvRRIpA== X-Google-Smtp-Source: AK7set9OguqdOHMphOq4bnKYWrOa0Li5fPVk1pMp9Hh9cW11sCJuRx0sM4JdGGb/FK+Qd77scgs/0w== X-Received: by 2002:a2e:b8c4:0:b0:290:6e13:7674 with SMTP id s4-20020a2eb8c4000000b002906e137674mr4521593ljp.31.1677071542753; Wed, 22 Feb 2023 05:12:22 -0800 (PST) Received: from ta1.c.googlers.com.com (138.58.228.35.bc.googleusercontent.com. [35.228.58.138]) by smtp.gmail.com with ESMTPSA id y25-20020a2e7d19000000b0029335c12997sm564383ljc.58.2023.02.22.05.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 05:12:22 -0800 (PST) From: Tudor Ambarus To: tytso@mit.edu, darrick.wong@oracle.com, djwong@kernel.org, adilger.kernel@dilger.ca Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, joneslee@google.com, Tudor Ambarus Subject: [PATCH 2/3] ext4: fsmap: Consolidate fsmap_head checks Date: Wed, 22 Feb 2023 13:12:10 +0000 Message-Id: <20230222131211.3898066-3-tudor.ambarus@linaro.org> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog In-Reply-To: <20230222131211.3898066-1-tudor.ambarus@linaro.org> References: <20230222131211.3898066-1-tudor.ambarus@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Sanity checks should be done the soonest possible to avoid superfluous computations when user provides wrong data. Gather all the checks on user provided data in a single method and call it immediately after copying the data from user. Signed-off-by: Tudor Ambarus --- fs/ext4/fsmap.c | 52 ++++++++++++++++++++++++++++++++++++------------- fs/ext4/fsmap.h | 3 +++ fs/ext4/ioctl.c | 17 +++------------- 3 files changed, 44 insertions(+), 28 deletions(-) diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c index b5289378a761..a27d9f0967b7 100644 --- a/fs/ext4/fsmap.c +++ b/fs/ext4/fsmap.c @@ -9,6 +9,7 @@ #include "fsmap.h" #include "mballoc.h" #include +#include #include #include =20 @@ -571,7 +572,7 @@ static int ext4_getfsmap_datadev(struct super_block *sb, =20 /* Do we recognize the device? */ static bool ext4_getfsmap_is_valid_device(struct super_block *sb, - struct ext4_fsmap *fm) + const struct fsmap *fm) { if (fm->fmr_device =3D=3D 0 || fm->fmr_device =3D=3D UINT_MAX || fm->fmr_device =3D=3D new_encode_dev(sb->s_bdev->bd_dev)) @@ -583,17 +584,19 @@ static bool ext4_getfsmap_is_valid_device(struct supe= r_block *sb, } =20 /* Ensure that the low key is less than the high key. */ -static bool ext4_getfsmap_check_keys(struct ext4_fsmap *low_key, - struct ext4_fsmap *high_key) +static bool ext4_getfsmap_check_keys(const struct fsmap *low_key, + const struct fsmap *high_key) { + u64 l_fmr_phys =3D low_key->fmr_physical + low_key->fmr_length; + if (low_key->fmr_device > high_key->fmr_device) return false; if (low_key->fmr_device < high_key->fmr_device) return true; =20 - if (low_key->fmr_physical > high_key->fmr_physical) + if (l_fmr_phys > high_key->fmr_physical) return false; - if (low_key->fmr_physical < high_key->fmr_physical) + if (l_fmr_phys < high_key->fmr_physical) return true; =20 if (low_key->fmr_owner > high_key->fmr_owner) @@ -604,6 +607,36 @@ static bool ext4_getfsmap_check_keys(struct ext4_fsmap= *low_key, return false; } =20 +int ext4_fsmap_check_head(struct super_block *sb, + const struct fsmap_head *head) +{ + const struct fsmap *l =3D &head->fmh_keys[0]; + const struct fsmap *h =3D &head->fmh_keys[1]; + + if (memchr_inv(head->fmh_reserved, 0, sizeof(head->fmh_reserved)) || + memchr_inv(l->fmr_reserved, 0, sizeof(l->fmr_reserved)) || + memchr_inv(h->fmr_reserved, 0, sizeof(h->fmr_reserved))) + return -EINVAL; + /* + * ext4 doesn't report file extents at all, so the only valid + * file offsets are the magic ones (all zeroes or all ones). + */ + if (l->fmr_offset || (h->fmr_offset !=3D 0 && h->fmr_offset !=3D -1ULL)) + return -EINVAL; + + if (head->fmh_iflags & ~FMH_IF_VALID) + return -EINVAL; + + if (!ext4_getfsmap_is_valid_device(sb, l) || + !ext4_getfsmap_is_valid_device(sb, h)) + return -EINVAL; + + if (!ext4_getfsmap_check_keys(l, h)) + return -EINVAL; + + return 0; +} + #define EXT4_GETFSMAP_DEVS 2 /* * Get filesystem's extents as described in head, and format for @@ -635,12 +668,6 @@ int ext4_getfsmap(struct super_block *sb, struct ext4_= fsmap_head *head, int i; int error =3D 0; =20 - if (head->fmh_iflags & ~FMH_IF_VALID) - return -EINVAL; - if (!ext4_getfsmap_is_valid_device(sb, &head->fmh_keys[0]) || - !ext4_getfsmap_is_valid_device(sb, &head->fmh_keys[1])) - return -EINVAL; - head->fmh_entries =3D 0; =20 /* Set up our device handlers. */ @@ -673,9 +700,6 @@ int ext4_getfsmap(struct super_block *sb, struct ext4_f= smap_head *head, dkeys[0].fmr_length =3D 0; memset(&dkeys[1], 0xFF, sizeof(struct ext4_fsmap)); =20 - if (!ext4_getfsmap_check_keys(dkeys, &head->fmh_keys[1])) - return -EINVAL; - info.gfi_next_fsblk =3D head->fmh_keys[0].fmr_physical + head->fmh_keys[0].fmr_length; info.gfi_formatter =3D formatter; diff --git a/fs/ext4/fsmap.h b/fs/ext4/fsmap.h index ac642be2302e..8325258def7b 100644 --- a/fs/ext4/fsmap.h +++ b/fs/ext4/fsmap.h @@ -8,6 +8,7 @@ #define __EXT4_FSMAP_H__ =20 struct fsmap; +struct fsmap_head; =20 /* internal fsmap representation */ struct ext4_fsmap { @@ -32,6 +33,8 @@ void ext4_fsmap_from_internal(struct super_block *sb, str= uct fsmap *dest, struct ext4_fsmap *src); void ext4_fsmap_to_internal(struct super_block *sb, struct ext4_fsmap *des= t, struct fsmap *src); +int ext4_fsmap_check_head(struct super_block *sb, + const struct fsmap_head *head); =20 /* fsmap to userspace formatter - copy to user & advance pointer */ typedef int (*ext4_fsmap_format_t)(struct ext4_fsmap *, void *); diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 8067ccda34e4..eb0ecb012e6a 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -874,20 +874,9 @@ static int ext4_ioc_getfsmap(struct super_block *sb, =20 if (copy_from_user(&head, arg, sizeof(struct fsmap_head))) return -EFAULT; - if (memchr_inv(head.fmh_reserved, 0, sizeof(head.fmh_reserved)) || - memchr_inv(head.fmh_keys[0].fmr_reserved, 0, - sizeof(head.fmh_keys[0].fmr_reserved)) || - memchr_inv(head.fmh_keys[1].fmr_reserved, 0, - sizeof(head.fmh_keys[1].fmr_reserved))) - return -EINVAL; - /* - * ext4 doesn't report file extents at all, so the only valid - * file offsets are the magic ones (all zeroes or all ones). - */ - if (head.fmh_keys[0].fmr_offset || - (head.fmh_keys[1].fmr_offset !=3D 0 && - head.fmh_keys[1].fmr_offset !=3D -1ULL)) - return -EINVAL; + error =3D ext4_fsmap_check_head(sb, &head); + if (error) + return error; =20 xhead.fmh_iflags =3D head.fmh_iflags; xhead.fmh_count =3D head.fmh_count; --=20 2.39.2.637.g21b0678d19-goog From nobody Wed Sep 10 21:48:04 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9445DC636D6 for ; Wed, 22 Feb 2023 13:12:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232135AbjBVNMo (ORCPT ); Wed, 22 Feb 2023 08:12:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231837AbjBVNMe (ORCPT ); Wed, 22 Feb 2023 08:12:34 -0500 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDD6F38B7C for ; Wed, 22 Feb 2023 05:12:24 -0800 (PST) Received: by mail-lf1-x131.google.com with SMTP id m7so9876907lfj.8 for ; Wed, 22 Feb 2023 05:12:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=0BsSDzTf9SbFwUJeyYQyh3jBbWhIKnNTZMpy1sOIMAw=; b=sMofeJd9iLw2kOEDQpMnMPpzHOysXOgdR3wH4VnBjWBwy+EK8cm8O0J7jxhjyn7Dt7 77CbVAGYMKonjt7Ex4Tfa19sv8Z2W/OL2Cq7kLub6LZlVWPWFnv19aGhCLMsltXN8tEp /vyczCYN6k0wDiA2SvO9B5tb+A0Zk8RCzXbGykG8oBHLFbKMN2qi4kuf8YY0Ohm6HtHE VHQLjNhtgkTqUrmf1i00BV9Yg91tR1T2/QLVcFp54jGGYNSFTx6KFqaGmVBXJt3D7DFm hTQf0Ge+cb2GDYnf8aC0sGLEo5D7oRucspojLAyHzfa7SQIN8WZv2URm2ee/tNQjFxOK GeOQ== 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=0BsSDzTf9SbFwUJeyYQyh3jBbWhIKnNTZMpy1sOIMAw=; b=hHK58/vzCrLvR15BMYoKUIm43zkp2LbRpFi5OcAVkhsz/SbtE6rW1CVMqgyoGkQuUl FJ1Uvzft2NTGpXGMh1N8Pr0RA+QhoTkP5dIctz5oIWGDYM5igMv8ZQ1wVZDPPys7szj9 f5GHZ3V51XtlRocmvLToKnGfTzkWQ1GCx/veqMzSxMesQBYUIIlhFShszEBIt+AXK8bT H3dt3rVKTj30C3mnv3sagIa4bEOowiaLNn8Gi1kcNlogMRXf6tYBUC0pb/O6Wjgu+pRs zkW3RD+5m6dcAwJFDhuuZyuLMp29DIM7ZafbmlMQys2m4ycPIeVD6C+ZfeqZBZLCGvgX gEbA== X-Gm-Message-State: AO0yUKWb8hmlEMEgdgeosKISklQK/HRrfBa5JuubYGmAZbgmn4NxuVcB D93Ja4Fuo9/4raugTf6rSoqCGg== X-Google-Smtp-Source: AK7set97icoH4gneBTQnKTzfwX04sUGPV+HUluAuLzHIsOe8ud64Si92qBqUkXq6r4BQiI7iXKy2oA== X-Received: by 2002:ac2:544c:0:b0:4b5:3505:d7f9 with SMTP id d12-20020ac2544c000000b004b53505d7f9mr2621363lfn.35.1677071543295; Wed, 22 Feb 2023 05:12:23 -0800 (PST) Received: from ta1.c.googlers.com.com (138.58.228.35.bc.googleusercontent.com. [35.228.58.138]) by smtp.gmail.com with ESMTPSA id y25-20020a2e7d19000000b0029335c12997sm564383ljc.58.2023.02.22.05.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 05:12:22 -0800 (PST) From: Tudor Ambarus To: tytso@mit.edu, darrick.wong@oracle.com, djwong@kernel.org, adilger.kernel@dilger.ca Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, joneslee@google.com, Tudor Ambarus Subject: [PATCH 3/3] ext4: fsmap: Remove duplicated initialization Date: Wed, 22 Feb 2023 13:12:11 +0000 Message-Id: <20230222131211.3898066-4-tudor.ambarus@linaro.org> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog In-Reply-To: <20230222131211.3898066-1-tudor.ambarus@linaro.org> References: <20230222131211.3898066-1-tudor.ambarus@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" All members of struct ext4_fsmap_head were already initialized with zero in the caller, ext4_ioc_getfsmap(), remove duplicated initialization. Signed-off-by: Tudor Ambarus --- fs/ext4/fsmap.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c index a27d9f0967b7..348eaffaa4d8 100644 --- a/fs/ext4/fsmap.c +++ b/fs/ext4/fsmap.c @@ -668,8 +668,6 @@ int ext4_getfsmap(struct super_block *sb, struct ext4_f= smap_head *head, int i; int error =3D 0; =20 - head->fmh_entries =3D 0; - /* Set up our device handlers. */ memset(handlers, 0, sizeof(handlers)); handlers[0].gfd_dev =3D new_encode_dev(sb->s_bdev->bd_dev); --=20 2.39.2.637.g21b0678d19-goog