lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250308215605.4774-1-qasdev00@gmail.com>
Date: Sat,  8 Mar 2025 21:56:05 +0000
From: Qasim Ijaz <qasdev00@...il.com>
To: ast@...nel.org,
	daniel@...earbox.net,
	andrii@...nel.org
Cc: martin.lau@...ux.dev,
	eddyz87@...il.com,
	song@...nel.org,
	yonghong.song@...ux.dev,
	john.fastabend@...il.com,
	kpsingh@...nel.org,
	sdf@...ichev.me,
	haoluo@...gle.com,
	jolsa@...nel.org,
	bpf@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH] bpf: add missing NULL check for __dev_get_by_index

The __dev_get_by_index function can return NULL if it fails to 
find a device with the provided ifindex.

We should handle this case by adding a NULL check
and cleaning up if it does happened.

Signed-off-by: Qasim Ijaz <qasdev00@...il.com>
Fixes: a38845729ea3 ("bpf: offload: add map offload infrastructure")
---
 kernel/bpf/offload.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c
index a10153c3be2d..28a30fa4457a 100644
--- a/kernel/bpf/offload.c
+++ b/kernel/bpf/offload.c
@@ -530,6 +530,12 @@ struct bpf_map *bpf_map_offload_map_alloc(union bpf_attr *attr)
 	bpf_map_init_from_attr(&offmap->map, attr);
 	rtnl_lock();
 	offmap->netdev = __dev_get_by_index(net, attr->map_ifindex);
+	if (!offmap->netdev) {
+		rtnl_unlock();
+		bpf_map_area_free(offmap);
+		return ERR_PTR(-ENODEV);
+	}	
+
 	netdev_lock_ops(offmap->netdev);
 	down_write(&bpf_devs_lock);
 	err = bpf_dev_offload_check(offmap->netdev);
-- 
2.39.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ