public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] nbd: null check for nla_nest_start
@ 2024-02-18  4:25 Kees Cook
  2024-02-18 13:01 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2024-02-18  4:25 UTC (permalink / raw)
  To: Josef Bacik
  Cc: Kees Cook, Navid Emamdoost, Michal Kubecek, Jens Axboe,
	linux-kernel, linux-block, nbd, linux-hardening

From: Navid Emamdoost <navid.emamdoost@gmail.com>

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

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Reviewed-by: Michal Kubecek <mkubecek@suse.cz>
Fixes: 47d902b90a32 ("nbd: add a status netlink command")
Signed-off-by: Kees Cook <keescook@chromium.org>
---
v3- https://lore.kernel.org/lkml/20190911164013.27364-1-navid.emamdoost@gmail.com/
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(+)

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) {
-- 
2.34.1


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

* Re: [PATCH v4] nbd: null check for nla_nest_start
  2024-02-18  4:25 [PATCH v4] nbd: null check for nla_nest_start Kees Cook
@ 2024-02-18 13:01 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2024-02-18 13:01 UTC (permalink / raw)
  To: Josef Bacik, Kees Cook
  Cc: Navid Emamdoost, Michal Kubecek, linux-kernel, linux-block, nbd,
	linux-hardening


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,
-- 
Jens Axboe




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

end of thread, other threads:[~2024-02-18 13:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-18  4:25 [PATCH v4] nbd: null check for nla_nest_start Kees Cook
2024-02-18 13:01 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox