linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Niedermayr, BENEDIKT" <benedikt.niedermayr@siemens.com>
To: "andriy.shevchenko@intel.com" <andriy.shevchenko@intel.com>
Cc: "linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	"Kiszka, Jan" <jan.kiszka@siemens.com>
Subject: Re: Question regarding runtime pinctrl (2nd try)
Date: Mon, 5 Dec 2022 10:47:27 +0000	[thread overview]
Message-ID: <21ea48401aa3d652a379bf6aa412c660d3f4f0e5.camel@siemens.com> (raw)
In-Reply-To: <Y4d6OosnHIDB2h6s@smile.fi.intel.com>

Hi Andy,
thanks for the response!

On Wed, 2022-11-30 at 17:43 +0200, Andy Shevchenko wrote:
> On Wed, Nov 30, 2022 at 03:09:50PM +0000, Niedermayr, BENEDIKT wrote:
> > Hello,
> > 
> > I got no response since last time so I try it again, but with a bit more
> > knowledge this time.
> > 
> > After carefully reading the pinctrl documentation
> > (driver-api/pin-control.rst) it was very clear for me that such an interface
> > already exists and is accessable via debugfs. The documentation is very clear
> > and self-explanatory. Thanks for that!
> > At the time of writing my last email [1] I took a look into an older BSP
> > kernel where this feature has not been implemented, yet. I must apologize for
> > that...
> > 
> > Now my last concern is using debugfs on a productive system. IMHO debugfs is
> > not the right interface to interact on a productive system.
> 
> And this is a point. No-one should try it on the production systems.
> 
> > Especially when
> > when a unprivileged process wants to interact with an interface offered by
> > debugfs. It's possible to change
> > permissions on files and folders there but nevertheless I think that this is
> > not the way to go, since debugfs was designed to offer interfaces to
> > privileged processes only.
> 
> Correct.
> 
> > My proposal would be to implement an chardev interface for that and using
> > udev rules to assign correct permissions to that. With this interface I can
> > then select the active pinctrl-groups which have been defined in the device
> > tree before.
> > I could also imagine to put the interface into the sysfs (that would be very
> > close to the debugfs implementation I think).
> > 
> > What do you think about it? Am I still missing something?
> 
> In my opinion -- no go.
> 
> The platform description (ACPI, DT, or board files) should know what they are
> doing. If something missing to achieve what you need via existing interfaces
> we rather think about that, but no, the debugfs stays and only for the purposes
> of development on the "I know what I'm doing" basis.
> 
Ok. If I got you right, you meant that there is no way to replace the debugfs interface?

So instead replacing the debugfs interface I would rather add a second interface that coexists with
debugfs.  

Unfortunatelly there is no interface available for runtime configuration, yet. The only alternative 
is to access "/dev/mem", but this is the most questionable solution from a security perspective.
There should be a way to avoid unsecure "/dev/mem" implementations but currently this is the only
way to achieve runtime configuration with reasonable effort. 
IMHO the current architecture leads to lot of unsecure implementations out there.

For example the raspberrypi kernel tries to workaround this issue by providing a "/dev/gpiomem"
interface that only provides mappings to the gpio register set(drivers/char/broadcom/bcm2835-gpiomem.c). 
This reduces possible vulnerabilities but they still persist since:

- mmap() cannot map memory less than PAGE_SIZE, which means that memory outside of the GPIO registers is accessable. 
- it's possible to select untested  pin configurations which may not be electrical fine.


I like the current architecture since I define pingroups in the platform description which have been tested and 
then select one of them during runtime.
It's just the interface itself which is not sufficient enough when it comes to security.  

> > [1] https://marc.info/?l=linux-gpio&m=166850640920120


cheers,
Benedikt


  reply	other threads:[~2022-12-05 10:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30 15:09 Question regarding runtime pinctrl (2nd try) Niedermayr, BENEDIKT
2022-11-30 15:43 ` Andy Shevchenko
2022-12-05 10:47   ` Niedermayr, BENEDIKT [this message]
2022-12-05 12:58     ` andriy.shevchenko
2022-12-07 12:02       ` Niedermayr, BENEDIKT
2022-12-07 20:38         ` andriy.shevchenko
2022-12-09 12:47           ` Niedermayr, BENEDIKT
2022-12-09 14:39             ` andriy.shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21ea48401aa3d652a379bf6aa412c660d3f4f0e5.camel@siemens.com \
    --to=benedikt.niedermayr@siemens.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=jan.kiszka@siemens.com \
    --cc=linux-gpio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).