Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1064051ybl; Wed, 14 Aug 2019 10:07:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVBmLNEWmUQciVeSR4A8jnTCGvStpoa34Fa5ZxdICzj0zQ9ApXFA93YgYt+0N7FFE/IuWG X-Received: by 2002:a65:5b8e:: with SMTP id i14mr201029pgr.188.1565802474946; Wed, 14 Aug 2019 10:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802474; cv=none; d=google.com; s=arc-20160816; b=ZfchQaTvncvPUjZP8vHQwRpNDWFTDJbw97ZJlu4ddyF1vaxxi8tYL6bGFStpHxfKqn e1Nx0BfLd7oo9qmxLrPLKdRNwmbTlaX2eNisJ9az6mjf9PBU45cp9x4plKadBCRblYvR MhOHFzhgy8+zOLAsyG4QEIDK5laxXOYSd9zIIDc7Jf09wkvQcff4a9PdyZOM0TJ/w87u DufEt1jRVRmVxR1MytcW1LICcC17K5o3vHopO7gj5beqBpwVlBzotZZtBxOEmO4AVBfw HtX7+8MCqEWGBdq3D7py6Av2ra3Dm3F6X+Aht7vwb6ShaoYiQBH+G8tEYRPR02IEaCWU v3Iw== 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=DBPyyKKkQuOXzb/glDChJePaOKMITjdOimagLxasZBQ=; b=E4WfAZVOPUWOalIM18AoNcMM3OqG3qO5g5jYZw4O2E0rW4wW7hoPT8IOzf1gKXGq9M +d2Bw1oSNphy3m3ViKEqy5dUA5Su0+kygDxAdCv8rp2J5g4Qdf5qjGvw7PyUmHMw+W2d Z/mL3IhACQnX8ZNghoFaVlOAG2fTn9jl7R1YtNCiIM4ePGutKRnhH3/uDpb5SCTYscul UUkuxuhkkMp6sv12taPnJde85Rqr/5LwW2k9bOmH5K0tqPaHX3XPY50RdwifjWIrBYV7 H9lbm9f3kMRyS7KwAVAUjPMomjcc25RRqr8TD4727aFebA9Wg62mJ/NR//IvcQuk62ZM gj5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qET4AeM5; 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 p16si162236pgh.410.2019.08.14.10.07.38; Wed, 14 Aug 2019 10:07:54 -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=qET4AeM5; 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 S1729627AbfHNRGR (ORCPT + 99 others); Wed, 14 Aug 2019 13:06:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:55320 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729137AbfHNRGN (ORCPT ); Wed, 14 Aug 2019 13:06:13 -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 E0E0D2173E; Wed, 14 Aug 2019 17:06:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802373; bh=ZbcM41UZ5tJ59SBJKZ1nr0uuY0yD7jpy7OVAsJ3VS20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qET4AeM5pTwFT7G3SE1uK3LB52Bh4dZByWVYb8W03ZH+m/zY7Thz+hKQq5Pd1S98T febBDy7swdMXuZgeWtA1HAshhS98qBhUxOw0XhaMiYuebNQyTq480C4IiXHR62TVop UwN65asV9ROofrG5MgyVYT74MHySGy2Pm1epyZ90= 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 5.2 101/144] drbd: dynamically allocate shash descriptor Date: Wed, 14 Aug 2019 19:00:57 +0200 Message-Id: <20190814165804.111912540@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@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 90ebfcae0ce6e..2b3103c308573 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c @@ -5417,7 +5417,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; @@ -5430,6 +5430,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; rv = crypto_shash_setkey(connection->cram_hmac_tfm, (u8 *)secret, key_len); @@ -5571,7 +5578,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