Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6157632iog; Thu, 23 Jun 2022 12:33:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sZ10MkURMmDEZ7xoxLiT4y9q9sQlBhvdC/yIyRSaiQFbRJMiIIPQkrkP1lrn0DTrG6M9r3 X-Received: by 2002:a17:90b:4f91:b0:1cd:3a73:3a5d with SMTP id qe17-20020a17090b4f9100b001cd3a733a5dmr5617633pjb.98.1656012809195; Thu, 23 Jun 2022 12:33:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656012809; cv=none; d=google.com; s=arc-20160816; b=X/T4XeNoLzI2MWzAPtX4zksQGYbIDAJxgXGn3SyylhZSk7s6O7htwJUfX5v1eYB9BM GVb/aREEiGtUaCJsh2dOKZupQiT9drJGOmMiy9GbqQ76x0pmqa4CI58FxExce10MC+tZ FRHcFE3vTPsDV90wzLvCmNJ5NatqKDirkEdOwr1Qr3XlmZHe4cKaWAQD92zwwStT/Q9J rUYZx64ZYK8wsFMefJKEFJ9fU1jymcqg6GJQM8l4AWn+/q62YAobZt+u3wKUQTzMg+74 5Plpy4kp/s6nzWAkVAQMDcEFLT/6mvsfBBIs53R5gvBeKr/hcDCuyQvL+5q30BW4IQry YkUQ== 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=WrvGqzG+AslhPXWXKN0vfMWN44Al0YuGDWs1T5szsj0=; b=vG3M9MSmzKic6VFjYhNroKmsc7Z7ptxy5ydDvgySlKjPVkjMxAD+JC1lDkLrmITy8M l4BlAkYhELGhhSX+XZRn5A+RWoRE0ybrc6r5LM1NxayVe0wWbvkccgCgyH18sAfgfbnC xg7VB4xi1DD6jTCjDJcWPzqNV1LxXPFCwOLi/djoqOjZ3jFOGRjQ7CpRuHH1M+CHXq9U f1AU7IrvBitxgjtBeRacZswAJApsg/AQ3GkNBqTbLh/z3kbMueZHon0MfvxUrB9OuW1i 2Ew5tmQWkGLHE4GUwjhe6VdSGfMQPLpW3YjxZHUQ13dQMJ6cVUO/q7ac0x7UfSZeDN2J u1ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M9aTa5Tm; 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 v202-20020a6361d3000000b00408dbda1a5esi26175pgb.276.2022.06.23.12.33.11; Thu, 23 Jun 2022 12:33:29 -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=M9aTa5Tm; 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 S235637AbiFWR5F (ORCPT + 99 others); Thu, 23 Jun 2022 13:57:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236014AbiFWRxo (ORCPT ); Thu, 23 Jun 2022 13:53:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B3F9AC8C6; Thu, 23 Jun 2022 10:14:38 -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 7ED4061D17; Thu, 23 Jun 2022 17:14:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43271C341C4; Thu, 23 Jun 2022 17:14:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656004476; bh=2e6ozog50rVhgaO01r/Nkzs/rPS+Giyrtcuxu+y0u9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M9aTa5Tm93vQoQPzgyp0zzsiQ3vqHFr0MuWVwt9p4MvlDHv6c1xRObPPJQ2A0KJ4O 0g7lJaI3rdNCdOASxHqpJRswfPG2ZHO0XeJTeGh4F9Fgj3C4aRi5mL4wZpox31C4xu Yozi27SVeEdja7dr7CqfODAn/15kLVuad4iZD3Vg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" Subject: [PATCH 4.19 051/234] random: do not sign extend bytes for rotation when mixing Date: Thu, 23 Jun 2022 18:41:58 +0200 Message-Id: <20220623164344.511214378@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164343.042598055@linuxfoundation.org> References: <20220623164343.042598055@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 @@ -549,7 +549,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;