linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: nbd: fix a missing check for nla_nest_start
@ 2019-03-15  6:31 Kangjie Lu
  2019-03-15 13:27 ` Josef Bacik
  0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2019-03-15  6:31 UTC (permalink / raw)
  To: kjlu; +Cc: pakki001, Josef Bacik, Jens Axboe, linux-block, nbd, linux-kernel

nla_nest_start may fail and thus deserves a check.

The fix inserts such a check and exits gracefully in case it
fails.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/block/nbd.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 7c9a949e876b..810c8c20b142 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -2099,6 +2099,10 @@ static int nbd_genl_status(struct sk_buff *skb, struct genl_info *info)
 	}
 
 	dev_list = nla_nest_start(reply, NBD_ATTR_DEVICE_LIST);
+	if (!dev_list) {
+		nlmsg_free(reply);
+		goto out;
+	}
 	if (index == -1) {
 		ret = idr_for_each(&nbd_index_idr, &status_cb, reply);
 		if (ret) {
-- 
2.17.1


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

* Re: [PATCH] block: nbd: fix a missing check for nla_nest_start
  2019-03-15  6:31 [PATCH] block: nbd: fix a missing check for nla_nest_start Kangjie Lu
@ 2019-03-15 13:27 ` Josef Bacik
  0 siblings, 0 replies; 2+ messages in thread
From: Josef Bacik @ 2019-03-15 13:27 UTC (permalink / raw)
  To: Kangjie Lu
  Cc: pakki001, Josef Bacik, Jens Axboe, linux-block, nbd, linux-kernel

On Fri, Mar 15, 2019 at 01:31:38AM -0500, Kangjie Lu wrote:
> nla_nest_start may fail and thus deserves a check.
> 
> The fix inserts such a check and exits gracefully in case it
> fails.
> 

Except it won't because we pre-reserve enough space for that attr.  Subsequent
calls could fail, and those are checked properly, but this one won't.  Thanks,

Josef

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

end of thread, other threads:[~2019-03-15 13:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-15  6:31 [PATCH] block: nbd: fix a missing check for nla_nest_start Kangjie Lu
2019-03-15 13:27 ` Josef Bacik

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