From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13DF8C2F3A0 for ; Mon, 21 Jan 2019 14:07:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D03C520989 for ; Mon, 21 Jan 2019 14:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548079657; bh=7L2rTermTa1VA0fCfzacfd3s0eqrU6jC59NinyyU5SQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=aJeYtVUyONt0XRcfPQPMJ8IHTFLSpk1hUFZEyBQeLv++k5qDNyfIacWh5o6oYpp1f vVR0iGxXQvnvca/+ysLWSATL8jjjhtgOtUF42483MJAwVx3GusspcMZIB1ToFtsyLU gTdjMZKo60S/10PjOR/PvebNBLIWAQy95pzyy3fg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731911AbfAUN7b (ORCPT ); Mon, 21 Jan 2019 08:59:31 -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: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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);