I noticed that the Raspberry Pi kernel adopted /dev/gpiomem to provide a way for non-root users to access GPIO:
sudo sh -c"echo '1' > /sys/class/gpio/gpio67/value"
The above can be made to run without using a passwd. So what this *is* is a way to allow a very specific command to be run
as root, without using a passwd. What this *is not* is a way to secure somethign similar on a multi user system.
So this method does have it's perks, e.g. allowing a very specific command, say read a GPIO value, that is not really a security
risk, while the rest of the GPIO bank could represent an issue.
I do believe one can achieve something very similar to what I suggest above using udev rules, but I'm honestly not all that well
versed with udev. . .
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
This is why Unix/Linux has groups. Do the following:
echo '1' > /sys/class/gpio/gpio67/value /* allowed */
echo '0' > /sys/class/gpio/gpio67/value /* not allowed */
Obviously the above is very contrived, but there can be a need for something similar.
Groups are frequently used to restrict access to resources. Android exploits groups for permissions and to sandbox applications. And the kernel enforces access.
Using sudo seems much less secure as it exposes the application to being exploited for security flaws. And since the application is running as root, it has access to everything.
But maybe I'm missing something?
ba
Using sudo seems much less secure as it exposes the application to being exploited for security flaws. And since the application is running as root, it has access to everything.
So, we have a device on a system that can potentially cause physical damage to external hardware when something like a wrong GPIO state is toggled, or such. How would sudo be less secure in this context?Using sudo seems much less secure as it exposes the application to being exploited for security flaws. And since the application is running as root, it has access to everything.
In fact under certain conditions it would be less safe using groups.
Also, "root has access to everything" is wrong. Reread what I've written above about running specific commands through sudo.
My comments are really to do with what I perceive as best practices on how one would approach building systems that are "security conscious". Of course, "convenience" may direct us in different directions during development. I am not sure what you are trying to imply by "safe" as in protecting the GPIOs from misuse. I don't actually see any way to accomplish that. What I do think one can do is to be aware of security considerations and not unnecessarily present an attack surface that can compromise the entire system.
So, we have a device on a system that can potentially cause physical damage to external hardware when something like a wrong GPIO state is toggled, or such. How would sudo be less secure in this context?Using sudo seems much less secure as it exposes the application to being exploited for security flaws. And since the application is running as root, it has access to everything.
It wouldn't. And that is not my point. I am not talking about how to protect the GPIOs from "bad behaved" programs that are "trusted" as implied by the fact that they are running as a normal user in the group that has access to those GPIOs. If an application is trusted (is a member of the appropriate group or for that matter can sudo), it is a hopeless task to protect the GPIOs from misuse. What I am trying to point out is that running an app as "root" (sudo, set uid, whatever) exposes a security attack vector...a vector that has access to _all_ system resources. I would claim that it is an unnecessary exposure...from a security point of view. YMMV when it comes to "convenience".
In fact under certain conditions it would be less safe using groups.
How would an application running at a non-root level using groups to access protected resources be less "safe" than an application running as root using sudo?
Also, "root has access to everything" is wrong. Reread what I've written above about running specific commands through sudo.
Errr, an application running as root, by definition, has access to _all_ system resources. The fact that you are limiting just a single application/user to run sudo doesn't limit the attack surface for that application. If your root application is compromised in some way, then the entire system can be compromised. Running as a normal user does not present the same attack surface...its much smaller and sandboxed by the kernel. Running as root affords no protection enforcement by the kernel.
ba
On Fri, Feb 5, 2016 at 6:05 PM, Brian Anderson <b...@nwlink.com> wrote:
Err, why?
Groups are frequently used to restrict access to resources. Android exploits groups for permissions and to sandbox applications. And the kernel enforces access.
Using sudo seems much less secure as it exposes the application to being exploited for security flaws. And since the application is running as root, it has access to everything.
But maybe I'm missing something?
ba
... to provide a way for non-root users to access GPIO:
...
Anyone have ideas/plans?
I call my success partial because I can get a test LED to turn on, but I can't get it to flash using PWM.Any ideas why that would be?
--
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/Ca7QDUwv72g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.
chgrp pruio /dev/uio5chmod g+rw /dev/uio5