FS#34038 - error opening ATTR{/sys/devices/...} for writing: Permission denied

Attached to Project: Arch Linux
Opened by Robert Orzanna (orschiro) - Tuesday, 26 February 2013, 22:34 GMT
Last edited by Allan McRae (Allan) - Monday, 29 April 2013, 06:02 GMT
Task Type Bug Report
Category System
Status Closed
Assigned To No-one
Architecture x86_64
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
I created the following Udev rule:

[orschiro@thinkpad ~]$ cat /etc/udev/rules.d/50-powersave.rules
ACTION=="add", KERNEL=="acpi_video0", SUBSYSTEM=="backlight", SUBSYSTEMS=="pci", DRIVERS=="i915", ATTR{brightness}="2"

Normally, this should work. The Udev rule is correct. However, Udev does not have permissions to write to ATTR{brightness}. Writing the value manually works though. Output of udevadm test /sys/class/backlight/acpi_video0/

rules contain 196608 bytes tokens (16384 * 12 bytes), 28990 bytes strings
16403 strings (148133 bytes), 13926 de-duplicated (121621 bytes), 2478 trie nodes used
ATTR '/sys/devices/pci0000:00/0000:00:02.0/backlight/acpi_video0/brightness' writing '2' /etc/udev/rules.d/50-powersave.rules:2
error opening ATTR{/sys/devices/pci0000:00/0000:00:02.0/backlight/acpi_video0/brightness} for writing: Permission denied
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:02.0/backlight/acpi_video0
SUBSYSTEM=backlight
USEC_INITIALIZED=1720252336
unload module index


Additional info:

linux 3.7.9-2
lib32-systemd 197-1
systemd 197-4
This task depends upon

Closed by  Allan McRae (Allan)
Monday, 29 April 2013, 06:02 GMT
Reason for closing:  Not a bug
Comment by Dave Reisner (falconindy) - Wednesday, 27 February 2013, 01:21 GMT
And your claim is that /sys/devices/pci0000:00/0000:00:02.0/backlight/acpi_video0/brightness exists? What are the permissions and ownership on this file (ls -l is fine)
Comment by Robert Orzanna (orschiro) - Wednesday, 27 February 2013, 10:48 GMT
Hello Dave,

Yes it exists.

[orschiro@thinkpad ~]$ ls -l /sys/devices/pci0000:00/0000:00:02.0/backlight/acpi_video0/brightness
-rw-r--r-- 1 root root 4096 27. Feb 2013 /sys/devices/pci0000:00/0000:00:02.0/backlight/acpi_video0/brightness



[orschiro@thinkpad ~]$ udevadm info -a -p /sys/class/backlight/acpi_video0

looking at device '/devices/pci0000:00/0000:00:02.0/backlight/acpi_video0':
KERNEL=="acpi_video0"
SUBSYSTEM=="backlight"
DRIVER==""
ATTR{type}=="firmware"
ATTR{brightness}=="15"
ATTR{bl_power}=="0"
ATTR{max_brightness}=="15"
ATTR{actual_brightness}=="15"

looking at parent device '/devices/pci0000:00/0000:00:02.0':
KERNELS=="0000:00:02.0"
SUBSYSTEMS=="pci"
DRIVERS=="i915"
ATTRS{irq}=="47"
ATTRS{subsystem_vendor}=="0x17aa"
ATTRS{broken_parity_status}=="0"
ATTRS{class}=="0x030000"
ATTRS{consistent_dma_mask_bits}=="36"
ATTRS{dma_mask_bits}=="36"
ATTRS{local_cpus}=="00000000,00000003"
ATTRS{device}=="0x2a42"
ATTRS{msi_bus}==""
ATTRS{local_cpulist}=="0-1"
ATTRS{vendor}=="0x8086"
ATTRS{subsystem_device}=="0x20e4"
ATTRS{boot_vga}=="1"
ATTRS{numa_node}=="-1"
ATTRS{d3cold_allowed}=="1"

looking at parent device '/devices/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""
Comment by Robert Orzanna (orschiro) - Thursday, 28 February 2013, 23:09 GMT
I added OWNER="root" to my rule. Now testing the rule with 'udevadm test /sys/class/acpi_video0/backlight' no longer gives me permission denied but when I unplug the cable it still does not change the brightness to 2.
Comment by Robert Orzanna (orschiro) - Friday, 01 March 2013, 00:48 GMT
I added acpi_backlight=vendor to the kernel line and now use intel_backlight. But the error remains. Udev does not write the attribute 2.

Manually writing the value works:

# echo 2 > /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight/brightness


The rule:

[orschiro@thinkpad rules.d]$ cat 50-powersave.rules
ACTION=="add", DEVPATH=="/devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight", SUBSYSTEM=="backlight", OWNER="root", ATTR{brightness}="2"

With OWNER="root"

rules contain 196608 bytes tokens (16384 * 12 bytes), 29035 bytes strings
16401 strings (148186 bytes), 13926 de-duplicated (121627 bytes), 2476 trie nodes used
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight
SUBSYSTEM=backlight
USEC_INITIALIZED=1328197320
unload module index


Without OWNER="root"

ATTR '/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight/brightness' writing '2' /etc/udev/rules.d/50-powersave.rules:3
error opening ATTR{/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight/brightness} for writing: Permission denied
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight
SUBSYSTEM=backlight
USEC_INITIALIZED=1241377860
unload module index
Comment by Jelle van der Waa (jelly) - Sunday, 17 March 2013, 13:57 GMT
Problem solved?
Comment by Robert Orzanna (orschiro) - Thursday, 28 March 2013, 11:51 GMT
I use another approach now by directly writing into the file through a script rather than a udev rule. As written on the Gentoo forum [1] writing to /sys through an Udev rule is not recommended.

[1] http://forums.gentoo.org/viewtopic-t-934196-start-0.html

Loading...