From patchwork Tue Jul 24 16:49:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10542697 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E837817FD for ; Tue, 24 Jul 2018 16:56:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D32B228942 for ; Tue, 24 Jul 2018 16:56:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6AB828EBF; Tue, 24 Jul 2018 16:56:36 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 54FBC28942 for ; Tue, 24 Jul 2018 16:56:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 618CFBDD1; Tue, 24 Jul 2018 16:56:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D899171D8; Tue, 24 Jul 2018 16:56:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DD72618037F0; Tue, 24 Jul 2018 16:56:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6OGuOod012230 for ; Tue, 24 Jul 2018 12:56:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 85563608F4; Tue, 24 Jul 2018 16:56:24 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7BAE2608F3 for ; Tue, 24 Jul 2018 16:56:21 +0000 (UTC) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B26C73D12 for ; Tue, 24 Jul 2018 16:56:19 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id r1-v6so3304532pgp.11 for ; Tue, 24 Jul 2018 09:56:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0ojuoFtpY49pRoRZrlcC4u6qgVkehMZZO1daFH4ebQg=; b=CgkzIzBn05lmhk+e5TxjjScesDSSObcCCDKeeEetNTDQqzFBrOQOV5dpyPCniZo7Vx ya0Qd8SN1iPqfA/0N1NH3sMbIObBCd3gLY9JtF7Eol3k1gcOI0v7oiPJWAB6Rb4aejv+ 1n3po6/tG1epyvHDeSHaxKEgii74YV5qc+tvQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0ojuoFtpY49pRoRZrlcC4u6qgVkehMZZO1daFH4ebQg=; b=XR8ET32cIX962Ln+meMniLBTRcYy5+fuUTgxNe0pOcTiPDk/36s5aKsah1c3Yn2OfN bK+d7hbfakNj/QlstVh4W2f9RgzvFhCQG0RPt5sVk+IpEue470NJCpRjxnKztSbnuGNh fCDXjz+D+824W5z+SL3aYz4U6E/EO+bxitSq8VS9uysMI3dzEGYV7ZDLSWA0EhGcUu8P hoSGAyNTL09P7KCK1mT+uxjuNtUwbIpm1AtGbOuDY9LeZ3l/PJJkBrbcLlmveKsfx+7S ReqdWLuTiN3BDiB5224WXTr//3WqYszeIzVNGbLziM9vOY9JBY/U0Qgxzq7pEzQyxQ5i AtnQ== X-Gm-Message-State: AOUpUlFyrAdTAzynAEOrCCak1/Da3EFdpUKA4yD7sD3Fy7msySknd7tH qVLfk2uI0ncAhDl4WmGz4Fv9wg== X-Google-Smtp-Source: AAOMgpf+xHiYmSuy+iFsx+BWYX3LSu60mgKBhzZNEgiNUYprSNUZMSYoiShz+vEbEyowvo14sudtLA== X-Received: by 2002:a63:714a:: with SMTP id b10-v6mr16668343pgn.73.1532451379202; Tue, 24 Jul 2018 09:56:19 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id b12-v6sm17874054pfe.148.2018.07.24.09.56.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Jul 2018 09:56:17 -0700 (PDT) From: Kees Cook To: Herbert Xu Date: Tue, 24 Jul 2018 09:49:34 -0700 Message-Id: <20180724164936.37477-17-keescook@chromium.org> In-Reply-To: <20180724164936.37477-1-keescook@chromium.org> References: <20180724164936.37477-1-keescook@chromium.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 24 Jul 2018 16:56:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 24 Jul 2018 16:56:19 +0000 (UTC) for IP:'209.85.215.193' DOMAIN:'mail-pg1-f193.google.com' HELO:'mail-pg1-f193.google.com' FROM:'keescook@chromium.org' RCPT:'' X-RedHat-Spam-Score: -0.131 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.215.193 mail-pg1-f193.google.com 209.85.215.193 mail-pg1-f193.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: dm-devel@redhat.com Cc: Giovanni Cabiddu , Mike Snitzer , "Gustavo A. R. Silva" , linux-wireless@vger.kernel.org, Will Deacon , linux-kernel@vger.kernel.org, David Howells , dm-devel@redhat.com, Jia-Ju Bai , Paul Mackerras , Pavel Machek , "H. Peter Anvin" , linux-afs@lists.infradead.org, Alasdair Kergon , Kees Cook , devel@driverdev.osuosl.org, x86@kernel.org, qat-linux@intel.com, Ingo Molnar , Eric Biggers , Geert Uytterhoeven , drbd-dev@lists.linbit.com, Rabin Vincent , Arnd Bergmann , Tudor-Dan Ambarus , linux-block@vger.kernel.org, Josh Poimboeuf , Thomas Gleixner , Lars Ellenberg , Jens Axboe , Andrew Morton , Greg Kroah-Hartman , linux-pm@vger.kernel.org, "Rafael J. Wysocki" , Philipp Reisner , linux-crypto@vger.kernel.org, linux-ppp@vger.kernel.org, Johannes Berg , Tim Chen , netdev@vger.kernel.org, David Woodhouse Subject: [dm-devel] [PATCH v6 16/18] rxrpc: Reuse SKCIPHER_REQUEST_ON_STACK buffer X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 24 Jul 2018 16:56:35 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP The use of SKCIPHER_REQUEST_ON_STACK() will trigger FRAME_WARN warnings (when less than 2048) once the VLA is no longer hidden from the check: net/rxrpc/rxkad.c:398:1: warning: the frame size of 1152 bytes is larger than 1024 bytes [-Wframe-larger-than=] net/rxrpc/rxkad.c:242:1: warning: the frame size of 1152 bytes is larger than 1024 bytes [-Wframe-larger-than=] This passes the initial SKCIPHER_REQUEST_ON_STACK allocation to the leaf functions for reuse. Two requests allocated on the stack is not needed when only one is used at a time. Signed-off-by: Kees Cook Acked-by: Arnd Bergmann --- net/rxrpc/rxkad.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c index 278ac0807a60..6393391fac86 100644 --- a/net/rxrpc/rxkad.c +++ b/net/rxrpc/rxkad.c @@ -146,10 +146,10 @@ static int rxkad_prime_packet_security(struct rxrpc_connection *conn) static int rxkad_secure_packet_auth(const struct rxrpc_call *call, struct sk_buff *skb, u32 data_size, - void *sechdr) + void *sechdr, + struct skcipher_request *req) { struct rxrpc_skb_priv *sp = rxrpc_skb(skb); - SKCIPHER_REQUEST_ON_STACK(req, call->conn->cipher); struct rxkad_level1_hdr hdr; struct rxrpc_crypt iv; struct scatterlist sg; @@ -183,12 +183,12 @@ static int rxkad_secure_packet_auth(const struct rxrpc_call *call, static int rxkad_secure_packet_encrypt(const struct rxrpc_call *call, struct sk_buff *skb, u32 data_size, - void *sechdr) + void *sechdr, + struct skcipher_request *req) { const struct rxrpc_key_token *token; struct rxkad_level2_hdr rxkhdr; struct rxrpc_skb_priv *sp; - SKCIPHER_REQUEST_ON_STACK(req, call->conn->cipher); struct rxrpc_crypt iv; struct scatterlist sg[16]; struct sk_buff *trailer; @@ -296,11 +296,12 @@ static int rxkad_secure_packet(struct rxrpc_call *call, ret = 0; break; case RXRPC_SECURITY_AUTH: - ret = rxkad_secure_packet_auth(call, skb, data_size, sechdr); + ret = rxkad_secure_packet_auth(call, skb, data_size, sechdr, + req); break; case RXRPC_SECURITY_ENCRYPT: ret = rxkad_secure_packet_encrypt(call, skb, data_size, - sechdr); + sechdr, req); break; default: ret = -EPERM; @@ -316,10 +317,10 @@ static int rxkad_secure_packet(struct rxrpc_call *call, */ static int rxkad_verify_packet_1(struct rxrpc_call *call, struct sk_buff *skb, unsigned int offset, unsigned int len, - rxrpc_seq_t seq) + rxrpc_seq_t seq, + struct skcipher_request *req) { struct rxkad_level1_hdr sechdr; - SKCIPHER_REQUEST_ON_STACK(req, call->conn->cipher); struct rxrpc_crypt iv; struct scatterlist sg[16]; struct sk_buff *trailer; @@ -402,11 +403,11 @@ static int rxkad_verify_packet_1(struct rxrpc_call *call, struct sk_buff *skb, */ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb, unsigned int offset, unsigned int len, - rxrpc_seq_t seq) + rxrpc_seq_t seq, + struct skcipher_request *req) { const struct rxrpc_key_token *token; struct rxkad_level2_hdr sechdr; - SKCIPHER_REQUEST_ON_STACK(req, call->conn->cipher); struct rxrpc_crypt iv; struct scatterlist _sg[4], *sg; struct sk_buff *trailer; @@ -549,9 +550,9 @@ static int rxkad_verify_packet(struct rxrpc_call *call, struct sk_buff *skb, case RXRPC_SECURITY_PLAIN: return 0; case RXRPC_SECURITY_AUTH: - return rxkad_verify_packet_1(call, skb, offset, len, seq); + return rxkad_verify_packet_1(call, skb, offset, len, seq, req); case RXRPC_SECURITY_ENCRYPT: - return rxkad_verify_packet_2(call, skb, offset, len, seq); + return rxkad_verify_packet_2(call, skb, offset, len, seq, req); default: return -ENOANO; }