stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev,
	Nikita Zhandarovich <n.zhandarovich@fintech.ru>,
	Ido Schimmel <idosch@nvidia.com>, Paolo Abeni <pabeni@redhat.com>,
	Sasha Levin <sashal@kernel.org>,
	Natalia Petrova <n.petrova@fintech.ru>
Subject: [PATCH 4.19 06/29] mlxfw: fix null-ptr-deref in mlxfw_mfa2_tlv_next()
Date: Mon, 24 Apr 2023 15:18:33 +0200	[thread overview]
Message-ID: <20230424131121.365613893@linuxfoundation.org> (raw)
In-Reply-To: <20230424131121.155649464@linuxfoundation.org>

From: Nikita Zhandarovich <n.zhandarovich@fintech.ru>

[ Upstream commit c0e73276f0fcbbd3d4736ba975d7dc7a48791b0c ]

Function mlxfw_mfa2_tlv_multi_get() returns NULL if 'tlv' in
question does not pass checks in mlxfw_mfa2_tlv_payload_get(). This
behaviour may lead to NULL pointer dereference in 'multi->total_len'.
Fix this issue by testing mlxfw_mfa2_tlv_multi_get()'s return value
against NULL.

Found by Linux Verification Center (linuxtesting.org) with static
analysis tool SVACE.

Fixes: 410ed13cae39 ("Add the mlxfw module for Mellanox firmware flash process")
Co-developed-by: Natalia Petrova <n.petrova@fintech.ru>
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://lore.kernel.org/r/20230417120718.52325-1-n.zhandarovich@fintech.ru
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.c b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.c
index 0094b92a233ba..31c0d6ee81b16 100644
--- a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.c
+++ b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.c
@@ -62,6 +62,8 @@ mlxfw_mfa2_tlv_next(const struct mlxfw_mfa2_file *mfa2_file,
 
 	if (tlv->type == MLXFW_MFA2_TLV_MULTI_PART) {
 		multi = mlxfw_mfa2_tlv_multi_get(mfa2_file, tlv);
+		if (!multi)
+			return NULL;
 		tlv_len = NLA_ALIGN(tlv_len + be16_to_cpu(multi->total_len));
 	}
 
-- 
2.39.2




  parent reply	other threads:[~2023-04-24 13:39 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24 13:18 [PATCH 4.19 00/29] 4.19.282-rc1 review Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 01/29] ARM: dts: rockchip: fix a typo error for rk3288 spdif node Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 02/29] net: sched: sch_qfq: prevent slab-out-of-bounds in qfq_activate_agg Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 03/29] virtio_net: bugfix overflow inside xdp_linearize_page() Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 04/29] i40e: fix accessing vsi->active_filters without holding lock Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 05/29] i40e: fix i40e_setup_misc_vector() error handling Greg Kroah-Hartman
2023-04-24 13:18 ` Greg Kroah-Hartman [this message]
2023-04-24 13:18 ` [PATCH 4.19 07/29] e1000e: Disable TSO on i219-LM card to increase speed Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 08/29] f2fs: Fix f2fs_truncate_partial_nodes ftrace event Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 09/29] Input: i8042 - add quirk for Fujitsu Lifebook A574/H Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 10/29] selftests: sigaltstack: fix -Wuninitialized Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 11/29] scsi: megaraid_sas: Fix fw_crash_buffer_show() Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 12/29] scsi: core: Improve scsi_vpd_inquiry() checks Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 13/29] net: dsa: b53: mmap: add phy ops Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 14/29] s390/ptrace: fix PTRACE_GET_LAST_BREAK error handling Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 15/29] xen/netback: use same error messages for same errors Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 16/29] nilfs2: initialize unused bytes in segment summary blocks Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 17/29] memstick: fix memory leak if card device is never registered Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 18/29] x86/purgatory: Dont generate debug info for purgatory.ro Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 19/29] Revert "ext4: fix use-after-free in ext4_xattr_set_entry" Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 20/29] ext4: remove duplicate definition of ext4_xattr_ibody_inline_set() Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 21/29] ext4: fix use-after-free in ext4_xattr_set_entry Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 22/29] udp: Call inet6_destroy_sock() in setsockopt(IPV6_ADDRFORM) Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 23/29] tcp/udp: Call inet6_destroy_sock() in IPv6 sk->sk_destruct() Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 24/29] inet6: Remove inet6_destroy_sock() in sk->sk_prot->destroy() Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 25/29] dccp: Call inet6_destroy_sock() via sk->sk_destruct() Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 26/29] sctp: " Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 27/29] counter: 104-quad-8: Fix race condition between FLAG and CNTR reads Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 28/29] iio: adc: at91-sama5d2_adc: fix an error code in at91_adc_allocate_trigger() Greg Kroah-Hartman
2023-04-24 13:18 ` [PATCH 4.19 29/29] ASN.1: Fix check for strdup() success Greg Kroah-Hartman
2023-04-25  1:04 ` [PATCH 4.19 00/29] 4.19.282-rc1 review Guenter Roeck
2023-04-25 10:02 ` Naresh Kamboju
2023-04-26 19:47   ` Pavel Machek
2023-04-26 21:09   ` Steven Rostedt
2023-04-26 22:14     ` Steven Rostedt
2023-04-27  9:49       ` Naresh Kamboju
2023-10-11  1:29         ` Naresh Kamboju
2023-10-11  9:04           ` Greg Kroah-Hartman
2023-10-11  9:05             ` Greg Kroah-Hartman
2023-10-11 14:45               ` Steven Rostedt
2023-10-12 11:53                 ` Naresh Kamboju
2023-10-15 17:50                   ` Greg Kroah-Hartman
2023-04-25 13:39 ` Chris Paterson
2023-04-26  0:32 ` 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=20230424131121.365613893@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=idosch@nvidia.com \
    --cc=n.petrova@fintech.ru \
    --cc=n.zhandarovich@fintech.ru \
    --cc=pabeni@redhat.com \
    --cc=patches@lists.linux.dev \
    --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).