netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i40e: Add checking for null for nlmsg_find_attr()
@ 2023-01-25 14:13 Natalia Petrova
  2023-01-25 15:08 ` Simon Horman
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Natalia Petrova @ 2023-01-25 14:13 UTC (permalink / raw)
  To: Jesse Brandeburg
  Cc: Natalia Petrova, Tony Nguyen, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, intel-wired-lan, netdev,
	linux-kernel, lvc-project

The result of nlmsg_find_attr() 'br_spec' is dereferenced in
nla_for_each_nested, but it can take null value in 'nla_find' finction,
which will result in an error.

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

Fixes: 51616018dd1b ("i40e: Add support for getlink, setlink ndo ops")
Signed-off-by: Natalia Petrova <n.petrova@fintech.ru>
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index b36bf9c3e1e4..ed4be4ffeb09 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -13101,6 +13101,8 @@ static int i40e_ndo_bridge_setlink(struct net_device *dev,
 	}
 
 	br_spec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC);
+	if (!br_spec)
+		return -ENOENT;
 
 	nla_for_each_nested(attr, br_spec, rem) {
 		__u16 mode;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-02-07 10:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-25 14:13 [PATCH] i40e: Add checking for null for nlmsg_find_attr() Natalia Petrova
2023-01-25 15:08 ` Simon Horman
2023-01-25 20:09 ` [Intel-wired-lan] " Paul Menzel
2023-01-30 22:11 ` [PATCH v2] " Natalia Petrova
2023-01-31  5:17   ` Greg Kroah-Hartman
2023-01-31 16:23     ` Simon Horman
2023-02-01  9:06 ` [PATCH v3] " Natalia Petrova
2023-02-02 17:23   ` Tony Nguyen
2023-02-07 10:48   ` [Intel-wired-lan] " G, GurucharanX

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).