Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4614558imw; Tue, 19 Jul 2022 09:50:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v8R7jLg18sgw67rhRnn6yaYhYvGMAvfxstfRlGMbYm2vF2M7ddeZUIvorQSTHoOyECAhRr X-Received: by 2002:a17:907:734a:b0:72b:7c72:e6b3 with SMTP id dq10-20020a170907734a00b0072b7c72e6b3mr30344997ejc.608.1658249416979; Tue, 19 Jul 2022 09:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658249416; cv=none; d=google.com; s=arc-20160816; b=hyZuYOrW+q1FTIkRqFFroIhVyefSbOWihPF1/VmPBqirRhcCGYSoFjqlzZm/dJD9U6 Ggiq/D/DP9pSxWIdWk+WUV9h4mCoSaULyI3K4J9Qc40Fx4qAc6LRru91YU/CbUvyazAn O8kFECfdVWKRYE0xgdxIZYBSSPnzn+lrVTj6tUdSEO1UxA8DznDaHy6jfbAGlSp7OQA6 f2Rd463kTfUJBZ9IX31+199RftsRWK7CsElnUdbeCLQ6Mq7pPD8YK8gy0bWXm0XEid1c cdhDwbuTGIHTz3ZyNhA3B+cZzA2IDr7DEAsZ5eXerC7Z9YowGada8ArhOkqrZAOPRxxA yaGA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=ta3ryZSlqExzxUmLFgSxuRmX94hyX7rAo8QlrKosoFo=; b=pQByCtKdY/6B3WQWIENoSLQJ3LMUcfIOzCZPfpKMRtgmIAXpZ6qoKZKh8U3UWXG+9Y Op7qkMOVpVytj4c/LnZFl1XnBxsgQu07W0yUzwKKFj8TbwOg7lWp0XUj9NBbkT/asztE 0HDdDjqw7Z4OvFJZBHZzjwC3W24UCxaf335rl/tTqd2lI+7LMH+nmnavQbt9v4I6PqtF c4ZsF5bhLQI9lBX5YbUDHCkgawvcVVsTy55ggJwnEG9w7bRPYmYZFAbvJZqTRZUV0M6I UAiIR6KbXDFX+B+/R29JFGyu4vtn5/d76lD/a2sh37BavYJhSxNx/OD2ZCFDNzcXcybQ mdPA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp23-20020a1709073e1700b0072b3b8d31f8si22844965ejc.63.2022.07.19.09.49.51; Tue, 19 Jul 2022 09:50: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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229936AbiGSQjQ convert rfc822-to-8bit (ORCPT + 99 others); Tue, 19 Jul 2022 12:39:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbiGSQjK (ORCPT ); Tue, 19 Jul 2022 12:39:10 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 387903AB3B; Tue, 19 Jul 2022 09:39:09 -0700 (PDT) Received: from fraeml705-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4LnPYl67rsz6842y; Wed, 20 Jul 2022 00:34:35 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml705-chm.china.huawei.com (10.206.15.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.24; Tue, 19 Jul 2022 18:39:06 +0200 Received: from localhost (10.81.209.49) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 19 Jul 2022 17:39:06 +0100 Date: Tue, 19 Jul 2022 17:39:04 +0100 From: Jonathan Cameron To: CC: Dan Williams , Bjorn Helgaas , Krzysztof =?UTF-8?Q?Wilczy=C5=84ski?= , Greg Kroah-Hartman , Lukas Wunner , Alison Schofield , "Vishal Verma" , Dave Jiang , "Ben Widawsky" , , , Subject: Re: [PATCH V14 5/7] driver-core: Introduce BIN_ATTR_ADMIN_{RO,RW} Message-ID: <20220719173904.00005c9a@Huawei.com> In-Reply-To: <20220715030424.462963-6-ira.weiny@intel.com> References: <20220715030424.462963-1-ira.weiny@intel.com> <20220715030424.462963-6-ira.weiny@intel.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.29; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Originating-IP: [10.81.209.49] X-ClientProxiedBy: lhreml749-chm.china.huawei.com (10.201.108.199) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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 On Thu, 14 Jul 2022 20:04:22 -0700 ira.weiny@intel.com wrote: > From: Ira Weiny > > Many binary attributes need to limit access to CAP_SYS_ADMIN only; ie > many binary attributes specify is_visible with 0400 or 0600. > > Make setting the permissions of such attributes more explicit by > defining BIN_ATTR_ADMIN_{RO,RW}. > > Cc: Bjorn Helgaas > Suggested-by: Dan Williams > Suggested-by: Krzysztof WilczyƄski > Reviewed-by: Greg Kroah-Hartman > Signed-off-by: Ira Weiny Seems sensible. Reviewed-by: Jonathan Cameron > > --- > Changes from V12: > Pick up review tag > Bjorn: > NOTE: this has a lot of similarities to > https://lore.kernel.org/all/20210416205856.3234481-7-kw@linux.com/ > I'm not sure why that patch was not picked up. But I've > added Krzysztof as a suggested by if that is ok? > > Changes from V11: > New Patch > --- > include/linux/sysfs.h | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h > index e3f1e8ac1f85..fd3fe5c8c17f 100644 > --- a/include/linux/sysfs.h > +++ b/include/linux/sysfs.h > @@ -235,6 +235,22 @@ struct bin_attribute bin_attr_##_name = __BIN_ATTR_WO(_name, _size) > #define BIN_ATTR_RW(_name, _size) \ > struct bin_attribute bin_attr_##_name = __BIN_ATTR_RW(_name, _size) > > + > +#define __BIN_ATTR_ADMIN_RO(_name, _size) { \ > + .attr = { .name = __stringify(_name), .mode = 0400 }, \ > + .read = _name##_read, \ > + .size = _size, \ > +} > + > +#define __BIN_ATTR_ADMIN_RW(_name, _size) \ > + __BIN_ATTR(_name, 0600, _name##_read, _name##_write, _size) > + > +#define BIN_ATTR_ADMIN_RO(_name, _size) \ > +struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_RO(_name, _size) > + > +#define BIN_ATTR_ADMIN_RW(_name, _size) \ > +struct bin_attribute bin_attr_##_name = __BIN_ATTR_ADMIN_RW(_name, _size) > + > struct sysfs_ops { > ssize_t (*show)(struct kobject *, struct attribute *, char *); > ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t);