Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6143165iog; Thu, 23 Jun 2022 12:14:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1trmRfimwB3uDoC6Hv/wEYCCthYBAGJsdImJCchRmcdB4tpgqazwmFxYPsAlPxyNHE/BHd+ X-Received: by 2002:a63:2ac5:0:b0:40d:62e8:87f1 with SMTP id q188-20020a632ac5000000b0040d62e887f1mr2527326pgq.539.1656011670780; Thu, 23 Jun 2022 12:14:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011670; cv=none; d=google.com; s=arc-20160816; b=Grj88LTMSt6tdbMqWyIwQrZt+Ig3il/s7sT4RJMbN+VDqTe53716FdKRl+9goYDx1v XlgU3FPRauSu5zcS9Bv3TVGG+hSJ+lYDb7ps2XocLr4PqkRlMXm3UlKiAcfkADd/QAF2 78P8knZDPeh0dlpfkfCufACRSXolPULMBLkUQIvQJpyPkoWKualTKr7Ok/a6HTrWIQKC lEp7Jhmk6jUPWaKXqi3TavIJ7jaye7bpfX7X3hC+XloFpxTgO0y5Z9Zkk1pQLeDwuDBw i+tjllmdmc5W+J7YFYuewJDani/EdcCBVXlioXcxwcZQIWK3EEpdWJ+LcCFS7ve+15zo KcVw== 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=n4WgBRcNkY0EKR5TIay81lStPE2DxtzrF3fQoEme4vk=; b=oBEoV3nfMEc7OhMBJpRs6fsUQYYl7DtIf90e5KWSVw0BfWCrDZbZt3X7mK2Vyc5YcT zCH2uT5fSQJuYpT3SmRu6fu++yWPON5hKsETs0NhcRCd2Vg7jrjfo5LVhmEtk+KrQc47 /YiJytpalgflEjOEvR5V3i/MYpbCjL69MKeCAEIpj4f75pWkeu21l3ZgMtexcy8KLzwG 76cou5BtmxJKf1JttI/wgRtJjbyEBbrQDi4EK/W4OFMoj8JJXnTZ8Pc/J6RjPYfk1Eo4 f9cGbu+Iy/VM1ZJrQJsbUZ6qZ23CEyyzDczsm4eWs+J11KDB0Po/zJ3Cr9KscUq3XYPt Rnzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lq4HnZg7; 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 d5-20020a170903230500b0016a03e09ddasi329415plh.605.2022.06.23.12.14.19; Thu, 23 Jun 2022 12:14:30 -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=lq4HnZg7; 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 S230475AbiFWRBt (ORCPT + 99 others); Thu, 23 Jun 2022 13:01:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233287AbiFWQ5m (ORCPT ); Thu, 23 Jun 2022 12:57:42 -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 D8FD84D63C; Thu, 23 Jun 2022 09:53:26 -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 C448461FC2; Thu, 23 Jun 2022 16:53:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C5DDC3411B; Thu, 23 Jun 2022 16:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656003196; bh=7430oTTUQqiKv+OG9VsykxknV6Vufulp3bf/aPDVebo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lq4HnZg7vg6i7LBx2YR2wj65x1gvVpJ7mPeo5FVjlcJTyurZsDYvTvgLHOPU5BpNm F6nXrqjpSduMyexp3htlBRAJ0oxhee9ntH3WYxRY2IcKe+mXSpSGaNiP4iaL2jBA+v TAQFhdpA00mqrOckU7QOJQBJt0rBBxo4uN7/jYmQ= 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.9 160/264] random: dont let 644 read-only sysctls be written to Date: Thu, 23 Jun 2022 18:42:33 +0200 Message-Id: <20220623164348.589759301@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 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 @@ -1663,6 +1663,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[] = { { @@ -1684,14 +1691,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",