Message ID | 20240218042534.it.206-kees@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v4] nbd: null check for nla_nest_start | expand |
On Sat, 17 Feb 2024 20:25:38 -0800, Kees Cook wrote: > 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,
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 33a8f37bb6a1..b7c332528ed7 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -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) {