Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1079135ybl; Wed, 14 Aug 2019 10:21:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqx07iVgnU9hLyifOExWSh4y9Hanhw31NB/976ydQ5HRSIw/MZ/nGuujR7Vklwu4tP0rM017 X-Received: by 2002:a65:610a:: with SMTP id z10mr254451pgu.178.1565803276406; Wed, 14 Aug 2019 10:21:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803276; cv=none; d=google.com; s=arc-20160816; b=wb5TjO9qQQ0b44cSGXYKocWKuGl8ahaHnVJYq2AyYuaEea9IbJYWWvwgcHfDCYj5bB P0lHwoy2DDsRaRvfWJ/8NdjzEiwvdDaMPwZofeLlGBXxsp6IyqZ6oq3mmMeaov5JHxOy 5gDYwLygUB2XNHKYmvBOgspCdG3m5q3nmAQFjV+atSJ/Lz8KKJOI3zZK3AoY9+yf793O FgjEBb198qasMAmJzemymk7rtUETFC9sl/kOgDGhHrhhxkfT9BoWKoSCMIDo2deeplyH KVBhF2npdo6fFhI/cEfSSj23ssblyCRlOLZ86KiyRQA1guqQXYzkSIh7QIVe1h6GEmOW vLhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lx89fV7B/T6xkpcEDKp+JZic1gVuhWEQJNlz86Bhz1U=; b=I2Lo1Y5L8rLAeIUsKCaCtE8hW0t2QWjcV9RPa4iqJUC2iofB/cXm+h+q5XHvbamZiL eB5NPpoeemWuD1SDQUoAQo0vgnmABaL1bp4HBabP9bFOMB+gmREWL4f+Og6Vw01+XKLo U6OCQIQoVHWZYduZ3SErlB6M57vBmQ7DNauBDOKHV4ghloXLRzutLyTey4iH5/89meFs 4nmwghSjUUjI6soLjQqAz1Q9746ETpmzarI84ask0VJxAVRw7aMYZNnX+m0ohgo94KT6 csG88dCi5a/+BPZMvMCdn6QksmlhWRl64vfsQSZacrAl36FGOq1u8Mfv841Tjs1GeqSp 3Ung== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fvVR2qUT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cf17si260188plb.48.2019.08.14.10.21.00; Wed, 14 Aug 2019 10:21:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fvVR2qUT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728566AbfHNRKo (ORCPT + 99 others); Wed, 14 Aug 2019 13:10:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:33520 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730491AbfHNRKh (ORCPT ); Wed, 14 Aug 2019 13:10:37 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D4666208C2; Wed, 14 Aug 2019 17:10:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802636; bh=YDQJh1s0RTBt+Tifbh5eZKJpS1SCtra7aq/KoofWG3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fvVR2qUThr5flizOH+P7vO81JBY+XhgaDbWeBuiIBALDmVPLIRobVNjHxEdpWAIzK RJcT3vp2T7TTnlBITtbtvr/kqH6QRrRokCpOAJ9nmhlWbn8kXWtR+KUjVpn+uIzWND QsRFf9+Kyc867iiNQcrjQuXSFwniz7Xl7/kAeH9s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , Roland Kammerer , Arnd Bergmann , Jens Axboe , Sasha Levin Subject: [PATCH 4.19 58/91] drbd: dynamically allocate shash descriptor Date: Wed, 14 Aug 2019 19:01:21 +0200 Message-Id: <20190814165752.062292870@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165748.991235624@linuxfoundation.org> References: <20190814165748.991235624@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 77ce56e2bfaa64127ae5e23ef136c0168b818777 ] Building with clang and KASAN, we get a warning about an overly large stack frame on 32-bit architectures: drivers/block/drbd/drbd_receiver.c:921:31: error: stack frame size of 1280 bytes in function 'conn_connect' [-Werror,-Wframe-larger-than=] We already allocate other data dynamically in this function, so just do the same for the shash descriptor, which makes up most of this memory. Link: https://lore.kernel.org/lkml/20190617132440.2721536-1-arnd@arndb.de/ Reviewed-by: Kees Cook Reviewed-by: Roland Kammerer Signed-off-by: Arnd Bergmann Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/drbd/drbd_receiver.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index cb919b9640660..3cdadf75c82da 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c @@ -5240,7 +5240,7 @@ static int drbd_do_auth(struct drbd_connection *connection) unsigned int key_len; char secret[SHARED_SECRET_MAX]; /* 64 byte */ unsigned int resp_size; - SHASH_DESC_ON_STACK(desc, connection->cram_hmac_tfm); + struct shash_desc *desc; struct packet_info pi; struct net_conf *nc; int err, rv; @@ -5253,6 +5253,13 @@ static int drbd_do_auth(struct drbd_connection *connection) memcpy(secret, nc->shared_secret, key_len); rcu_read_unlock(); + desc = kmalloc(sizeof(struct shash_desc) + + crypto_shash_descsize(connection->cram_hmac_tfm), + GFP_KERNEL); + if (!desc) { + rv = -1; + goto fail; + } desc->tfm = connection->cram_hmac_tfm; desc->flags = 0; @@ -5395,7 +5402,10 @@ static int drbd_do_auth(struct drbd_connection *connection) kfree(peers_ch); kfree(response); kfree(right_response); - shash_desc_zero(desc); + if (desc) { + shash_desc_zero(desc); + kfree(desc); + } return rv; } -- 2.20.1