Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6146705iog; Thu, 23 Jun 2022 12:18:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t9G6d242YuGxprr3PtC3cYk3WP/u515V/nAviJfavuVrcJS6+MP4w3rmv4U9+y/DJvEBPT X-Received: by 2002:a17:902:ce11:b0:167:7d4a:964b with SMTP id k17-20020a170902ce1100b001677d4a964bmr40162535plg.37.1656011909596; Thu, 23 Jun 2022 12:18:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011909; cv=none; d=google.com; s=arc-20160816; b=bqIEqZyBfqxI+PiOLwIcoG+0hn/FQMzOiz+nQksB3et15H2JuUG6vMqccp1Pr8+9yE tOZtvtIdU1Sd2HU9yN5MzdSf2NwWGellDtmEupRAPwI4FYPAo9Z3ZmrO9AyewFyfZlth cBbLC4L1MgNptUXCP9ZKUNcUHrTM/bTGsqcdS2VdwK1g6TUCjH31dxAfGhDS8lh95FO3 aqr5qqt3DiZ+2KxhrgB9tTMYZ7O7DUvgvBHee8nHUJeNQ5vYH0KLI8WbbXlTcV6B+ZnY lGfpC2co1pVZ5IAKiPIbVUZ8uaCQPWmEzaMBWrDR2TuYTLWnonlTSWY6kHTTtHZ5Cg3W CISw== 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=59H9heoOmCynpiJVIXE3C6e0mF5eWtHwNf9qWYUJwDY=; b=YgSMYu6ctQkgRHaDD/0sgx5Qtz+9PS//ONA8K6trvrFIWvZwYdv+2JfyGN4ZWFh185 xgO6zwZ2dyf/bp109OK5+w9UL2ABjj8HF6PXzqesTN5OXZ4+lBFxebEncexcoiQ/B0c5 2vzdo1vwDsnMyanMK2qKOddWGjgrkbUKgkpMzhHY+OCSwnmkIq+zrxT/nzbkyUtVCiLa 6Ye9aSzIhDVYYoHU9jh7YoSGNV+cEviv030AIl2hEKjIrFdtY2pJiqhfAZjqg/7Tnge8 gv8lmIA2sbtNatpHpROjj+Uk10YjDlqdgJhdhhVEvrWIP1kSR34zsn+8J1/z5ZDuT+iH n9Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Eluh6kCj; 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 t6-20020a170902e84600b00153b640ed90si472435plg.38.2022.06.23.12.18.17; Thu, 23 Jun 2022 12:18: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=Eluh6kCj; 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 S232176AbiFWQrs (ORCPT + 99 others); Thu, 23 Jun 2022 12:47:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232614AbiFWQq4 (ORCPT ); Thu, 23 Jun 2022 12:46:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CAC349B62; Thu, 23 Jun 2022 09:46:54 -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 1B83061F8B; Thu, 23 Jun 2022 16:46:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC13AC341C4; Thu, 23 Jun 2022 16:46:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656002813; bh=nqHKUhp03f6/fa4qQx1O4w9+Q5q5omykigKC5SdoCj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Eluh6kCjlTllqW9ZZlrDSyb576hSSgam5MI7xRLxpQ7+9LyrWTh1pA6Pv7q3UY4CT 5F8tAndda9aElxgkz1TmtBuXTE2FL+BPxNEfy74t4ILVWo2zallSc4VjV7/ijuCh79 C9295ir7lnycFBLwjtUz0GNFk7SwIalGmf9LzznE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Theodore Tso" , Ingo Molnar , Thomas Gleixner , Sebastian Andrzej Siewior , "Jason A. Donenfeld" Subject: [PATCH 4.9 033/264] random: remove preempt disabled region Date: Thu, 23 Jun 2022 18:40:26 +0200 Message-Id: <20220623164345.005711217@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: Ingo Molnar commit b34fbaa9289328c7aec67d2b8b8b7d02bc61c67d upstream. No need to keep preemption disabled across the whole function. mix_pool_bytes() uses a spin_lock() to protect the pool and there are other places like write_pool() whhich invoke mix_pool_bytes() without disabling preemption. credit_entropy_bits() is invoked from other places like add_hwgenerator_randomness() without disabling preemption. Before commit 95b709b6be49 ("random: drop trickle mode") the function used __this_cpu_inc_return() which would require disabled preemption. The preempt_disable() section was added in commit 43d5d3018c37 ("[PATCH] random driver preempt robustness", history tree). It was claimed that the code relied on "vt_ioctl() being called under BKL". Cc: "Theodore Ts'o" Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner [bigeasy: enhance the commit message] Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Theodore Ts'o Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 4 ---- 1 file changed, 4 deletions(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1189,8 +1189,6 @@ static void add_timer_randomness(struct } sample; long delta, delta2, delta3; - preempt_disable(); - sample.jiffies = jiffies; sample.cycles = random_get_entropy(); sample.num = num; @@ -1228,8 +1226,6 @@ static void add_timer_randomness(struct * and limit entropy entimate to 12 bits. */ credit_entropy_bits(r, min_t(int, fls(delta>>1), 11)); - - preempt_enable(); } void add_input_randomness(unsigned int type, unsigned int code,