From patchwork Mon Mar 12 04:49:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobin Harding X-Patchwork-Id: 10275455 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E8E3660211 for ; Mon, 12 Mar 2018 04:50:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D74D728C88 for ; Mon, 12 Mar 2018 04:50:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC27628C8F; Mon, 12 Mar 2018 04:50:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id EFF0328C8A for ; Mon, 12 Mar 2018 04:50:02 +0000 (UTC) Received: (qmail 23773 invoked by uid 550); 12 Mar 2018 04:50:00 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 23753 invoked from network); 12 Mar 2018 04:49:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobin.cc; h=cc :date:from:message-id:subject:to:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=fY71O/oZVqj7ORjPmj1+SBUiM0AiqJV/d2FT6UTP1 mg=; b=qs/AWPpPmjepZqrZZ2DqZ8sjtx4zZehbK19N8OHp7KRKVkI8SXXQl5wxe jV6vs1r8zxn40v5rHDD/rvILHJsBGtLrzwDhnXq4noLNaf1kA5VogIK+pUbBM8gy 2XDUz9G8S+5nGLmzv4KFOG+XpIo3aqGGBjtFPxZEpRZdGuOf/PQvjAgwI6wqKPWD t8PNMnfU0h/rgP6RAOjVDM95plE/yClAtUBx6CTsD7yRHbSjHQ8onBM8jX3HIblo yFdBvNG9GC9yxUmdJKLPFarE5688KvIXT7Sit5F/SV6LHOJEw0LY4uCXJYvNtVbX qOlTNuE6RebePT0yn+AJexnZmitEA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=fY71O/oZVqj7ORjPm j1+SBUiM0AiqJV/d2FT6UTP1mg=; b=Rl4VIvQZVeBGMZn4Zt+XDtYqbsCwFwmUg Qz7AG8C+or8TH1C+p4dF6Qpzi9Hz+ydkTr6VmOyImPX+PjUyGKCMlp/Hex2FpSpr tFQzy2XCOpH+J/U8hSZ8lshZMQg6YMoTKVReaTZSEAefiWp7na64OEYohPe2vBrK 803zwEZGdz8E14OKH5woqOb3qd2zqG+DL+SU0sT3iAPJgTUvaH5+giWCxbS81X1J fItLcdP2/ODYMhA6hIKwQJuXqZc/baHi2AFD6rRjS0FUpqSJDjeXeu/j97imYz9u rpCvb40HImsTM9T8EUmYVW7fKAPk8g2FglR1J1yos83/JQ8RhkfOQ== X-ME-Sender: From: "Tobin C. Harding" To: Ilya Dryomov , Sage Weil , Alex Elder Cc: "Tobin C. Harding" , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Tycho Andersen , Kees Cook Subject: [PATCH] rbd: Remove VLA stack usage Date: Mon, 12 Mar 2018 15:49:40 +1100 Message-Id: <1520830180-25452-1-git-send-email-me@tobin.cc> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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); }