From: "Tobin C. Harding" <me@tobin.cc>
To: Ilya Dryomov <idryomov@gmail.com>, Sage Weil <sage@redhat.com>,
Alex Elder <elder@kernel.org>
Cc: "Tobin C. Harding" <me@tobin.cc>,
ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-hardening@lists.openwall.com,
Tycho Andersen <tycho@tycho.ws>,
Kees Cook <keescook@chromium.org>
Subject: [PATCH] rbd: Remove VLA stack usage
Date: Mon, 12 Mar 2018 15:49:40 +1100 [thread overview]
Message-ID: <1520830180-25452-1-git-send-email-me@tobin.cc> (raw)
The kernel would like to have all stack VLA usage removed[1]. Here the
array is declared using a variable that is declared using a constant
statement but the compiler still emits a warning. We can clear the
warning bu using the constant statement directly. In place of later
usage of the size variable we can use the ARRAY_SIZE() macro.
Use constant statement to declare array.
[1]: https://lkml.org/lkml/2018/3/7/621
Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
drivers/block/rbd.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 0016170cde0a..927ecd9a2511 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -3100,20 +3100,19 @@ static int __rbd_notify_op_lock(struct rbd_device *rbd_dev,
{
struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
struct rbd_client_id cid = rbd_get_cid(rbd_dev);
- int buf_size = 4 + 8 + 8 + CEPH_ENCODING_START_BLK_LEN;
- char buf[buf_size];
+ char buf[4 + 8 + 8 + CEPH_ENCODING_START_BLK_LEN];
void *p = buf;
dout("%s rbd_dev %p notify_op %d\n", __func__, rbd_dev, notify_op);
/* encode *LockPayload NotifyMessage (op + ClientId) */
- ceph_start_encoding(&p, 2, 1, buf_size - CEPH_ENCODING_START_BLK_LEN);
+ ceph_start_encoding(&p, 2, 1, ARRAY_SIZE(buf) - CEPH_ENCODING_START_BLK_LEN);
ceph_encode_32(&p, notify_op);
ceph_encode_64(&p, cid.gid);
ceph_encode_64(&p, cid.handle);
return ceph_osdc_notify(osdc, &rbd_dev->header_oid,
- &rbd_dev->header_oloc, buf, buf_size,
+ &rbd_dev->header_oloc, buf, ARRAY_SIZE(buf),
RBD_NOTIFY_TIMEOUT, preply_pages, preply_len);
}
--
2.7.4
next reply other threads:[~2018-03-12 4:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-12 4:49 Tobin C. Harding [this message]
2018-03-12 5:02 ` Eric Biggers
2018-03-12 5:06 ` Tobin C. Harding
2018-03-12 9:57 ` Ilya Dryomov
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=1520830180-25452-1-git-send-email-me@tobin.cc \
--to=me@tobin.cc \
--cc=ceph-devel@vger.kernel.org \
--cc=elder@kernel.org \
--cc=idryomov@gmail.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sage@redhat.com \
--cc=tycho@tycho.ws \
/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
all inboxes | Powered by JetHome®