All of lore.kernel.org
 help / color / mirror / Atom feed
* Writing to /sys/../power/autosuspend when not root.
@ 2020-04-26 19:08 Dave Mielke
  2020-04-27 10:30 ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: Dave Mielke @ 2020-04-26 19:08 UTC (permalink / raw)
  To: linux-usb; +Cc: Samuel Thibault, Nicolas Pitre

We're working on getting brltty to run as an unprivileged user with just a few
required capabilities. We don't want one of those required capabilities to be
CAP_DAC_OVERRIDE (bypass file permission checks).

Some USB-connected braille devices don't respond very well to being
autosuspended. We get around this, when running as root, by writing to the
SYSFS power/autosuspend file associated with the device. Our problem is that
only the root user can write to it.

Other than using CAP_DAC_OVERRIDE (which we don't want to do), what other
way(s) might we be able to use to overcome this restriction? For example, is
there some kind of safe (enough) udev rule?

-- 
I believe the Bible to be the very Word of God: http://Mielke.cc/bible/
Dave Mielke            | 2213 Fox Crescent | WebHome: http://Mielke.cc/
EMail: Dave@Mielke.cc  | Ottawa, Ontario   | Twitter: @Dave_Mielke
Phone: +1 613 726 0014 | Canada  K2A 1H7   |

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Writing to /sys/../power/autosuspend when not root.
  2020-04-26 19:08 Writing to /sys/../power/autosuspend when not root Dave Mielke
@ 2020-04-27 10:30 ` Greg KH
  2020-04-27 14:27   ` Alan Stern
  2020-04-28  9:26   ` Dave Mielke
  0 siblings, 2 replies; 7+ messages in thread
From: Greg KH @ 2020-04-27 10:30 UTC (permalink / raw)
  To: Dave Mielke; +Cc: linux-usb, Samuel Thibault, Nicolas Pitre

On Sun, Apr 26, 2020 at 03:08:38PM -0400, Dave Mielke wrote:
> We're working on getting brltty to run as an unprivileged user with just a few
> required capabilities. We don't want one of those required capabilities to be
> CAP_DAC_OVERRIDE (bypass file permission checks).
> 
> Some USB-connected braille devices don't respond very well to being
> autosuspended. We get around this, when running as root, by writing to the
> SYSFS power/autosuspend file associated with the device. Our problem is that
> only the root user can write to it.
> 
> Other than using CAP_DAC_OVERRIDE (which we don't want to do), what other
> way(s) might we be able to use to overcome this restriction? For example, is
> there some kind of safe (enough) udev rule?

Have a udev rule that turns autosuspend off for each specific USB device
that you know does not work with autosuspend.  Do you have such a list?

If so, we can add it to the USB core with the
USB_QUIRK_DISCONNECT_SUSPEND flag.  Or is it the USB_QUIRK_NO_LPM that
they need?  I can't remember, but you can test it out from userspace
by reading about those in the
Documentation/admin-guide/kernel-parameters.txt file.

Hope this helps,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Writing to /sys/../power/autosuspend when not root.
  2020-04-27 10:30 ` Greg KH
@ 2020-04-27 14:27   ` Alan Stern
  2020-04-28  9:26   ` Dave Mielke
  1 sibling, 0 replies; 7+ messages in thread
From: Alan Stern @ 2020-04-27 14:27 UTC (permalink / raw)
  To: Greg KH; +Cc: Dave Mielke, linux-usb, Samuel Thibault, Nicolas Pitre

On Mon, 27 Apr 2020, Greg KH wrote:

> On Sun, Apr 26, 2020 at 03:08:38PM -0400, Dave Mielke wrote:
> > We're working on getting brltty to run as an unprivileged user with just a few
> > required capabilities. We don't want one of those required capabilities to be
> > CAP_DAC_OVERRIDE (bypass file permission checks).
> > 
> > Some USB-connected braille devices don't respond very well to being
> > autosuspended. We get around this, when running as root, by writing to the
> > SYSFS power/autosuspend file associated with the device. Our problem is that
> > only the root user can write to it.
> > 
> > Other than using CAP_DAC_OVERRIDE (which we don't want to do), what other
> > way(s) might we be able to use to overcome this restriction? For example, is
> > there some kind of safe (enough) udev rule?
> 
> Have a udev rule that turns autosuspend off for each specific USB device
> that you know does not work with autosuspend.  Do you have such a list?
> 
> If so, we can add it to the USB core with the
> USB_QUIRK_DISCONNECT_SUSPEND flag.  Or is it the USB_QUIRK_NO_LPM that
> they need?  I can't remember, but you can test it out from userspace
> by reading about those in the
> Documentation/admin-guide/kernel-parameters.txt file.

A udev rule will probably work a lot better than a quirk flag.  In 
fact, I don't think we have a quirk flag for "don't autosuspend".  
DISCONNECT_SUSPEND doesn't affect autosuspends, only system sleeps.  
And NO_LPM only affects USB-3 devices.

A suitable udev rule should be pretty easy to write.

Alan Stern


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Writing to /sys/../power/autosuspend when not root.
  2020-04-27 10:30 ` Greg KH
  2020-04-27 14:27   ` Alan Stern
@ 2020-04-28  9:26   ` Dave Mielke
  2020-04-28  9:53     ` Greg KH
  2020-04-28 13:17     ` Alan Stern
  1 sibling, 2 replies; 7+ messages in thread
From: Dave Mielke @ 2020-04-28  9:26 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-usb, Samuel Thibault, Nicolas Pitre

[quoted lines by Greg KH on 2020/04/27 at 12:30 +0200]

>Have a udev rule that turns autosuspend off for each specific USB device
>that you know does not work with autosuspend.  

Yes, thanks, that should work. I have another question, though. Our code first
tries to write "-1" to power/autosuspend, and then, if that fails, it writes
"0". I'm guessing that "-1" was an older way (but I've forgotten). How can a
udev rule be written to accommodate that?

-- 
I believe the Bible to be the very Word of God: http://Mielke.cc/bible/
Dave Mielke            | 2213 Fox Crescent | WebHome: http://Mielke.cc/
EMail: Dave@Mielke.cc  | Ottawa, Ontario   | Twitter: @Dave_Mielke
Phone: +1 613 726 0014 | Canada  K2A 1H7   |

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Writing to /sys/../power/autosuspend when not root.
  2020-04-28  9:26   ` Dave Mielke
@ 2020-04-28  9:53     ` Greg KH
  2020-04-28 13:17     ` Alan Stern
  1 sibling, 0 replies; 7+ messages in thread
From: Greg KH @ 2020-04-28  9:53 UTC (permalink / raw)
  To: Dave Mielke; +Cc: linux-usb, Samuel Thibault, Nicolas Pitre

On Tue, Apr 28, 2020 at 05:26:49AM -0400, Dave Mielke wrote:
> [quoted lines by Greg KH on 2020/04/27 at 12:30 +0200]
> 
> >Have a udev rule that turns autosuspend off for each specific USB device
> >that you know does not work with autosuspend.  
> 
> Yes, thanks, that should work. I have another question, though. Our code first
> tries to write "-1" to power/autosuspend, and then, if that fails, it writes
> "0". I'm guessing that "-1" was an older way (but I've forgotten). How can a
> udev rule be written to accommodate that?

udev rules can run any script/program that they want to :)

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Writing to /sys/../power/autosuspend when not root.
  2020-04-28  9:26   ` Dave Mielke
  2020-04-28  9:53     ` Greg KH
@ 2020-04-28 13:17     ` Alan Stern
  1 sibling, 0 replies; 7+ messages in thread
From: Alan Stern @ 2020-04-28 13:17 UTC (permalink / raw)
  To: Dave Mielke; +Cc: Greg KH, linux-usb, Samuel Thibault, Nicolas Pitre

On Tue, 28 Apr 2020, Dave Mielke wrote:

> [quoted lines by Greg KH on 2020/04/27 at 12:30 +0200]
> 
> >Have a udev rule that turns autosuspend off for each specific USB device
> >that you know does not work with autosuspend.  
> 
> Yes, thanks, that should work. I have another question, though. Our code first
> tries to write "-1" to power/autosuspend, and then, if that fails, it writes
> "0". I'm guessing that "-1" was an older way (but I've forgotten). How can a
> udev rule be written to accommodate that?

See the entry for "/sys/bus/usb/devices/.../power/autosuspend" in
Documentation/ABI/stable/sysfs-bus-usb, or the corresponding entry for
"/sys/devices/.../power/autosuspend_delay_ms" in
Documentation/ABI/testing/sysfs-devices-power.

In short, -1 means "don't autosuspend", whereas 0 means "autosuspend as 
soon as possible".

Alan Stern


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Writing to /sys/../power/autosuspend when not root.
@ 2020-04-20 21:07 Dave Mielke
  0 siblings, 0 replies; 7+ messages in thread
From: Dave Mielke @ 2020-04-20 21:07 UTC (permalink / raw)
  To: linux-pm; +Cc: Samuel Thibault, Nicolas Pitre

We're working on getting brltty to run as an unprivileged user with just a few
required capabilities. We don't want one of those required capabilities to be
CAP_DAC_OVERRIDE (bypass file permission checks).

Some USB-connected braille devices don't respond very well to being
autosuspended. We get around this, when running as root, by writing to the
SYSFS power/autosuspend file associated with the device. Our problem is that
only the root user can write to it.

Other than using CAP_DAC_OVERRIDE (which we don't want to do), what other
way(s) might we be able to use to overcome this restriction? For example, is
there some kind of safe (enough) udev rule?

-- 
I believe the Bible to be the very Word of God: http://Mielke.cc/bible/
Dave Mielke            | 2213 Fox Crescent | WebHome: http://Mielke.cc/
EMail: Dave@Mielke.cc  | Ottawa, Ontario   | Twitter: @Dave_Mielke
Phone: +1 613 726 0014 | Canada  K2A 1H7   |

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-04-28 13:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-26 19:08 Writing to /sys/../power/autosuspend when not root Dave Mielke
2020-04-27 10:30 ` Greg KH
2020-04-27 14:27   ` Alan Stern
2020-04-28  9:26   ` Dave Mielke
2020-04-28  9:53     ` Greg KH
2020-04-28 13:17     ` Alan Stern
  -- strict thread matches above, loose matches on Subject: below --
2020-04-20 21:07 Dave Mielke

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.