From: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
To: Josef Bacik <josef@toxicpanda.com>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, nbd@other.debian.org,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
cascardo@canonical.com
Subject: [PATCH] nbd: allocate sufficient space for NBD_CMD_STATUS
Date: Thu, 18 Jun 2020 18:02:40 -0300 [thread overview]
Message-ID: <20200618210240.157566-2-cascardo@canonical.com> (raw)
In-Reply-To: <20200618210240.157566-1-cascardo@canonical.com>
The nest attribute NBD_ATTR_DEVICE_LIST was not accounted for when
allocating the message, resulting in -EMSGSIZE.
As __alloc_skb aligns size requests to SMP_CACHE_BYTES and SLUB will end up
allocating more than requested, this can hardly be reproduced on most
setups.
However, I managed to test this on a 32-bit x86 with 15 entries, by loading
with nbds_max=15. It failed with -EMSGSIZE, while it worked with 14 or 16
entries.
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
---
drivers/block/nbd.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 43cff01a5a67..19551d8ca355 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -2265,6 +2265,7 @@ static int nbd_genl_status(struct sk_buff *skb, struct genl_info *info)
msg_size = nla_total_size(nla_attr_size(sizeof(u32)) +
nla_attr_size(sizeof(u8)));
msg_size *= (index == -1) ? nbd_total_devices : 1;
+ msg_size += nla_total_size(0); /* for NBD_ATTR_DEVICE_LIST */
reply = genlmsg_new(msg_size, GFP_KERNEL);
if (!reply)
--
2.25.1
prev parent reply other threads:[~2020-06-18 21:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-18 21:02 [PATCH] nbd: allocate sufficient space for NBD_CMD_STATUS Thadeu Lima de Souza Cascardo
2020-06-18 21:02 ` Thadeu Lima de Souza Cascardo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200618210240.157566-2-cascardo@canonical.com \
--to=cascardo@canonical.com \
--cc=axboe@kernel.dk \
--cc=josef@toxicpanda.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nbd@other.debian.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox