Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp45911imu; Thu, 8 Nov 2018 14:30:07 -0800 (PST) X-Google-Smtp-Source: AJdET5eTXSxAAZWbrCq3zMFUBGy7PgEMainZKKrygSfP17d+KAGmvBqyPiMcHMP97rpjUjNN1OVS X-Received: by 2002:a62:e0dd:: with SMTP id d90-v6mr6245164pfm.214.1541716207889; Thu, 08 Nov 2018 14:30:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541716207; cv=none; d=google.com; s=arc-20160816; b=FLnVog5OKYd0g3rB/slJYzIwM0bx+NsH5b0stFTa9RQJZVbd8ZhXn18m2kztHZ5usl 0v1bjHuAZOubTj6DX5kFl5WAO4ObOMGhlJUlpUngcj5a2DffwpcSf5H047FYHT5wv1da fHLDv2Z5i/dHz7Xm5F8pqlw2XNvKILfOx08t9wwcHlEStomPm1lv5UBeq8egF/9IX8BM lxk/xprEyL4UpUUVNbpOwuqTmN81O6dDeB3k8VIPNduXR59RIAR2dxiq5meXFnjXHWWR yBragNU9NhhEGB48eD2tCus6OpVqpcm+aTbosDZkr13YNHTiEWNl9GqyYLcxRcYBAdOM aT1g== 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=g0HsHt6jq7jBkZlQIFa+iDFFm14C0vC4V+p1UgCG93E=; b=q0C08T9e/85h3OBZGB098fpFVDDo2fHJTguVBilGeZG0fG6rSBZGETJu46DLpu2Ih5 31O81iQ4WimSCrmTuNpjhwlz6Gx8H7kVPkLjupFy637h9f9dEp8QSfcOlKlbmyPEnLBJ 5LnxAomDoEkgPu6Jxe6NaozjVzNuBTQTgfdJHOm+bLUfgcYCfVQ4SyzPUjx37oqaz10i bLkNy1DwdzQURF020by32OSFkQu2a18EoQuP2ewthwBYX+QxUylUNjPuOmfVDmvBRuuy /fxBpC/vq5DGV+/2zfy7YM3YCq6RaqkW6EbNNxiRTuV87xU29aeIRE19yyKtnLo2D1J6 4/bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SKOP3nrz; 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 u9si5034213pgu.570.2018.11.08.14.29.52; Thu, 08 Nov 2018 14:30:07 -0800 (PST) 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=SKOP3nrz; 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 S1730777AbeKIHig (ORCPT + 99 others); Fri, 9 Nov 2018 02:38:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:57904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728491AbeKIHif (ORCPT ); Fri, 9 Nov 2018 02:38:35 -0500 Received: from localhost (unknown [208.72.13.198]) (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 98C3520989; Thu, 8 Nov 2018 22:01:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714466; bh=cH1rxjmgf+yrt4cmzOS2KuKuZS4NhECRjKyi79xIlCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SKOP3nrz0osM7tdeYRgOXHx+KvnTQEaLu8R2YudKSsMmRKaPmRNanpm+7E74yCyly MN3IjeuUvsaPAV4Z6NRqoDA7KvaRSU7Lv09EQBP0dJy+Nq/jWcI0Zpt59qbmE4ii9X zlfHh6WaFqnRXtvZDh7BOTww95bLfrc8y3IRY234= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia-Ju Bai , Herbert Xu , Sasha Levin Subject: [PATCH 4.4 102/114] crypto: shash - Fix a sleep-in-atomic bug in shash_setkey_unaligned Date: Thu, 8 Nov 2018 13:51:57 -0800 Message-Id: <20181108215109.932145213@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215059.051093652@linuxfoundation.org> References: <20181108215059.051093652@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 9039f3ef446e9ffa200200c934f049add9e58426 ] The SCTP program may sleep under a spinlock, and the function call path is: sctp_generate_t3_rtx_event (acquire the spinlock) sctp_do_sm sctp_side_effects sctp_cmd_interpreter sctp_make_init_ack sctp_pack_cookie crypto_shash_setkey shash_setkey_unaligned kmalloc(GFP_KERNEL) For the same reason, the orinoco driver may sleep in interrupt handler, and the function call path is: orinoco_rx_isr_tasklet orinoco_rx orinoco_mic crypto_shash_setkey shash_setkey_unaligned kmalloc(GFP_KERNEL) To fix it, GFP_KERNEL is replaced with GFP_ATOMIC. This bug is found by my static analysis tool and my code review. Signed-off-by: Jia-Ju Bai Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- crypto/shash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/shash.c b/crypto/shash.c index 5444b429e35d..4f89f78031e2 100644 --- a/crypto/shash.c +++ b/crypto/shash.c @@ -41,7 +41,7 @@ static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key, int err; absize = keylen + (alignmask & ~(crypto_tfm_ctx_alignment() - 1)); - buffer = kmalloc(absize, GFP_KERNEL); + buffer = kmalloc(absize, GFP_ATOMIC); if (!buffer) return -ENOMEM; -- 2.17.1