From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev,
Stefan Wiehler <stefan.wiehler@nokia.com>,
"Rob Herring (Arm)" <robh@kernel.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.19 71/96] of/irq: Prevent device address out-of-bounds read in interrupt map walk
Date: Tue, 10 Sep 2024 11:32:13 +0200 [thread overview]
Message-ID: <20240910092544.674877191@linuxfoundation.org> (raw)
In-Reply-To: <20240910092541.383432924@linuxfoundation.org>
4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Wiehler <stefan.wiehler@nokia.com>
[ Upstream commit b739dffa5d570b411d4bdf4bb9b8dfd6b7d72305 ]
When of_irq_parse_raw() is invoked with a device address smaller than
the interrupt parent node (from #address-cells property), KASAN detects
the following out-of-bounds read when populating the initial match table
(dyndbg="func of_irq_parse_* +p"):
OF: of_irq_parse_one: dev=/soc@0/picasso/watchdog, index=0
OF: parent=/soc@0/pci@878000000000/gpio0@17,0, intsize=2
OF: intspec=4
OF: of_irq_parse_raw: ipar=/soc@0/pci@878000000000/gpio0@17,0, size=2
OF: -> addrsize=3
==================================================================
BUG: KASAN: slab-out-of-bounds in of_irq_parse_raw+0x2b8/0x8d0
Read of size 4 at addr ffffff81beca5608 by task bash/764
CPU: 1 PID: 764 Comm: bash Tainted: G O 6.1.67-484c613561-nokia_sm_arm64 #1
Hardware name: Unknown Unknown Product/Unknown Product, BIOS 2023.01-12.24.03-dirty 01/01/2023
Call trace:
dump_backtrace+0xdc/0x130
show_stack+0x1c/0x30
dump_stack_lvl+0x6c/0x84
print_report+0x150/0x448
kasan_report+0x98/0x140
__asan_load4+0x78/0xa0
of_irq_parse_raw+0x2b8/0x8d0
of_irq_parse_one+0x24c/0x270
parse_interrupts+0xc0/0x120
of_fwnode_add_links+0x100/0x2d0
fw_devlink_parse_fwtree+0x64/0xc0
device_add+0xb38/0xc30
of_device_add+0x64/0x90
of_platform_device_create_pdata+0xd0/0x170
of_platform_bus_create+0x244/0x600
of_platform_notify+0x1b0/0x254
blocking_notifier_call_chain+0x9c/0xd0
__of_changeset_entry_notify+0x1b8/0x230
__of_changeset_apply_notify+0x54/0xe4
of_overlay_fdt_apply+0xc04/0xd94
...
The buggy address belongs to the object at ffffff81beca5600
which belongs to the cache kmalloc-128 of size 128
The buggy address is located 8 bytes inside of
128-byte region [ffffff81beca5600, ffffff81beca5680)
The buggy address belongs to the physical page:
page:00000000230d3d03 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1beca4
head:00000000230d3d03 order:1 compound_mapcount:0 compound_pincount:0
flags: 0x8000000000010200(slab|head|zone=2)
raw: 8000000000010200 0000000000000000 dead000000000122 ffffff810000c300
raw: 0000000000000000 0000000000200020 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffffff81beca5500: 04 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffffff81beca5580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffffff81beca5600: 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
^
ffffff81beca5680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffffff81beca5700: 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc
==================================================================
OF: -> got it !
Prevent the out-of-bounds read by copying the device address into a
buffer of sufficient size.
Signed-off-by: Stefan Wiehler <stefan.wiehler@nokia.com>
Link: https://lore.kernel.org/r/20240812100652.3800963-1-stefan.wiehler@nokia.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/of/irq.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 02ad93a304a4..f06c9df60e34 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -289,7 +289,8 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar
struct device_node *p;
const __be32 *addr;
u32 intsize;
- int i, res;
+ int i, res, addr_len;
+ __be32 addr_buf[3] = { 0 };
pr_debug("of_irq_parse_one: dev=%pOF, index=%d\n", device, index);
@@ -298,13 +299,19 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar
return of_irq_parse_oldworld(device, index, out_irq);
/* Get the reg property (if any) */
- addr = of_get_property(device, "reg", NULL);
+ addr = of_get_property(device, "reg", &addr_len);
+
+ /* Prevent out-of-bounds read in case of longer interrupt parent address size */
+ if (addr_len > (3 * sizeof(__be32)))
+ addr_len = 3 * sizeof(__be32);
+ if (addr)
+ memcpy(addr_buf, addr, addr_len);
/* Try the new-style interrupts-extended first */
res = of_parse_phandle_with_args(device, "interrupts-extended",
"#interrupt-cells", index, out_irq);
if (!res)
- return of_irq_parse_raw(addr, out_irq);
+ return of_irq_parse_raw(addr_buf, out_irq);
/* Look for the interrupt parent. */
p = of_irq_find_parent(device);
@@ -334,7 +341,7 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar
/* Check if there are any interrupt-map translations to process */
- res = of_irq_parse_raw(addr, out_irq);
+ res = of_irq_parse_raw(addr_buf, out_irq);
out:
of_node_put(p);
return res;
--
2.43.0
next prev parent reply other threads:[~2024-09-10 9:40 UTC|newest]
Thread overview: 98+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-10 9:31 [PATCH 4.19 00/96] 4.19.322-rc1 review Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 01/96] net: usb: qmi_wwan: add MeiG Smart SRM825L Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 02/96] usb: dwc3: st: Add of_node_put() before return in probe function Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 03/96] usb: dwc3: st: add missing depopulate in probe error path Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 04/96] drm/amdgpu: Fix uninitialized variable warning in amdgpu_afmt_acr Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 05/96] drm/amdgpu: fix overflowed array index read warning Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 06/96] drm/amdgpu: fix ucode out-of-bounds " Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 07/96] drm/amdgpu: fix mc_data " Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 08/96] drm/amdkfd: Reconcile the definition and use of oem_id in struct kfd_topology_device Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 09/96] apparmor: fix possible NULL pointer dereference Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 10/96] usbip: Dont submit special requests twice Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 11/96] smack: tcp: ipv4, fix incorrect labeling Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 12/96] media: uvcvideo: Enforce alignment of frame and interval Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 13/96] block: initialize integrity buffer to zero before writing it to media Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 14/96] virtio_net: Fix napi_skb_cache_put warning Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 15/96] udf: Limit file size to 4TB Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 16/96] ALSA: usb-audio: Sanity checks for each pipe and EP types Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 17/96] ALSA: usb-audio: Fix gpf in snd_usb_pipe_sanity_check Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 18/96] sch/netem: fix use after free in netem_dequeue Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 19/96] ALSA: hda/conexant: Add pincfg quirk to enable top speakers on Sirius devices Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 20/96] ata: libata: Fix memory leak for error path in ata_host_alloc() Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 21/96] mmc: dw_mmc: Fix IDMAC operation with pages bigger than 4K Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 22/96] fuse: use unsigned type for getxattr/listxattr size truncation Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 23/96] clk: qcom: clk-alpha-pll: Fix the pll post div mask Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 24/96] nilfs2: fix missing cleanup on rollforward recovery error Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 25/96] nilfs2: fix state management in error path of log writing function Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 26/96] ALSA: hda: Add input value sanity checks to HDMI channel map controls Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 27/96] smack: unix sockets: fix accept()ed socket label Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 28/96] irqchip/armada-370-xp: Do not allow mapping IRQ 0 and 1 Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 29/96] af_unix: Remove put_pid()/put_cred() in copy_peercred() Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 30/96] netfilter: nf_conncount: fix wrong variable type Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 31/96] udf: Avoid excessive partition lengths Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 32/96] wifi: brcmsmac: advertise MFP_CAPABLE to enable WPA3 Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 33/96] media: qcom: camss: Add check for v4l2_fwnode_endpoint_parse Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 34/96] pcmcia: Use resource_size function on resource object Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 35/96] can: bcm: Remove proc entry when dev is unregistered Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 36/96] igb: Fix not clearing TimeSync interrupts for 82580 Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 37/96] platform/x86: dell-smbios: Fix error path in dell_smbios_init() Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 38/96] cx82310_eth: re-enable ethernet mode after router reboot Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 39/96] drivers/net/usb: Remove all strcpy() uses Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 40/96] net: usb: dont write directly to netdev->dev_addr Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 41/96] usbnet: modern method to get random MAC Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 42/96] rfkill: fix spelling mistake contidion to condition Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 43/96] net: bridge: add support for sticky fdb entries Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 44/96] bridge: switchdev: Allow clearing FDB entry offload indication Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 45/96] net: bridge: fdb: convert is_local to bitops Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 46/96] net: bridge: fdb: convert is_static " Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 47/96] net: bridge: fdb: convert is_sticky " Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 48/96] net: bridge: fdb: convert added_by_user " Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 49/96] net: bridge: fdb: convert added_by_external_learn to use bitops Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 50/96] net: bridge: br_fdb_external_learn_add(): always set EXT_LEARN Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 51/96] net: dsa: vsc73xx: fix possible subblocks range of CAPT block Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 52/96] iommu/vt-d: Handle volatile descriptor status read Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 53/96] cgroup: Protect css->cgroup write under css_set_lock Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 54/96] um: line: always fill *error_out in setup_one_line() Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 55/96] devres: Initialize an uninitialized struct member Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 56/96] pci/hotplug/pnv_php: Fix hotplug driver crash on Powernv Greg Kroah-Hartman
2024-09-10 9:31 ` [PATCH 4.19 57/96] hwmon: (adc128d818) Fix underflows seen when writing limit attributes Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 58/96] hwmon: (lm95234) " Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 59/96] hwmon: (nct6775-core) " Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 60/96] hwmon: (w83627ehf) " Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 61/96] wifi: mwifiex: Do not return unused priv in mwifiex_get_priv_by_id() Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 62/96] smp: Add missing destroy_work_on_stack() call in smp_call_on_cpu() Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 63/96] btrfs: replace BUG_ON with ASSERT in walk_down_proc() Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 64/96] btrfs: clean up our handling of refs == 0 in snapshot delete Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 65/96] PCI: Add missing bridge lock to pci_bus_lock() Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 66/96] btrfs: initialize location to fix -Wmaybe-uninitialized in btrfs_lookup_dentry() Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 67/96] HID: cougar: fix slab-out-of-bounds Read in cougar_report_fixup Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 68/96] Input: uinput - reject requests with unreasonable number of slots Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 69/96] usbnet: ipheth: race between ipheth_close and error handling Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 70/96] Squashfs: sanity check symbolic link size Greg Kroah-Hartman
2024-09-10 9:32 ` Greg Kroah-Hartman [this message]
2024-09-10 9:32 ` [PATCH 4.19 72/96] ata: pata_macio: Use WARN instead of BUG Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 73/96] iio: buffer-dmaengine: fix releasing dma channel on error Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 74/96] iio: fix scale application in iio_convert_raw_to_processed_unlocked Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 75/96] nvmem: Fix return type of devm_nvmem_device_get() in kerneldoc Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 76/96] uio_hv_generic: Fix kernel NULL pointer dereference in hv_uio_rescind Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 77/96] Drivers: hv: vmbus: Fix rescind handling in uio_hv_generic Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 78/96] VMCI: Fix use-after-free when removing resource in vmci_resource_remove() Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 79/96] clocksource/drivers/imx-tpm: Fix return -ETIME when delta exceeds INT_MAX Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 80/96] clocksource/drivers/imx-tpm: Fix next event not taking effect sometime Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 81/96] uprobes: Use kzalloc to allocate xol area Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 82/96] ring-buffer: Rename ring_buffer_read() to read_buffer_iter_advance() Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 83/96] tracing: Avoid possible softlockup in tracing_iter_reset() Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 84/96] nilfs2: replace snprintf in show functions with sysfs_emit Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 85/96] nilfs2: protect references to superblock parameters exposed in sysfs Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 86/96] netns: add pre_exit method to struct pernet_operations Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 87/96] ila: call nf_unregister_net_hooks() sooner Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 88/96] ACPI: processor: Return an error if acpi_processor_get_info() fails in processor_add() Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 89/96] ACPI: processor: Fix memory leaks in error paths of processor_add() Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 90/96] drm/i915/fence: Mark debug_fence_init_onstack() with __maybe_unused Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 91/96] drm/i915/fence: Mark debug_fence_free() " Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 92/96] rtmutex: Drop rt_mutex::wait_lock before scheduling Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 93/96] net, sunrpc: Remap EPERM in case of connection failure in xs_tcp_setup_socket Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 94/96] cx82310_eth: fix error return code in cx82310_bind() Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 95/96] net: bridge: explicitly zero is_sticky in fdb_create Greg Kroah-Hartman
2024-09-10 9:32 ` [PATCH 4.19 96/96] netns: restore ops before calling ops_exit_list Greg Kroah-Hartman
2024-09-10 23:03 ` [PATCH 4.19 00/96] 4.19.322-rc1 review Shuah Khan
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=20240910092544.674877191@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=patches@lists.linux.dev \
--cc=robh@kernel.org \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=stefan.wiehler@nokia.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;
as well as URLs for NNTP newsgroup(s).