From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Yogesh <yogi.kernel@gmail.com>,
syzbot+853a6f4dfa3cf37d3aea@syzkaller.appspotmail.com,
Dave Kleikamp <dave.kleikamp@oracle.com>,
Sasha Levin <sashal@kernel.org>,
shaggy@kernel.org, wuhoipok@gmail.com, code@siddh.me,
mudongliangabcd@gmail.com, liushixin2@huawei.com,
jfs-discussion@lists.sourceforge.net, wonguk.lee1023@gmail.com
Subject: [PATCH AUTOSEL 6.4 55/58] fs: jfs: Fix UBSAN: array-index-out-of-bounds in dbAllocDmapLev
Date: Sun, 23 Jul 2023 21:13:23 -0400 [thread overview]
Message-ID: <20230724011338.2298062-55-sashal@kernel.org> (raw)
In-Reply-To: <20230724011338.2298062-1-sashal@kernel.org>
From: Yogesh <yogi.kernel@gmail.com>
[ Upstream commit 4e302336d5ca1767a06beee7596a72d3bdc8d983 ]
Syzkaller reported the following issue:
UBSAN: array-index-out-of-bounds in fs/jfs/jfs_dmap.c:1965:6
index -84 is out of range for type 's8[341]' (aka 'signed char[341]')
CPU: 1 PID: 4995 Comm: syz-executor146 Not tainted 6.4.0-rc6-syzkaller-00037-gb6dad5178cea #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
ubsan_epilogue lib/ubsan.c:217 [inline]
__ubsan_handle_out_of_bounds+0x11c/0x150 lib/ubsan.c:348
dbAllocDmapLev+0x3e5/0x430 fs/jfs/jfs_dmap.c:1965
dbAllocCtl+0x113/0x920 fs/jfs/jfs_dmap.c:1809
dbAllocAG+0x28f/0x10b0 fs/jfs/jfs_dmap.c:1350
dbAlloc+0x658/0xca0 fs/jfs/jfs_dmap.c:874
dtSplitUp fs/jfs/jfs_dtree.c:974 [inline]
dtInsert+0xda7/0x6b00 fs/jfs/jfs_dtree.c:863
jfs_create+0x7b6/0xbb0 fs/jfs/namei.c:137
lookup_open fs/namei.c:3492 [inline]
open_last_lookups fs/namei.c:3560 [inline]
path_openat+0x13df/0x3170 fs/namei.c:3788
do_filp_open+0x234/0x490 fs/namei.c:3818
do_sys_openat2+0x13f/0x500 fs/open.c:1356
do_sys_open fs/open.c:1372 [inline]
__do_sys_openat fs/open.c:1388 [inline]
__se_sys_openat fs/open.c:1383 [inline]
__x64_sys_openat+0x247/0x290 fs/open.c:1383
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f1f4e33f7e9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 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 ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffc21129578 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f1f4e33f7e9
RDX: 000000000000275a RSI: 0000000020000040 RDI: 00000000ffffff9c
RBP: 00007f1f4e2ff080 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f1f4e2ff110
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
</TASK>
The bug occurs when the dbAllocDmapLev()function attempts to access
dp->tree.stree[leafidx + LEAFIND] while the leafidx value is negative.
To rectify this, the patch introduces a safeguard within the
dbAllocDmapLev() function. A check has been added to verify if leafidx is
negative. If it is, the function immediately returns an I/O error, preventing
any further execution that could potentially cause harm.
Tested via syzbot.
Reported-by: syzbot+853a6f4dfa3cf37d3aea@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=ae2f5a27a07ae44b0f17
Signed-off-by: Yogesh <yogi.kernel@gmail.com>
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/jfs/jfs_dmap.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index a3eb1e8269477..455300d38d315 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -1953,6 +1953,9 @@ dbAllocDmapLev(struct bmap * bmp,
if (dbFindLeaf((dmtree_t *) & dp->tree, l2nb, &leafidx))
return -ENOSPC;
+ if (leafidx < 0)
+ return -EIO;
+
/* determine the block number within the file system corresponding
* to the leaf at which free space was found.
*/
--
2.39.2
next prev parent reply other threads:[~2023-07-24 1:22 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-24 1:12 [PATCH AUTOSEL 6.4 01/58] drm/amd/display: Do not set drr on pipe commit Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 02/58] drm/amd/display: Update DTBCLK for DCN32 Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 03/58] drm/scheduler: set entity to NULL in drm_sched_entity_pop_job() Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 04/58] drm/amdgpu: fix calltrace warning in amddrm_buddy_fini Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 05/58] drm/radeon: Fix integer overflow in radeon_cs_parser_init Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 06/58] drm/amdgpu: Fix integer overflow in amdgpu_cs_pass1 Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 07/58] drm/amdgpu: fix memory leak in mes self test Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 08/58] Revert "drm/amd/display: disable SubVP + DRR to prevent underflow" Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 09/58] ALSA: emu10k1: roll up loops in DSP setup code for Audigy Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 10/58] ASoC: Intel: sof_sdw: add quirk for MTL RVP Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 11/58] ASoC: Intel: sof_sdw: add quirk for LNL RVP Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 12/58] PCI: tegra194: Fix possible array out of bounds access Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 13/58] ASoC: cs35l56: Move DSP part string generation so that it is done only once Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 14/58] iommu: Make __iommu_group_set_domain() handle error unwind Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 15/58] ASoC: SOF: amd: Add pci revision id check Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 16/58] drm/stm: ltdc: fix late dereference check Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 17/58] arm64: dts: qcom: ipq5332: add QFPROM node Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 18/58] drm: rcar-du: remove R-Car H3 ES1.* workarounds Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 19/58] ASoC: amd: vangogh: Add check for acp config flags in vangogh platform Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 20/58] RDMA/mana_ib: Use v2 version of cfg_rx_steer_req to enable RX coalescing Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 21/58] ARM: dts: imx6dl: prtrvt, prtvt7, prti6q, prtwd2: fix USB related warnings Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 22/58] ASoC: Intel: sof_sdw_rt_sdca_jack_common: test SOF_JACK_JDSRC in _exit Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 23/58] ASoC: Intel: sof_sdw: add quick for Dell SKU 0BDA Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 24/58] ASoC: Intel: sof_sdw: Add support for Rex soundwire Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 25/58] iopoll: Call cpu_relax() in busy loops Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 26/58] quota: Properly disable quotas when add_dquot_ref() fails Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 27/58] quota: fix warning in dqgrab() Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 28/58] ALSA: hda: Add Loongson LS7A HD-Audio support Sasha Levin
2023-07-24 3:00 ` Yanteng Si
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 29/58] ASoC: SOF: Intel: fix SoundWire/HDaudio mutual exclusion Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 30/58] dma-remap: use kvmalloc_array/kvfree for larger dma memory remap Sasha Levin
2023-07-24 1:12 ` [PATCH AUTOSEL 6.4 31/58] accel/habanalabs: add pci health check during heartbeat Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 32/58] accel/habanalabs: fix mem leak in capture user mappings Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 33/58] hwmon: (aquacomputer_d5next) Add support for Aquacomputer Leakshield Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 34/58] dt-bindings: input: goodix: Add "goodix,no-reset-during-suspend" property Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 35/58] HID: i2c-hid: goodix: Add support for " Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 36/58] HID: logitech-hidpp: Add USB and Bluetooth IDs for the Logitech G915 TKL Keyboard Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 37/58] iommu/amd: Introduce Disable IRTE Caching Support Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 38/58] drm/amdgpu: install stub fence into potential unused fence pointers Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 39/58] drm/amd/display: Remove v_startup workaround for dcn3+ Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 40/58] drm/amd/display: Trigger DIO FIFO resync on commit streams Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 41/58] drm/amd/display: Apply 60us prefetch for DCFCLK <= 300Mhz Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 42/58] Revert "drm/amd/display: Do not set drr on pipe commit" Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 43/58] HID: add quirk for 03f0:464a HP Elite Presenter Mouse Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 44/58] drm/amd/pm: Fill metrics data for SMUv13.0.6 Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 45/58] drm/amdgpu: unmap and remove csa_va properly Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 46/58] RDMA/mlx5: Return the firmware result upon destroying QP/RQ Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 47/58] RDMA/bnxt_re: consider timeout of destroy ah as success Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 48/58] drm/amd/display: Skip DPP DTO update if root clock is gated Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 49/58] drm/amd/display: Enable dcn314 DPP RCO Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 50/58] ASoC: SOF: core: Free the firmware trace before calling snd_sof_shutdown() Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 51/58] ovl: check type and offset of struct vfsmount in ovl_entry Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 52/58] HID: intel-ish-hid: ipc: Add Arrow Lake PCI device ID Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 53/58] udf: Fix uninitialized array access for some pathnames Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 54/58] ALSA: hda/realtek: Add quirks for ROG ALLY CS35l41 audio Sasha Levin
2023-07-24 1:13 ` Sasha Levin [this message]
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 56/58] MIPS: dec: prom: Address -Warray-bounds warning Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 57/58] FS: JFS: Fix null-ptr-deref Read in txBegin Sasha Levin
2023-07-24 1:13 ` [PATCH AUTOSEL 6.4 58/58] FS: JFS: Check for read-only mounted filesystem " Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230724011338.2298062-55-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=code@siddh.me \
--cc=dave.kleikamp@oracle.com \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=liushixin2@huawei.com \
--cc=mudongliangabcd@gmail.com \
--cc=shaggy@kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+853a6f4dfa3cf37d3aea@syzkaller.appspotmail.com \
--cc=wonguk.lee1023@gmail.com \
--cc=wuhoipok@gmail.com \
--cc=yogi.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox