Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6260071imu; Mon, 21 Jan 2019 06:01:36 -0800 (PST) X-Google-Smtp-Source: ALg8bN53x7ICxdjRcYjLoiDPYy3Eta55tlIP/9GPTjz3RyMtn7YqOQx3oUz4izcM42LhMnGZcPSB X-Received: by 2002:a17:902:e08b:: with SMTP id cb11mr17315805plb.263.1548079296780; Mon, 21 Jan 2019 06:01:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548079296; cv=none; d=google.com; s=arc-20160816; b=0tEUoDspM2a5ZrtpuIXeo+0BqnYtiT/aIojchIF5OjRVxAq1zD64yd6apK3KuNJGge yiFVGII08tQ2xlfqtBQGTrFIIw8Kb39k9jfBAtPUt+lzS6t4gHjLTCwZzi0fArPZoYOt hr/b5IG8MuSdOuv+ueVy1cgUxUNIYq2jZQNrs1WcbvCiPaF7H39HXKOTLZM0VP+xvG0t pvW4YyCfCU7X2vIL3Jdrnl2v3ta/a2BIMgxJoI6RAPMf1yHLPn9qxCkeh1EI2gFksdcT 1fAfXncPL4f8F+4dbxIrN6EzR3+f/zqH0y9LWvuGFLYF8FgaChsYqYcgdDpz8XMIgD8Z 1Rsw== 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=AuE9vJ4VfHCl6Rta7RS4pLZlDusbv1GghA8ndJAiRWc=; b=xxHmcv3HnLRuJp+JRvdcbWKHpJcv0u8+b0cm+UGpW8iw8+w+BjseggxJmD/CVQpg0m l2ZQYI6Cb1narF5ffR1aiU5TUxOUVYIKvgzdmp7SNFLJHhGh0Lqnmglr1sVuZfwwJm67 1c0pFFEZcnKLVVDHGHSSIyf6sYweSUitNBI9A4cTspk77/8Z39c6utYkXFVcuwzU0jBr 3/ysgB5wOymCaQkoM6g/r9zffqRGB0u5EqL0n1ts0lB/Wt4UsE89Q3FDKLod5Df/Y+4Q hIWW+mozsPNy/Kdl3dPYMwoRAo47El0xRJYCemkD/Gk9EPH9RnJ/9EeeSWMpwHWegcuf M6Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZrfwSBmZ; 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 x23si9695658pgk.272.2019.01.21.06.01.21; Mon, 21 Jan 2019 06:01:36 -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=ZrfwSBmZ; 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 S1732207AbfAUN7c (ORCPT + 99 others); Mon, 21 Jan 2019 08:59:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:45532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732198AbfAUN7a (ORCPT ); Mon, 21 Jan 2019 08:59:30 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 6B3C42084C; Mon, 21 Jan 2019 13:59:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548079169; bh=7L2rTermTa1VA0fCfzacfd3s0eqrU6jC59NinyyU5SQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZrfwSBmZYMjWH3bl+uiLrXDbjYs6SWv+7oeVGGwSB4b93tmTMh6iBez5y9T7mTCPO WBn5RTzHBX04927HbXiTclKq5Z8IdrJtaqYAZCPMuF/iuiiTKPfsAGp4y5wStxezQZ bxO8gHUNOSGFEwDg1JkTB/pbIJVOhxoh8TuQtbFs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gilad Ben-Yossef , Eric Biggers , Herbert Xu Subject: [PATCH 4.19 31/99] crypto: sm3 - fix undefined shift by >= width of value Date: Mon, 21 Jan 2019 14:48:23 +0100 Message-Id: <20190121134915.082802140@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121134913.924726465@linuxfoundation.org> References: <20190121134913.924726465@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Biggers commit d45a90cb5d061fa7d411b974b950fe0b8bc5f265 upstream. sm3_compress() calls rol32() with shift >= 32, which causes undefined behavior. This is easily detected by enabling CONFIG_UBSAN. Explicitly AND with 31 to make the behavior well defined. Fixes: 4f0fc1600edb ("crypto: sm3 - add OSCCA SM3 secure hash") Cc: # v4.15+ Cc: Gilad Ben-Yossef Signed-off-by: Eric Biggers Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- crypto/sm3_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/crypto/sm3_generic.c +++ b/crypto/sm3_generic.c @@ -100,7 +100,7 @@ static void sm3_compress(u32 *w, u32 *wt for (i = 0; i <= 63; i++) { - ss1 = rol32((rol32(a, 12) + e + rol32(t(i), i)), 7); + ss1 = rol32((rol32(a, 12) + e + rol32(t(i), i & 31)), 7); ss2 = ss1 ^ rol32(a, 12);