Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6135181iog; Thu, 23 Jun 2022 12:05:07 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uba5Owu6UALC8hOSldqjn+HN73Xw4QKQc8GbEp3N7CVIngbCCbtTeqZRwEdM7gpE3CoUZc X-Received: by 2002:a63:b449:0:b0:40c:f5b5:639f with SMTP id n9-20020a63b449000000b0040cf5b5639fmr8920275pgu.48.1656011106843; Thu, 23 Jun 2022 12:05:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011106; cv=none; d=google.com; s=arc-20160816; b=ByyQFUqt/A85zCoZdo9yMKQc9MOQx7KE/qOogrHvLm+cp2D+O78ctdpx24DDYdMyfp l2doHjCE4xi9k/4KfS7gbHGn+N9WJZCN0jrEn13EASrClgty/tZHzPPmb8gd/iPznuHm J00xGi/+lmAiFAZJLoBzuI+aNeQnu4/hLpYX4NmCO4ApDcZ1fhgUjPM06Hu6w5ua4Bqe LgGivAclDUQ4N1beGcNPAM+hKFX/zD4Kb1u/0oq1RQMnHcmDiM3Da3flL6dlrnnlcnB2 pl6uy+z8JcfWU9ceKTfgIui8sxY0cM2gBL6nVCMh1OYDcY1RkSriaMB85xLPfciKDbkz QL8g== 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=nmLwIn8AMUf6VE66+BLEmWlLi9N8+k/ZEzIjmjPkqcA=; b=EpgPZsgpjMLaaP0Cn0yR7J/K+4qli3dld2KNx1iuAXaJAIB7bScOyNalahZUDJ5/eh VCxLyxPLCMPc1nOgSIxUMi5sd2FUN8665Jew5edLBjYWS78YLnklIiR65BW7lrocFT7r rkjW966NKG7WWzjkAbRCdbvJlTrj3yngrifomuQP0zW+qG2lkGxpIRoB1SzRkZNrwVHb 5FjHMoJsyr+q8HHH0BauMMLW3ifAKnwPLx0GH0LRI1ascLBadBlkhUYYg5N80MWFk7f0 fF+QSy0oBeXWlghJjBnCaNm6+rgW1xvob8iONx6Lthe8AyYo72sWkV1ZpMkO3kHeFJa+ 4Srg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xEyeh9ib; 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 d1-20020aa797a1000000b005252bb2fda9si7664pfq.71.2022.06.23.12.04.55; Thu, 23 Jun 2022 12:05:06 -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=xEyeh9ib; 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 S236328AbiFWSKN (ORCPT + 99 others); Thu, 23 Jun 2022 14:10:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233369AbiFWSGI (ORCPT ); Thu, 23 Jun 2022 14:06:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D93C860C48; Thu, 23 Jun 2022 10:18:12 -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 ams.source.kernel.org (Postfix) with ESMTPS id B3A77B824B9; Thu, 23 Jun 2022 17:18:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FEEFC341C5; Thu, 23 Jun 2022 17:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656004689; bh=fBU7IPs0E+Na+OQLrUJRsGKxqjI7vklE+yq1nJxbwYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xEyeh9ibXQvE2OPI7LeDCB6hHjDttvRvouxk/1+VwGMem/1sFK/TcHNYN8jp7GngR 43OZdygok2RUgnA6SUzLz3cUEEEIBbZrgbB2FcpCSOOP6YCcVRosc/wq0hNzHFNn0E tR0i2y5Z3kvRPMzVq647wZAsp1wkdLc+q7ZGdlY8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Theodore Tso , Dominik Brodowski , "Jason A. Donenfeld" Subject: [PATCH 4.19 117/234] random: dont let 644 read-only sysctls be written to Date: Thu, 23 Jun 2022 18:43:04 +0200 Message-Id: <20220623164346.369104038@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 77553cf8f44863b31da242cf24671d76ddb61597 upstream. We leave around these old sysctls for compatibility, and we keep them "writable" for compatibility, but even after writing, we should keep reporting the same value. This is consistent with how userspaces tend to use sysctl_random_write_wakeup_bits, writing to it, and then later reading from it and using the value. Cc: Theodore Ts'o Reviewed-by: Dominik Brodowski Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1662,6 +1662,13 @@ static int proc_do_uuid(struct ctl_table return proc_dostring(&fake_table, 0, buffer, lenp, ppos); } +/* The same as proc_dointvec, but writes don't change anything. */ +static int proc_do_rointvec(struct ctl_table *table, int write, void __user *buffer, + size_t *lenp, loff_t *ppos) +{ + return write ? 0 : proc_dointvec(table, 0, buffer, lenp, ppos); +} + extern struct ctl_table random_table[]; struct ctl_table random_table[] = { { @@ -1683,14 +1690,14 @@ struct ctl_table random_table[] = { .data = &sysctl_random_write_wakeup_bits, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = proc_do_rointvec, }, { .procname = "urandom_min_reseed_secs", .data = &sysctl_random_min_urandom_seed, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = proc_do_rointvec, }, { .procname = "boot_id",