Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1072376ybl; Wed, 14 Aug 2019 10:14:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzILnh9lhANdXrhc7Ji4THQyGl5gZr7TpS4IMYO+PsWIu7RlTEstEUoO6FXaH11RWCCowTR X-Received: by 2002:a17:902:28a4:: with SMTP id f33mr455728plb.50.1565802896747; Wed, 14 Aug 2019 10:14:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802896; cv=none; d=google.com; s=arc-20160816; b=0Snx3aDNA/hBhC9acVG4okUBYVDbvRLyvIt8jvYS9P3p/CiZFEFDuEfK93WT9Iqq4q KqK3nKJRGZx/OiCidpffsA/7Df5YBx0qOByg82rBXjR1oJ1h+hcWvzC+WIhUhbZgEPRW dX0jRiRMF/BsO+FRoEOO7iKu4dq+r8a2DI7lVNtcVkDbSN9l/AfBPyqb/fiR645kZqEl iwRdC3xJ74u2u5gPItLkQGDgIZLlrfsc/jVgQbwQuJrEr2Vlls826uaCM4A9TBnXXF86 HoKjpCM9vGHtxNU69bvygcBg4LdKaosYDpCoWy+Cu0LCbhS5eYQNmlooi3SjmDIqLjk9 gcTw== 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=GCHguY0h/kvA1DrJflukuAF4zYfkkI3OlKQe2pzV904=; b=v04aXRxuFzlRc6mlJxCauYcRUbgRzrTkVvZctGPg3hmu7MOM+cCOAmaU74GP0E9DH6 JyhDtGbxSUgxrRPnIecBI6Kx8617vSAtFN1l+3ksUBGn0L5PtaxU3OuAG3g/SWaBcyUZ AXvue3eYnWBjQZ1Ekgy59HuwhGW5SVoxxN21UtQZ/9inbtvhWirg2h38mtBKdquObmrB RQ3DywIN1ZQhvFxPJ4/llS76E15oX+sHq0g+2XORpmYtDEiJI5or0gmrZWueKkE1ao0W hNDhNsqdYgrUMxlu/Q/144WeXR+kNJaAfzJpzLani/cSxqUC3BWNwNJyGAnSXLCzcDb+ 0KUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E8meYCjt; 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 31si238348plk.342.2019.08.14.10.14.40; Wed, 14 Aug 2019 10:14:56 -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=E8meYCjt; 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 S1731037AbfHNROK (ORCPT + 99 others); Wed, 14 Aug 2019 13:14:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:38594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731023AbfHNROI (ORCPT ); Wed, 14 Aug 2019 13:14:08 -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 044A12063F; Wed, 14 Aug 2019 17:14:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802848; bh=9J/hVlocitOzGgJbVxHih96oSCV/jmUgFFqrsAWV2aE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E8meYCjttmB6wmApiI60hfpHkJyuNEkp0MIGhTJNAALJmKEJ+iiiVPpqEnKiStn6g oL8sSWZ0wzztwCrj5aLWv9HI69ve2TmbjaPqO7PCm6pzUPkfFs/iksS/V99S069clu rM0SajkKL7lG3Tt6wtHiD5dOlX1WaHr2c3zMQtwA= 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.14 42/69] drbd: dynamically allocate shash descriptor Date: Wed, 14 Aug 2019 19:01:40 +0200 Message-Id: <20190814165748.230767321@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165744.822314328@linuxfoundation.org> References: <20190814165744.822314328@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 1aad373da50e2..8fbdfaacc2226 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c @@ -5237,7 +5237,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; @@ -5250,6 +5250,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; @@ -5392,7 +5399,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