Message ID | 2023041810-angelic-conical-52d8@gregkh |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2872679vqo; Tue, 18 Apr 2023 07:01:17 -0700 (PDT) X-Google-Smtp-Source: AKy350bl/vHshCuY4RzOdXVDKTxvhi/AE4KeroHWPL/LKso5q/eg+QJlHLUeHoGzBXd/RN71FULN X-Received: by 2002:a17:90a:ce02:b0:246:94cf:6c26 with SMTP id f2-20020a17090ace0200b0024694cf6c26mr2108130pju.10.1681826476594; Tue, 18 Apr 2023 07:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681826476; cv=none; d=google.com; s=arc-20160816; b=T9Id7/BhJM7yNzhJBh1BgEyI41pXYzKBH1nUFQBktI/GYGomDqIQ5kHBr3bEj3UI41 Lhx2zkLHo4xLy95dpPUYPYer37h9sYb65eHWvItiAt48TL2WXNO+/ymFPlSMbqnWYS2B Z6jkcbUOKzBUkSc9Q7J7+rJu+4TDj8a5C+aZTwIsTbOG1D009YqZ5xRNMrLBlY4wp+et jMfaqnCHvbtbox7j1xOmge1oV+eHqVkF7R5vXAajMEs8QFf+/RiEUXsX+0lX2dRGSkXD 9QydduGl+QanXH5aIaYACUyy86ACySMIVLQ4Q9Aret9G1SmFLc3gI2aqeQWbU5dtv41k Ui8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:lines:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=HP+6MA+GFg4v9+qBrzHHtjz0yMc/n8N8nSKYPpT6FOA=; b=s5dNHCreUttnodnY31EEteHa1j0UpshbbFfGKfDGEI/VEy00Eo1zjlcLM7JBk64lpj bpt4zt+u/D+LW1AUM+wMebhJyoCnfcg2g0kldKaeXwWvRsLYrs9G6yppE7Qw+PiFZkFN LKajFMSZFIKxaRoJOLD7Gbs5J1P2FR5obIlCLT1ijRzC9udzuaSgol7VlJIi2UvRZfAD 7etjY9x9cS1fJIK79jdQyJ8E1siMhXNJoqvM9qm8PoY266w0loIg/2vL6k4WTSJ86Z3U BZsuod3Xb9ea8tuIbncVUzD/VrihEqvIzqWP+SRML3/+d7pIcYmkdZn2nDx+F0YGqA6S YJsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Q6a4v5FL; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ci23-20020a17090afc9700b0023b30b28b89si13600964pjb.56.2023.04.18.07.01.03; Tue, 18 Apr 2023 07:01:16 -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=Q6a4v5FL; 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 S232422AbjDRNra (ORCPT <rfc822;leviz.kernel.dev@gmail.com> + 99 others); Tue, 18 Apr 2023 09:47:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232186AbjDRNr1 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 18 Apr 2023 09:47:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 150AB125A7 for <linux-kernel@vger.kernel.org>; Tue, 18 Apr 2023 06:47:23 -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 90485634FE for <linux-kernel@vger.kernel.org>; Tue, 18 Apr 2023 13:47:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A865C433D2; Tue, 18 Apr 2023 13:47:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1681825643; bh=z6bziQOWX6ta9DQwSmPL8i4kjhV1G33KL8lW3/ZwuFI=; h=From:To:Cc:Subject:Date:From; b=Q6a4v5FL00efHxA4dSrTnY11Mr7uWQQ3zWozDGeBV/BMl0k/4g44m2DLZw4yLXZMF mBg7NOG36iinQwKs4FCgsvuvfwM/EwvI69DfxRJPrObEXitg+67yAmqb6n7MoRgehf E3k6KI5SqUhK+xaI88prLAG6jrVNj4qmqxE3cwhM= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Denis Efremov <efremov@linux.com> Subject: [PATCH] zram: fix up permission for the hot_add sysfs file Date: Tue, 18 Apr 2023 15:47:15 +0200 Message-Id: <2023041810-angelic-conical-52d8@gregkh> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Lines: 35 X-Developer-Signature: v=1; a=openpgp-sha256; l=1491; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=z6bziQOWX6ta9DQwSmPL8i4kjhV1G33KL8lW3/ZwuFI=; b=owGbwMvMwCRo6H6F97bub03G02pJDCl28+O8H6QZ/89wj/mgnlT27tnVL3zJXOxeNfdmGb6bu EiVrWN3RywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAEzkqy/D/Irtk97nnzTa8MjI yijjfFjNJOab8xnmB8ea+jevmFpyd2eezbN958M1dzFKAwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763522879670731875?= X-GMAIL-MSGID: =?utf-8?q?1763522879670731875?= |
Series |
zram: fix up permission for the hot_add sysfs file
|
|
Commit Message
Greg KH
April 18, 2023, 1:47 p.m. UTC
Commit 75a2d4226b53 ("driver core: class: mark the struct class for
sysfs callbacks as constant") changed the attribute to use
CLASS_ATTR_RO() which changed the permission from 0400 to 0444. But
this atribute is "special" in that reading it modifies the system state,
so it MUST be set to 0400 so that only root processes can muck around
with it.
Fix this all up, AND document this so that I don't change it again in
3-4 years when I stumble across it and wonder why it's an open-coded
_ATTR() macro.
Reported-by: Denis Efremov <efremov@linux.com>
Fixes: 75a2d4226b53 ("driver core: class: mark the struct class for sysfs callbacks as constant")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/block/zram/zram_drv.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 3feadfb96114..d8217529be6f 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -2438,7 +2438,9 @@ static ssize_t hot_add_show(const struct class *class, return ret; return scnprintf(buf, PAGE_SIZE, "%d\n", ret); } -static CLASS_ATTR_RO(hot_add); +/* This attribute must be set to 0400, so CLASS_ATTR_RO() can not be used */ +static struct class_attribute class_attr_hot_add = + __ATTR(hot_add, 0400, hot_add_show, NULL); static ssize_t hot_remove_store(const struct class *class, const struct class_attribute *attr,