stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Stephane Grosjean <s.grosjean@peak-system.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	Sasha Levin <sashal@kernel.org>
Subject: Re: [PATCH 4.19 019/101] can: peak_usb: add range checking in decode operations
Date: Wed, 18 Nov 2020 23:05:45 +0100	[thread overview]
Message-ID: <20201118220545.GB23840@amd> (raw)
In-Reply-To: <20201117122114.030656831@linuxfoundation.org>

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]

HI!

> From: Dan Carpenter <dan.carpenter@oracle.com>
> 
> [ Upstream commit a6921dd524fe31d1f460c161d3526a407533b6db ]
> 
> These values come from skb->data so Smatch considers them untrusted.  I
> believe Smatch is correct but I don't have a way to test this.
> 
> The usb_if->dev[] array has 2 elements but the index is in the 0-15
> range without checks.  The cfd->len can be up to 255 but the maximum
> valid size is CANFD_MAX_DLEN (64) so that could lead to memory
> corruption.

If this is untrusted, does it need to use _nospec() variants?

> index 41988358f63c8..19600d35aac55 100644
> --- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
> @@ -476,12 +476,18 @@ static int pcan_usb_fd_decode_canmsg(struct pcan_usb_fd_if *usb_if,
>  				     struct pucan_msg *rx_msg)
>  {
...
>  	const u16 rx_msg_flags = le16_to_cpu(rm->flags);
>  
> +	if (pucan_msg_get_channel(rm) >= ARRAY_SIZE(usb_if->dev))
> +		return -ENOMEM;

Furthermore, should it use -EINVAL here

> +	if (pucan_stmsg_get_channel(sm) >= ARRAY_SIZE(usb_if->dev))
> +		return -ENOMEM;

and here, and perhaps use a helper function?

Best regards,
								Pavel

-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2020-11-18 22:05 UTC|newest]

Thread overview: 110+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-17 13:04 [PATCH 4.19 000/101] 4.19.158-rc1 review Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 001/101] regulator: defer probe when trying to get voltage from unresolved supply Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 002/101] time: Prevent undefined behaviour in timespec64_to_ns() Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 003/101] nbd: dont update block size after device is started Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 004/101] usb: dwc3: gadget: Continue to process pending requests Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 005/101] usb: dwc3: gadget: Reclaim extra TRBs after request completion Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 006/101] btrfs: sysfs: init devices outside of the chunk_mutex Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 007/101] btrfs: reschedule when cloning lots of extents Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 008/101] genirq: Let GENERIC_IRQ_IPI select IRQ_DOMAIN_HIERARCHY Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 009/101] hv_balloon: disable warning when floor reached Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 010/101] net: xfrm: fix a race condition during allocing spi Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 011/101] xfs: set xefi_discard when creating a deferred agfl free log intent item Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 012/101] netfilter: ipset: Update byte and packet counters regardless of whether they match Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 013/101] perf tools: Add missing swap for ino_generation Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 014/101] ALSA: hda: prevent undefined shift in snd_hdac_ext_bus_get_link() Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 015/101] can: rx-offload: dont call kfree_skb() from IRQ context Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 016/101] can: dev: can_get_echo_skb(): prevent call to kfree_skb() in hard " Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 017/101] can: dev: __can_get_echo_skb(): fix real payload length return value for RTR frames Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 018/101] can: can_create_echo_skb(): fix echo skb generation: always use skb_clone() Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 019/101] can: peak_usb: add range checking in decode operations Greg Kroah-Hartman
2020-11-18 22:05   ` Pavel Machek [this message]
2020-11-17 13:04 ` [PATCH 4.19 020/101] can: peak_usb: peak_usb_get_ts_time(): fix timestamp wrapping Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 021/101] can: peak_canfd: pucan_handle_can_rx(): fix echo management when loopback is on Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 022/101] can: flexcan: remove FLEXCAN_QUIRK_DISABLE_MECR quirk for LS1021A Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 023/101] xfs: flush new eof page on truncate to avoid post-eof corruption Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 024/101] xfs: fix scrub flagging rtinherit even if there is no rt device Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 025/101] tpm: efi: Dont create binary_bios_measurements file for an empty log Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 026/101] Btrfs: fix missing error return if writeback for extent buffer never started Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 027/101] ath9k_htc: Use appropriate rs_datalen type Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 028/101] netfilter: use actual socket sk rather than skb sk when routing harder Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 029/101] crypto: arm64/aes-modes - get rid of literal load of addend vector Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 030/101] usb: gadget: goku_udc: fix potential crashes in probe Greg Kroah-Hartman
2020-11-17 13:04 ` [PATCH 4.19 031/101] ALSA: hda: Reinstate runtime_allow() for all hda controllers Greg Kroah-Hartman
2020-11-18 10:43   ` Pavel Machek
2020-11-18 13:40     ` Sasha Levin
2020-11-17 13:04 ` [PATCH 4.19 032/101] gfs2: Free rd_bits later in gfs2_clear_rgrpd to fix use-after-free Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 033/101] gfs2: Add missing truncate_inode_pages_final for sd_aspace Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 034/101] gfs2: check for live vs. read-only file system in gfs2_fitrim Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 035/101] scsi: hpsa: Fix memory leak in hpsa_init_one() Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 036/101] drm/amdgpu: perform srbm soft reset always on SDMA resume Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 037/101] drm/amd/pm: perform SMC reset on suspend/hibernation Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 038/101] drm/amd/pm: do not use ixFEATURE_STATUS for checking smc running Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 039/101] mac80211: fix use of skb payload instead of header Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 040/101] mac80211: always wind down STA state Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 041/101] cfg80211: regulatory: Fix inconsistent format argument Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 042/101] scsi: scsi_dh_alua: Avoid crash during alua_bus_detach() Greg Kroah-Hartman
2020-11-18 22:17   ` Pavel Machek
2020-11-17 13:05 ` [PATCH 4.19 043/101] iommu/amd: Increase interrupt remapping table limit to 512 entries Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 044/101] s390/smp: move rcu_cpu_starting() earlier Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 045/101] vfio: platform: fix reference leak in vfio_platform_open Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 046/101] selftests: proc: fix warning: _GNU_SOURCE redefined Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 047/101] tpm_tis: Disable interrupts on ThinkPad T490s Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 048/101] tick/common: Touch watchdog in tick_unfreeze() on all CPUs Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 049/101] mfd: sprd: Add wakeup capability for PMIC IRQ Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 050/101] pinctrl: intel: Set default bias in case no particular value given Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 051/101] ARM: 9019/1: kprobes: Avoid fortify_panic() when copying optprobe template Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 052/101] pinctrl: aspeed: Fix GPI only function problem Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 053/101] nbd: fix a block_device refcount leak in nbd_release Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 054/101] xfs: fix flags argument to rmap lookup when converting shared file rmaps Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 055/101] xfs: set the unwritten bit in rmap lookup flags in xchk_bmap_get_rmapextents Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 056/101] xfs: fix rmap key and record comparison functions Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 057/101] xfs: fix brainos in the refcount scrubbers rmap fragment processor Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 058/101] lan743x: fix "BUG: invalid wait context" when setting rx mode Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 059/101] xfs: fix a missing unlock on error in xfs_fs_map_blocks Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 060/101] of/address: Fix of_node memory leak in of_dma_is_coherent Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 061/101] cosa: Add missing kfree in error path of cosa_write Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 062/101] perf: Fix get_recursion_context() Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 063/101] ext4: correctly report "not supported" for {usr,grp}jquota when !CONFIG_QUOTA Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 064/101] ext4: unlock xattr_sem properly in ext4_inline_data_truncate() Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 065/101] btrfs: ref-verify: fix memory leak in btrfs_ref_tree_mod Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 066/101] btrfs: dev-replace: fail mount if we dont have replace item with target device Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 067/101] thunderbolt: Fix memory leak if ida_simple_get() fails in enumerate_services() Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 068/101] thunderbolt: Add the missed ida_simple_remove() in ring_request_msix() Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 069/101] uio: Fix use-after-free in uio_unregister_device() Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 070/101] usb: cdc-acm: Add DISABLE_ECHO for Renesas USB Download mode Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 071/101] xhci: hisilicon: fix refercence leak in xhci_histb_probe Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 072/101] mei: protect mei_cl_mtu from null dereference Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 073/101] futex: Dont enable IRQs unconditionally in put_pi_state() Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 074/101] ocfs2: initialize ip_next_orphan Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 075/101] btrfs: fix potential overflow in cluster_pages_for_defrag on 32bit arch Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 076/101] selinux: Fix error return code in sel_ib_pkey_sid_slow() Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 077/101] gpio: pcie-idio-24: Fix irq mask when masking Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 078/101] gpio: pcie-idio-24: Fix IRQ Enable Register value Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 079/101] gpio: pcie-idio-24: Enable PEX8311 interrupts Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 080/101] mmc: renesas_sdhi_core: Add missing tmio_mmc_host_free() at remove Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 081/101] dont dump the threads that had been already exiting when zapped Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 082/101] drm/gma500: Fix out-of-bounds access to struct drm_device.vblank[] Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 083/101] pinctrl: amd: use higher precision for 512 RtcClk Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 084/101] pinctrl: amd: fix incorrect way to disable debounce filter Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 085/101] erofs: derive atime instead of leaving it empty Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 086/101] swiotlb: fix "x86: Dont panic if can not alloc buffer for swiotlb" Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 087/101] IPv6: Set SIT tunnel hard_header_len to zero Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 088/101] net/af_iucv: fix null pointer dereference on shutdown Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 089/101] net: Update window_clamp if SOCK_RCVBUF is set Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 090/101] net/x25: Fix null-ptr-deref in x25_connect Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 091/101] tipc: fix memory leak in tipc_topsrv_start() Greg Kroah-Hartman
2020-11-17 13:05 ` [PATCH 4.19 092/101] vrf: Fix fast path output packet handling with async Netfilter rules Greg Kroah-Hartman
2020-11-17 13:06 ` [PATCH 4.19 093/101] r8169: fix potential skb double free in an error path Greg Kroah-Hartman
2020-11-17 13:06 ` [PATCH 4.19 094/101] random32: make prandom_u32() output unpredictable Greg Kroah-Hartman
2020-11-17 13:06 ` [PATCH 4.19 095/101] x86/speculation: Allow IBPB to be conditionally enabled on CPUs with always-on STIBP Greg Kroah-Hartman
2020-11-17 13:06 ` [PATCH 4.19 096/101] perf scripting python: Avoid declaring function pointers with a visibility attribute Greg Kroah-Hartman
2020-11-17 13:06 ` [PATCH 4.19 097/101] perf/core: Fix race in the perf_mmap_close() function Greg Kroah-Hartman
2020-11-17 13:06 ` [PATCH 4.19 098/101] Revert "kernel/reboot.c: convert simple_strtoul to kstrtoint" Greg Kroah-Hartman
2020-11-17 13:06 ` [PATCH 4.19 099/101] reboot: fix overflow parsing reboot cpu number Greg Kroah-Hartman
2020-11-17 13:06 ` [PATCH 4.19 100/101] net: sch_generic: fix the missing new qdisc assignment bug Greg Kroah-Hartman
2020-11-17 13:06 ` [PATCH 4.19 101/101] Convert trailing spaces and periods in path components Greg Kroah-Hartman
2020-11-17 19:09 ` [PATCH 4.19 000/101] 4.19.158-rc1 review Jon Hunter
2020-11-17 22:05 ` Shuah Khan
2020-11-18  7:57 ` Naresh Kamboju
2020-11-18 15:23 ` Guenter Roeck

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=20201118220545.GB23840@amd \
    --to=pavel@ucw.cz \
    --cc=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=s.grosjean@peak-system.com \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /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).