* [PATCH] net: ice: Fix potential NULL pointer dereference in ice_bridge_setlink()
@ 2024-02-28 15:54 Rand Deeb
2024-03-01 15:26 ` Simon Horman
0 siblings, 1 reply; 2+ messages in thread
From: Rand Deeb @ 2024-02-28 15:54 UTC (permalink / raw)
To: Jesse Brandeburg, Tony Nguyen, David S . Miller, Jakub Kicinski,
intel-wired-lan, netdev, linux-kernel
Cc: deeb.rand, lvc-project, voskresenski.stanislav, Rand Deeb
The function ice_bridge_setlink() may encounter a NULL pointer dereference
if nlmsg_find_attr() returns NULL and br_spec is dereferenced subsequently
in nla_for_each_nested(). To address this issue, add a check to ensure that
br_spec is not NULL before proceeding with the nested attribute iteration.
Signed-off-by: Rand Deeb <rand.sec96@gmail.com>
---
drivers/net/ethernet/intel/ice/ice_main.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 4f0d63fa5709..ba2bbd53d543 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -6530,6 +6530,8 @@ ice_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,
pf_sw = pf->first_sw;
/* find the attribute in the netlink message */
br_spec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC);
+ if (!br_spec)
+ return -EINVAL;
nla_for_each_nested(attr, br_spec, rem) {
__u16 mode;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] net: ice: Fix potential NULL pointer dereference in ice_bridge_setlink()
2024-02-28 15:54 [PATCH] net: ice: Fix potential NULL pointer dereference in ice_bridge_setlink() Rand Deeb
@ 2024-03-01 15:26 ` Simon Horman
0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2024-03-01 15:26 UTC (permalink / raw)
To: Rand Deeb
Cc: Jesse Brandeburg, Tony Nguyen, David S . Miller, Jakub Kicinski,
intel-wired-lan, netdev, linux-kernel, deeb.rand, lvc-project,
voskresenski.stanislav
On Wed, Feb 28, 2024 at 06:54:48PM +0300, Rand Deeb wrote:
> The function ice_bridge_setlink() may encounter a NULL pointer dereference
> if nlmsg_find_attr() returns NULL and br_spec is dereferenced subsequently
> in nla_for_each_nested(). To address this issue, add a check to ensure that
> br_spec is not NULL before proceeding with the nested attribute iteration.
>
> Signed-off-by: Rand Deeb <rand.sec96@gmail.com>
Thanks Rand,
I do wonder if for some reason this cannot ever occur.
But assuming it can then I agree with the fix.
Reviewed-by: Simon Horman <horms@kernel.org>
As a fix I think it probably warrants a fixes tag and
being applied to net. As such, the following seems appropriate.
Fixes: b1edc14a3fbf ("ice: Implement ice_bridge_getlink and ice_bridge_setlink")
...
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-01 15:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-28 15:54 [PATCH] net: ice: Fix potential NULL pointer dereference in ice_bridge_setlink() Rand Deeb
2024-03-01 15:26 ` Simon Horman
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).