From patchwork Mon Mar 12 05:00:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobin Harding X-Patchwork-Id: 10275463 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 5AD0E60467 for ; Mon, 12 Mar 2018 05:00:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BE9C28B81 for ; Mon, 12 Mar 2018 05:00:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4062328C83; Mon, 12 Mar 2018 05:00:30 +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 726D828C88 for ; Mon, 12 Mar 2018 05:00:28 +0000 (UTC) Received: (qmail 32568 invoked by uid 550); 12 Mar 2018 05:00:26 -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 32549 invoked from network); 12 Mar 2018 05:00:26 -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=HI9YNtnL86EqwTdX0gs87n3BCwzk3GslnKYO1Ulr1 Qk=; b=RXZH042585DPARYorzZyExWK0KZ01ElEhyJP+LnIsY9mAqw0/IaLrouZK gLNNdpdhg0R+TwRu/5EwFjmJsFtG06FS1C5STQ0TxacPK6pKOf6i7yFeueKYNgLS Y6p5JJtBNRas4KCwhBhWHFb1W592fVf4PAUj9Ckn3QZvZ1cl9jVPVo4vqxMXUmkk HF3JnRllKnJ38/ztbSo1iCvo+O68KLNKwI6myRkJPWzmcQHJ7egCe8W+Oes+EyYd sG5byIpeE/FulHcnju//5uwwZP7/fMS5WPpKKtupiFquhGuoOVWyks2hbNRvNglz OyagGXBl/6rs0OqxjIQp4ndZO/K3g== 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=HI9YNtnL86EqwTdX0 gs87n3BCwzk3GslnKYO1Ulr1Qk=; b=Aiw0vSxt0ljnk22A1Lf+jm6cRAnSstTIJ jDA3s2EKow168GSHNjVvv7steK3uF2stiALTCYbE2WCZ0rUYTSAJKaleA5Dzty65 vH0NLE0XkZIXyYWQosG8W9CB8alzjqMHL2Lb4kU4dKs2DBkZqwqeSlXJqEvEXku4 Mo26TY1UXTE6vgs2XEpUB6oWYHsMMY+qQ9SUEWtI1aMcaDZz6NPaycZXFFQHrPil tbXUCeK5FlqrAnJ2cbwa4SZFZlOkASvx7X0nLVYqF++94o32e71ePPcWDayATjG2 s2K3vHyFpzoX/6+B+qXm3YOIKTy4CoLBRaAs+UMVR5n3PQ4TAhbcw== 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 saving ack buffer size Date: Mon, 12 Mar 2018 16:00:08 +1100 Message-Id: <1520830808-26991-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. The buffer size variable is set to zero on the error path; the buffer size variable is used later in the function, we can maintain this behavior by setting the variable using the macro ARRAY_SIZE. Use constant statement to declare array. [1]: https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Tobin C. Harding --- Excuse the lack of threading, I forgot the second patch ;) Can re-send threaded correctly if required. drivers/block/rbd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 927ecd9a2511..7c228753fddd 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -3618,13 +3618,14 @@ static void __rbd_acknowledge_notify(struct rbd_device *rbd_dev, u64 notify_id, u64 cookie, s32 *result) { struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; - int buf_size = 4 + CEPH_ENCODING_START_BLK_LEN; - char buf[buf_size]; + char buf[4 + CEPH_ENCODING_START_BLK_LEN]; + int buf_size; int ret; if (result) { void *p = buf; + buf_size = ARRAY_SIZE(buf); /* encode ResponseMessage */ ceph_start_encoding(&p, 1, 1, buf_size - CEPH_ENCODING_START_BLK_LEN);