Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6031751iog; Thu, 23 Jun 2022 09:57:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tNFPLWANnuJYwdHsgt+OZQfHGXe01Lud90Pn+DLm0jJOAdD3qlz2yMKYcIisJ40jh5Knyk X-Received: by 2002:a05:6402:5384:b0:431:6d84:b451 with SMTP id ew4-20020a056402538400b004316d84b451mr11903112edb.46.1656003421541; Thu, 23 Jun 2022 09:57:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656003421; cv=none; d=google.com; s=arc-20160816; b=gS34cm7Z6aGJFljy/qcgUzlhJLCFxbbpGPMP+ql4JoJT1tkSWPiqAfKOUnple9pQi+ CCHA2Z+aNV6nwNZcB/J9i3Osc5+cTAIDPFrYwblhhvkw8ZKRtdifpr55OBaMpgnUU8IO EKqeIY3qMIpNsaRPxe84uXr2GovtZsbHETn9KL6eggkTvj7wRtMJgPdFWK2oEptkvuIp kTrgGIoztyFQMRmQwvEnRbCd1XQp4CsrE2iB8Viz+lupzIqYATAbmZi5IyDHYuoH/UfO jtDB87+oci785ZEgMmhiKmthxK5QNB6E+3blF4xStKyLF1cGA9GykcLriyYHgULQ+gBF gO9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WKAAPVpUeK14VgW0iglO9vyuyTNIz89p42nLkLN/Ddo=; b=xS5GpyJW9db89uA3k4a1zP8KLSmonN5a1H3jLUEehzTVKN4bT74wMNisYoft3RCApt fKHw7wXSGsRNrO4kWsCEfXo+JuPWwXYEO5CQgf3ZbNxQ3i/9GTwmkGeyPLX95ehafth4 o4S28BoH1VuHii35wcamRfwBFgb/t5032C/MvhYxdkcMz2VfRiIG1qgGcHDQ7mN/HrKi hRB5EVn2gCBv551ve2V9IRyUnGxqlxF2qaGB2T79GVPjVc55zM6t6X8zYhiQclhAbge7 rhu7Sdpa/1s3OJ7tq8EoVl5jefdd5LuAYiENF7wvvdzvpnwcw0u1TzdwKi+h4LMjU/dd 8GSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="BBp8o6R/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020a1709060f8f00b007115a93d536si21139584ejj.598.2022.06.23.09.56.28; Thu, 23 Jun 2022 09:57:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="BBp8o6R/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232208AbiFWQyw (ORCPT + 99 others); Thu, 23 Jun 2022 12:54:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233856AbiFWQvp (ORCPT ); Thu, 23 Jun 2022 12:51:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A2E29589; Thu, 23 Jun 2022 09:50:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1514361F99; Thu, 23 Jun 2022 16:50:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C44F5C3411B; Thu, 23 Jun 2022 16:50:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656003015; bh=ezQ5cfLdnEC6PYO373KbfXHKFeC+bD7ZwpWRgYNkwqY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BBp8o6R/2uvUlf2rzSx0vS+y9Qmf7zCth4xHTlFWhxJ8HMj5jSu8KR4VZb2aJPS1z B7nySd349DtEb8RPiayzF08uymaamA6WbCnN+EjMMQpbrx8hjtcprUcmggfHKfBi1b QAkWuyrZiCzILDylhgh+D1CUFEv2rZybTsF72xK0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" Subject: [PATCH 4.9 084/264] random: do not sign extend bytes for rotation when mixing Date: Thu, 23 Jun 2022 18:41:17 +0200 Message-Id: <20220623164346.446593474@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164344.053938039@linuxfoundation.org> References: <20220623164344.053938039@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Jason A. Donenfeld" commit 0d9488ffbf2faddebc6bac055bfa6c93b94056a3 upstream. By using `char` instead of `unsigned char`, certain platforms will sign extend the byte when `w = rol32(*bytes++, input_rotate)` is called, meaning that bit 7 is overrepresented when mixing. This isn't a real problem (unless the mixer itself is already broken) since it's still invertible, but it's not quite correct either. Fix this by using an explicit unsigned type. Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -550,7 +550,7 @@ static void _mix_pool_bytes(struct entro unsigned long i, tap1, tap2, tap3, tap4, tap5; int input_rotate; int wordmask = r->poolinfo->poolwords - 1; - const char *bytes = in; + const unsigned char *bytes = in; __u32 w; tap1 = r->poolinfo->tap1;