Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1049886yba; Tue, 2 Apr 2019 00:56:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+X9v5WmzQIukS0MsQ96O+aAS1ui/WxpASTYGxj5S0TdAiUsQKKJ+KyfGekolnwiDjZGA+ X-Received: by 2002:a17:902:b210:: with SMTP id t16mr45367651plr.84.1554191788534; Tue, 02 Apr 2019 00:56:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554191788; cv=none; d=google.com; s=arc-20160816; b=vhkqXPOYfTb6TVrq6shsWkgEaGWcPS/kUIAJhI5pzGR0LMjlZxAmg5dNSXACv1VtQs bDzTa1VlOgLe3+uzQiaVev2A+5z5U656gZnwrVIgHtPfkWjmlhbuJFekTGI7rihNr8na mkaWgFTQtp82Eecb71Nh0E/PL7QZFDN54O/OXzNvMn7NpIdz86Ty6PhJxXWCx6Bj1J+n J0irdmykr1iZRVX82p5afD7NwrKXp41lqCNWJIofblQ3MxVRBwu3G0HzttFJm8UDKgl1 KzNw8ss4aZ9l78ezh2P7ectyON3xMiyaX6INKUUvEoEfuBZ0SUTUpMSc6cyuTOx6oDIn uMUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/+CIpKJJox4EkuvzaMU0mH8JnfDNrkf5xJ/FuG90arQ=; b=Rcd860vmtiPNA8itOOXUERpmF5Z3g9d/CpXO2ARaccSLlIN9gXVq5NWsd+blvHexYM 94KyZtFceylquqoXlNcrVwQK3mwYmGI4TVLg9ynK8xW/G4lEKlT5WtYVqZHiZux1i+Iv SBsCgIW4B9EPDtddqQmOzqxdtGNs0CDie9r0sA8FYX9nsTCWCqVVK2TXVTLj8P472/uq d54i30dNnFXhJWFaE1eYYeFs4dAFNzJR2xtAjQKNhA/1a+4xIigk8Ln9HbvdB8adQjPE nw+lWkE3fKQnaKTtPgFHSaCBFmeaSNCHcfiljP3gB4x8PA54issw+3BYWog6YMXPXC9A d39g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NJcwxYel; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y18si10408935pfe.72.2019.04.02.00.56.12; Tue, 02 Apr 2019 00:56:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NJcwxYel; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729347AbfDBHfk (ORCPT + 99 others); Tue, 2 Apr 2019 03:35:40 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:46673 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727021AbfDBHfj (ORCPT ); Tue, 2 Apr 2019 03:35:39 -0400 Received: by mail-pf1-f195.google.com with SMTP id 9so5905032pfj.13 for ; Tue, 02 Apr 2019 00:35:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/+CIpKJJox4EkuvzaMU0mH8JnfDNrkf5xJ/FuG90arQ=; b=NJcwxYel4CSGRJDydgzvH0wwBuSbkhLKck2BfOiRigsn3TC+5KFQ9ysCQz3R1KzGPo 357mqh9AFFu49sEpFmcChbG3PqnsWZHlBS2Ag/VMZQ7Mmtl42qscWyruhOwi/eZepSkx B3srudRgD1R79hCoFIYblhKuweNrsvdcET5jx/jKXx4h45gUQcWZWLrwRFobMgcwf5JH H9OiShVHDoDDPisGg2qOdAVfD0wZFGNn+9a6itvN+1WACRzs+ghOGrsLPzECg9CXgMRD abhzyD6y6x+nNQ9RKtqWKTeQeTs0Q6IFQ4qrl/zcKPcp38MRGt495ii4fEeBUWpxJUQE eb4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/+CIpKJJox4EkuvzaMU0mH8JnfDNrkf5xJ/FuG90arQ=; b=TC2poWzu4fOdHSmvzpAqq5wcqMtacGtYDN+Z7FAklqgGkE2zda2SYN7wR7t95chAfi 1zIYSXBrPiy+aN7oLIQsbLhkSyY5vcpCMnGRXVkMLPlAvSXoZFWTNQCj5I7Pl5A5XVNO b+Y8cUgjmVDBet7hTWQmilXF5NYd5sm8FBfJtfKa79B4lbwaUC0eDokQ1XN5rcKl1Fn9 YU9GPEdzA6xzKSTI1RcucOY1J2RcZVoRanWTAfXdnTkqCxTjWZlGmW/oNtt+dDc/CgQz gx2jCVCIeVxnfIUszBjL9LDO7MVMhWOalYX/d0kW/yD9I3IJZUA9TmlG898hGUlVNGz3 abLA== X-Gm-Message-State: APjAAAVO4po/RvGUaanoqe+LZsmqKuuoDBbxRjyuCfh0Q4lRQCIdUD9e ij59DtWO429vmsPkZ4N/Hq3lpA== X-Received: by 2002:a63:195f:: with SMTP id 31mr55032834pgz.116.1554190538811; Tue, 02 Apr 2019 00:35:38 -0700 (PDT) Received: from centauri ([147.50.13.10]) by smtp.gmail.com with ESMTPSA id e126sm10694721pfh.35.2019.04.02.00.35.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Apr 2019 00:35:36 -0700 (PDT) Date: Tue, 2 Apr 2019 09:35:31 +0200 From: Niklas Cassel To: Srinivas Kandagatla Cc: Gaurav Kohli , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH v2] nvmem: core: Set no-read-write provider to avoid userspace read/write Message-ID: <20190402073531.GA25959@centauri> References: <1552831940-7327-1-git-send-email-gkohli@codeaurora.org> <48a71861-c60b-7fe7-d4af-5269cd7c20eb@linaro.org> <5f11070f-bf9b-c313-9a78-e412a2fb2908@codeaurora.org> <865519b5-62c9-3eb3-3855-eebf98bded85@linaro.org> <68755fdb-b2c6-ac25-a786-7593a692a173@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 22, 2019 at 03:02:11PM +0000, Srinivas Kandagatla wrote: > > > On 20/03/2019 17:50, Gaurav Kohli wrote: > > > > > Is root only option not helping you in this case? > > Yes we want to protect at root level as well, i mean it is better if we > > can avoid exposing to userspace at all. > Can you try below patch! > > > > > > > We could go down the route of adding new config option something > > > like CONFIG_NVMEM_NO_SYSFS_ENTRY to prevent adding nvmem entry in > > > userspace. > > > > > > Let me know if you are happy to create a patch for this change? > > > > I am happy with either way config option or dt binding(seems easy), > > please let me know we will post new patch for the same. > DT way is totally NAK. > > > --------------------------->cut<----------------------------------- > > From: Srinivas Kandagatla > Date: Wed, 20 Mar 2019 16:15:21 +0000 > Subject: [PATCH] nvmem: core: add support to NVMEM_NO_SYSFS_ENTRY > > Some users might not want to expose nvmem entry to sysfs and > only intend to use kernel interface so add such provision. > > Signed-off-by: Srinivas Kandagatla > --- > Documentation/ABI/stable/sysfs-bus-nvmem | 2 ++ > drivers/nvmem/Kconfig | 5 +++++ > drivers/nvmem/core.c | 11 ++++++----- > 3 files changed, 13 insertions(+), 5 deletions(-) > > diff --git a/Documentation/ABI/stable/sysfs-bus-nvmem > b/Documentation/ABI/stable/sysfs-bus-nvmem > index 5923ab4620c5..12aab0a85fea 100644 > --- a/Documentation/ABI/stable/sysfs-bus-nvmem > +++ b/Documentation/ABI/stable/sysfs-bus-nvmem > @@ -6,6 +6,8 @@ Description: > This file allows user to read/write the raw NVMEM contents. > Permissions for write to this file depends on the nvmem > provider configuration. > + Note: This file is not present if CONFIG_NVMEM_NO_SYSFS_ENTRY > + is enabled > > ex: > hexdump /sys/bus/nvmem/devices/qfprom0/nvmem > diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig > index 0a7a470ee859..6ab3276d287c 100644 > --- a/drivers/nvmem/Kconfig > +++ b/drivers/nvmem/Kconfig > @@ -192,4 +192,9 @@ config SC27XX_EFUSE > This driver can also be built as a module. If so, the module > will be called nvmem-sc27xx-efuse. > > +config NVMEM_NO_SYSFS_ENTRY > + bool "No nvmem sysfs entry" > + > + help > + Say Yes if you do not want to add nvmem entry to sysfs. > endif Hello Srini, doesn't it make sense to instead have a CONFIG_NVMEM_SYSFS, maked as default y, that way the default behavior will be the same, and people not wanting it can explicitly disable it. This also aligns with how it's done in other drivers: $ grep SYSFS .config # CONFIG_SYSFS_DEPRECATED is not set CONFIG_SYSFS_SYSCALL=y # CONFIG_DMI_SYSFS is not set # CONFIG_FW_CFG_SYSFS is not set # CONFIG_ISCSI_BOOT_SYSFS is not set # CONFIG_GPIO_SYSFS is not set # CONFIG_WATCHDOG_SYSFS is not set CONFIG_EDAC_LEGACY_SYSFS=y CONFIG_RTC_INTF_SYSFS=y CONFIG_CROS_EC_SYSFS=m # CONFIG_IIO_SYSFS_TRIGGER is not set CONFIG_PWM_SYSFS=y CONFIG_SYSFS=y Kind regards, Niklas > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > index b9a0270883a0..c70f183fe379 100644 > --- a/drivers/nvmem/core.c > +++ b/drivers/nvmem/core.c > @@ -216,7 +216,7 @@ static const struct attribute_group nvmem_bin_rw_group = > { > .attrs = nvmem_attrs, > }; > > -static const struct attribute_group *nvmem_rw_dev_groups[] = { > +static const __maybe_unused struct attribute_group *nvmem_rw_dev_groups[] = > { > &nvmem_bin_rw_group, > NULL, > }; > @@ -240,7 +240,7 @@ static const struct attribute_group nvmem_bin_ro_group = > { > .attrs = nvmem_attrs, > }; > > -static const struct attribute_group *nvmem_ro_dev_groups[] = { > +static const __maybe_unused struct attribute_group *nvmem_ro_dev_groups[] = > { > &nvmem_bin_ro_group, > NULL, > }; > @@ -265,7 +265,7 @@ static const struct attribute_group > nvmem_bin_rw_root_group = { > .attrs = nvmem_attrs, > }; > > -static const struct attribute_group *nvmem_rw_root_dev_groups[] = { > +static const __maybe_unused struct attribute_group > *nvmem_rw_root_dev_groups[] = { > &nvmem_bin_rw_root_group, > NULL, > }; > @@ -289,7 +289,7 @@ static const struct attribute_group > nvmem_bin_ro_root_group = { > .attrs = nvmem_attrs, > }; > > -static const struct attribute_group *nvmem_ro_root_dev_groups[] = { > +static const __maybe_unused struct attribute_group > *nvmem_ro_root_dev_groups[] = { > &nvmem_bin_ro_root_group, > NULL, > }; > @@ -688,6 +688,7 @@ struct nvmem_device *nvmem_register(const struct > nvmem_config *config) > nvmem->read_only = device_property_present(config->dev, "read-only") | > config->read_only; > > +#if !defined(CONFIG_NVMEM_NO_SYSFS_ENTRY) > if (config->root_only) > nvmem->dev.groups = nvmem->read_only ? > nvmem_ro_root_dev_groups : > @@ -696,7 +697,7 @@ struct nvmem_device *nvmem_register(const struct > nvmem_config *config) > nvmem->dev.groups = nvmem->read_only ? > nvmem_ro_dev_groups : > nvmem_rw_dev_groups; > - > +#endif > device_initialize(&nvmem->dev); > > dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name); > -- > 2.21.0 > > --------------------------->cut<-----------------------------------