Skip to contentSkip to conversation

nbd: null check for nla_nest_start

PATCH Applied Kees Cook 2 participants 2 messages Feb 18, 2024

Subsystems (2)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH v4 1/1 nbd: null check for nla_nest_start

From: Navid Emamdoost <[email protected]>

nla_nest_start() may fail and return NULL. Insert a check and set errno based on other call sites within the same source code.

Fixes 47d902b90a32 ("nbd: add a status netlink command")

---
v3- https://lore.kernel.org/lkml/[email protected]/
Resending on behalf of the author. This seems to have gotten lost and has been getting tracked as CVE-2019-16089 ever since. For example:
https://ubuntu.com/security/CVE-2019-16089

---
 drivers/block/nbd.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/block/nbd.c +6 -0
index 33a8f37bb6a1..b7c332528ed7 100644
@@ -2433,6 +2433,12 @@ static int nbd_genl_status(struct sk_buff *skb, struct genl_info *info)
 	}
 
 	dev_list = nla_nest_start_noflag(reply, NBD_ATTR_DEVICE_LIST);
+	if (!dev_list) {
+		nlmsg_free(reply);
+		ret = -EMSGSIZE;
+		goto out;
+	}
+
 	if (index == -1) {
 		ret = idr_for_each(&nbd_index_idr, &status_cb, reply);
 		if (ret) {
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 4 lines · Kees Cook

nla_nest_start() may fail and return NULL. Insert a check and set errno based on other call sites within the same source code.

Applied, thanks!

[1/1] nbd: null check for nla_nest_start

      commit: 31edf4bbe0ba27fd03ac7d87eb2ee3d2a231af6d

Best regards,

Signature · 1 line
Jens Axboe