From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BDABC64EB5 for ; Tue, 2 Oct 2018 09:47:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 330222089A for ; Tue, 2 Oct 2018 09:47:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 330222089A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=st.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727396AbeJBQ3h (ORCPT ); Tue, 2 Oct 2018 12:29:37 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:52019 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726884AbeJBQ3g (ORCPT ); Tue, 2 Oct 2018 12:29:36 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w929OGsI005322; Tue, 2 Oct 2018 11:47:07 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2mu1bjs1q1-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 02 Oct 2018 11:47:07 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4F6383A; Tue, 2 Oct 2018 09:47:06 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0572C26A1; Tue, 2 Oct 2018 09:47:05 +0000 (GMT) Received: from [10.201.23.162] (10.75.127.45) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 2 Oct 2018 11:47:04 +0200 Subject: Re: [PATCH 4/5] remoteproc: Introduce deny_sysfs_ops flag To: Suman Anna , Bjorn Andersson CC: Ohad Ben-Cohen , Loic Pallardy , , References: <20180915003725.17549-1-s-anna@ti.com> <20180915003725.17549-5-s-anna@ti.com> From: Arnaud Pouliquen Openpgp: preference=signencrypt Autocrypt: addr=arnaud.pouliquen@st.com; prefer-encrypt=mutual; keydata= xsFNBFZu+HIBEAC/bt4pnj18oKkUw40q1IXSPeDFOuuznWgFbjFS6Mrb8axwtnxeYicv0WAL rWhlhQ6W2TfKDJtkDygkfaZw7Nlsj57zXrzjVXuy4Vkezxtg7kvSLYItQAE8YFSOrBTL58Yd d5cAFz/9WbWGRf0o9MxFavvGQ9zkfHVd+Ytw6dJNP4DUys9260BoxKZZMaevxobh5Hnram6M gVBYGMuJf5tmkXD/FhxjWEZ5q8pCfqZTlN9IZn7S8d0tyFL7+nkeYldA2DdVplfXXieEEURQ aBjcZ7ZTrzu1X/1RrH1tIQE7dclxk5pr2xY8osNePmxSoi+4DJzpZeQ32U4wAyZ8Hs0i50rS VxZuT2xW7tlNcw147w+kR9+xugXrECo0v1uX7/ysgFnZ/YasN8E+osM2sfa7OYUloVX5KeUK yT58KAVkjUfo0OdtSmGkEkILWQLACFEFVJPz7/I8PisoqzLS4Jb8aXbrwgIg7d4NDgW2FddV X9jd1odJK5N68SZqRF+I8ndttRGK0o7NZHH4hxJg9jvyEELdgQAmjR9Vf0eZ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3ZrD3SSZVa+LhYfijFYuEgKjs4s+Dvk/xVL0JYWbKkpGWRz5M82 Pj7co6u8pTEReGBYSVUBHx7GF1e3L/IMZZMquggEsixD8CYMOzahCEZ7UUwD5LKxRfmBWBgK 36tfTyducLyZtGB3mbJYfWeI7aiFgYsd5ehov6OIBlOz5iOshd97+wbbmziYEp6jWMIMX+Em zqSvS5ETZydayO5JBbw7fFBd1nGVYk1WL6Ll72g+iEnqgIckMtxey1TgfT7GhPkR7hl54ZAe 8mOik8I/F6EW8XyQAA2P Message-ID: <36e85566-69e5-0a3a-edf1-6e0cfd8b388b@st.com> Date: Tue, 2 Oct 2018 11:47:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180915003725.17549-5-s-anna@ti.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG7NODE3.st.com (10.75.127.21) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-02_02:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Suman, On 09/15/2018 02:37 AM, Suman Anna wrote: > The remoteproc framework provides sysfs interfaces for changing > the firmware name and for starting/stopping a remote processor > through the sysfs files 'state' and 'firmware'. These interfaces > are currently allowed irrespective of how the remoteprocs were > booted (like remoteproc self auto-boot, remoteproc client-driven > boot etc). These interfaces can adversely affect a remoteproc > and its clients especially when a remoteproc is being controlled > by a remoteproc client driver(s). Also, not all remoteproc > drivers may want to support the sysfs interfaces by default. > > Add support to deny the sysfs state/firmware change by introducing > a state flag 'deny_sysfs_ops' that the individual remoteproc drivers > can set based on their usage needs. The default behavior is to > allow the sysfs operations as before. > > Signed-off-by: Suman Anna > --- > drivers/remoteproc/remoteproc_sysfs.c | 8 ++++++++ > include/linux/remoteproc.h | 2 ++ > 2 files changed, 10 insertions(+) > > diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c > index ce93f4d710f3..b2d8c11b89d0 100644 > --- a/drivers/remoteproc/remoteproc_sysfs.c > +++ b/drivers/remoteproc/remoteproc_sysfs.c > @@ -36,6 +36,10 @@ static ssize_t firmware_store(struct device *dev, > char *p; > int err, len = count; > > + /* restrict sysfs operations if not allowed by remoteproc drivers */ > + if (rproc->deny_sysfs_ops) > + return -EPERM; > + > err = mutex_lock_interruptible(&rproc->lock); > if (err) { > dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, err); > @@ -102,6 +106,10 @@ static ssize_t state_store(struct device *dev, > struct rproc *rproc = to_rproc(dev); > int ret = 0; > > + /* restrict sysfs operations if not allowed by remoteproc drivers */ > + if (rproc->deny_sysfs_ops) > + return -EPERM; > + > if (sysfs_streq(buf, "start")) { > if (rproc->state == RPROC_RUNNING) > return -EBUSY; > diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h > index 75f9ca05b865..d21252b4f758 100644 > --- a/include/linux/remoteproc.h > +++ b/include/linux/remoteproc.h > @@ -440,6 +440,7 @@ struct rproc_dump_segment { > * @table_sz: size of @cached_table > * @has_iommu: flag to indicate if remote processor is behind an MMU > * @auto_boot: flag to indicate if remote processor should be auto-started > + * @deny_sysfs_ops: flag to not permit sysfs operations on state and firmware > * @dump_segments: list of segments in the firmware > */ > struct rproc { > @@ -472,6 +473,7 @@ struct rproc { > size_t table_sz; > bool has_iommu; > bool auto_boot; > + bool deny_sysfs_ops; > struct list_head dump_segments; > }; I'm concerned about granularity. Are we denying all write access to the state and the firmware name? Would it be interesting to have a bit-field to separately allow/deny write access: - to change the firmware name - to start the firmware - to stop the firmware ? For instance, if firmware is stored in the file system, the auto_boot mode is not functional (if remote proc in built-in). We could have to allow user application to start the firmware, but deny to change the firmware name or stop it. Regards Arnaud > >