Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PermissionError: [Errno 13] Permission denied #13

Open
danglotb opened this issue Nov 15, 2020 · 6 comments
Open

PermissionError: [Errno 13] Permission denied #13

danglotb opened this issue Nov 15, 2020 · 6 comments

Comments

@danglotb
Copy link
Contributor

Hello,

When I run pyJoules, I have the following error:

PermissionError: [Errno 13] Permission denied: '/sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:2/energy_uj'

I do not understand what I did to have less permission on these files.

Here, is the output of ls -l:

ls -l /sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:2 
total 0
-r-------- 1 root root 4096 Nov 15 15:19 constraint_0_max_power_uw
-r-------- 1 root root 4096 Nov 15 15:19 constraint_0_name
-rw------- 1 root root 4096 Nov 15 15:19 constraint_0_power_limit_uw
-rw------- 1 root root 4096 Nov 15 15:19 constraint_0_time_window_us
lrwxrwxrwx 1 root root    0 Nov 15 15:19 device -> ../../intel-rapl:0
-rw-r--r-- 1 root root 4096 Nov 15 15:19 enabled
-r-------- 1 root root 4096 Nov 15 11:10 energy_uj
-r-------- 1 root root 4096 Nov 15 15:19 max_energy_range_uj
-r--r--r-- 1 root root 4096 Nov 15 15:14 name
drwxr-xr-x 2 root root    0 Nov 15 15:19 power
lrwxrwxrwx 1 root root    0 Nov 15 15:19 subsystem -> ../../../../../../class/powercap
-rw-r--r-- 1 root root 4096 Nov 15 15:19 uevent

Looks quite normal that the permission is denied, because of -r-------- 1 root root 4096 Nov 15 11:10 energy_uj.
I do not want to set up the proper permissions manually(e.g. with chmod command), do you have any idea if there are any settings or something I can do to have the proper permissions ?

Thank you.

@altor
Copy link
Contributor

altor commented Nov 16, 2020

Hello,
I don't know any setting to change these permissions (except chmod). This is weird, you should have read permission for this file...
Have you got the same permission for other domains ? (/sys/class/powercap/intel-rapl/intel-rapl:0, /sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:0 and /sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:1)
Did you use other tools than pyJoules to get CPU power consumption recently ? Or did you patch you kernel or using an uncommon version of linux ?

@danglotb
Copy link
Contributor Author

Hello, thank you for your answer.

ll /sys/class/powercap/intel-rapl/intel-rapl:0
total 0
-r-------- 1 root root 4.0K Nov 16 09:07 constraint_0_max_power_uw
-r-------- 1 root root 4.0K Nov 16 09:07 constraint_0_name
-rw------- 1 root root 4.0K Nov 16 09:07 constraint_0_power_limit_uw
-rw------- 1 root root 4.0K Nov 16 09:07 constraint_0_time_window_us
-r-------- 1 root root 4.0K Nov 16 09:07 constraint_1_max_power_uw
-r-------- 1 root root 4.0K Nov 16 09:07 constraint_1_name
-rw------- 1 root root 4.0K Nov 16 09:07 constraint_1_power_limit_uw
-rw------- 1 root root 4.0K Nov 16 09:07 constraint_1_time_window_us
lrwxrwxrwx 1 root root    0 Nov 16 09:07 device -> ../../intel-rapl
-rw-r--r-- 1 root root 4.0K Nov 16 09:07 enabled
-r-------- 1 root root 4.0K Nov 16 09:07 energy_uj
drwxr-xr-x 3 root root    0 Nov 16 09:07 intel-rapl:0:0
drwxr-xr-x 3 root root    0 Nov 16 09:07 intel-rapl:0:1
drwxr-xr-x 3 root root    0 Nov 16 09:07 intel-rapl:0:2
-r-------- 1 root root 4.0K Nov 16 09:07 max_energy_range_uj
-r--r--r-- 1 root root 4.0K Nov 16 09:07 name
drwxr-xr-x 2 root root    0 Nov 16 09:07 power
lrwxrwxrwx 1 root root    0 Nov 16 09:07 subsystem -> ../../../../../class/powercap
-rw-r--r-- 1 root root 4.0K Nov 16 09:07 uevent
ll /sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:0
total 0
-r-------- 1 root root 4.0K Nov 16 10:10 constraint_0_max_power_uw
-r-------- 1 root root 4.0K Nov 16 10:10 constraint_0_name
-rw------- 1 root root 4.0K Nov 16 10:10 constraint_0_power_limit_uw
-rw------- 1 root root 4.0K Nov 16 10:10 constraint_0_time_window_us
lrwxrwxrwx 1 root root    0 Nov 16 10:10 device -> ../../intel-rapl:0
-rw-r--r-- 1 root root 4.0K Nov 16 10:10 enabled
-r-------- 1 root root 4.0K Nov 16 10:10 energy_uj
-r-------- 1 root root 4.0K Nov 16 10:10 max_energy_range_uj
-r--r--r-- 1 root root 4.0K Nov 16 09:07 name
drwxr-xr-x 2 root root    0 Nov 16 10:10 power
lrwxrwxrwx 1 root root    0 Nov 16 09:07 subsystem -> ../../../../../../class/powercap
-rw-r--r-- 1 root root 4.0K Nov 16 09:07 uevent
ll /sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:1
total 0
-r-------- 1 root root 4.0K Nov 16 10:11 constraint_0_max_power_uw
-r-------- 1 root root 4.0K Nov 16 10:11 constraint_0_name
-rw------- 1 root root 4.0K Nov 16 10:11 constraint_0_power_limit_uw
-rw------- 1 root root 4.0K Nov 16 10:11 constraint_0_time_window_us
lrwxrwxrwx 1 root root    0 Nov 16 10:11 device -> ../../intel-rapl:0
-rw-r--r-- 1 root root 4.0K Nov 16 10:11 enabled
-r-------- 1 root root 4.0K Nov 16 10:11 energy_uj
-r-------- 1 root root 4.0K Nov 16 10:11 max_energy_range_uj
-r--r--r-- 1 root root 4.0K Nov 16 09:07 name
drwxr-xr-x 2 root root    0 Nov 16 10:11 power
lrwxrwxrwx 1 root root    0 Nov 16 09:07 subsystem -> ../../../../../../class/powercap
-rw-r--r-- 1 root root 4.0K Nov 16 09:07 uevent

I do not know when this happened, but I noticed it last friday. On the same day, I change my RAM to a more powerful one.

But I do not think that changing my RAM would do that, isn't?

What is alarming, is that I did granted the required permission (i.e. chmod 444) on one of them to try, and today (after reboot), the permissions have been reset to the ones that are problematic 😞

Looks like I'll have to write a script to grant me these permissions at each boot.

Thank you very much.

@altor
Copy link
Contributor

altor commented Nov 23, 2020

EDIT :
this issue seems to be related to a security vulnerability
A security patch now restrict reading energy value only for privileged users (root)
So don't change permissions of any file it's a security vulnerability


Old Message don't follow theses advice this will make security vulnerability on your system

Thanks for your feedback !
We don't know why this issue appear, we are investigating ...

For the moment, you could change the permission of the following files to be readable by the user that use pyJoules :

  • /sys/class/powercap/intel-rapl:*/energy_uj
  • /sys/class/powercap/intel-rapl:*:*/energy_uj

In order to help us to find a better solution, could you give us the result of the following commands :

  • uname -a
  • lsmod

@danglotb
Copy link
Contributor Author

Hello,

Thank you for following this up.

uname -a
Linux davidsouest-HP-EliteBook-840-G6 5.4.0-53-generic #59-Ubuntu SMP Wed Oct 21 09:38:44 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
➜  ~ lsmod
Module                  Size  Used by
rfcomm                 81920  4
xt_nat                 16384  4
veth                   28672  0
vxlan                  69632  0
ip6_udp_tunnel         16384  1 vxlan
udp_tunnel             16384  1 vxlan
xt_policy              16384  0
xt_mark                16384  0
xt_u32                 16384  0
nf_conntrack_netlink    45056  0
nfnetlink              16384  2 nf_conntrack_netlink
xfrm_user              36864  1
xfrm_algo              16384  1 xfrm_user
br_netfilter           28672  0
ccm                    20480  3
xt_MASQUERADE          20480  7
xt_CHECKSUM            16384  2
ip6table_mangle        16384  1
ip6table_nat           16384  1
iptable_mangle         16384  1
iptable_nat            16384  2
nf_nat                 40960  4 ip6table_nat,xt_nat,iptable_nat,xt_MASQUERADE
ebtable_filter         16384  0
ebtables               36864  1 ebtable_filter
bridge                176128  1 br_netfilter
stp                    16384  1 bridge
llc                    16384  2 bridge,stp
cmac                   16384  2
aufs                  262144  0
algif_hash             16384  1
algif_skcipher         16384  1
af_alg                 24576  6 algif_hash,algif_skcipher
overlay               114688  0
bnep                   24576  2
nls_iso8859_1          16384  1
snd_soc_skl_hda_dsp    24576  5
snd_soc_hdac_hdmi      36864  1 snd_soc_skl_hda_dsp
snd_hda_codec_hdmi     61440  1
snd_hda_codec_realtek   126976  1
snd_hda_codec_generic    81920  1 snd_hda_codec_realtek
snd_soc_dmic           16384  1
snd_sof_pci            20480  0
snd_sof_intel_hda_common    69632  1 snd_sof_pci
snd_soc_hdac_hda       24576  1 snd_sof_intel_hda_common
snd_sof_intel_hda      20480  1 snd_sof_intel_hda_common
snd_sof_intel_byt      20480  1 snd_sof_pci
snd_sof_intel_ipc      20480  1 snd_sof_intel_byt
snd_sof               106496  4 snd_sof_pci,snd_sof_intel_hda_common,snd_sof_intel_byt,snd_sof_intel_ipc
snd_sof_xtensa_dsp     16384  1 snd_sof_pci
snd_hda_ext_core       28672  4 snd_sof_intel_hda_common,snd_soc_hdac_hdmi,snd_soc_hdac_hda,snd_sof_intel_hda
snd_soc_acpi_intel_match    32768  2 snd_sof_pci,snd_sof_intel_hda_common
snd_soc_acpi           16384  2 snd_sof_pci,snd_soc_acpi_intel_match
ledtrig_audio          16384  3 snd_hda_codec_generic,snd_hda_codec_realtek,snd_sof
snd_soc_core          245760  6 snd_sof,snd_sof_intel_hda_common,snd_soc_hdac_hdmi,snd_soc_hdac_hda,snd_soc_dmic,snd_soc_skl_hda_dsp
snd_compress           24576  1 snd_soc_core
ac97_bus               16384  1 snd_soc_core
snd_pcm_dmaengine      16384  1 snd_soc_core
mei_hdcp               24576  0
intel_rapl_msr         20480  0
snd_hda_intel          53248  0
snd_intel_dspcfg       24576  3 snd_hda_intel,snd_sof_pci,snd_sof_intel_hda_common
snd_hda_codec         135168  6 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec_realtek,snd_soc_hdac_hda,snd_soc_skl_hda_dsp
snd_hda_core           90112  11 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_ext_core,snd_hda_codec,snd_hda_codec_realtek,snd_sof_intel_hda_common,snd_soc_hdac_hdmi,snd_soc_hdac_hda,snd_sof_intel_hda,snd_soc_skl_hda_dsp
x86_pkg_temp_thermal    20480  0
snd_hwdep              20480  1 snd_hda_codec
intel_powerclamp       20480  0
snd_pcm               106496  9 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_sof,snd_sof_intel_hda_common,snd_soc_hdac_hdmi,snd_soc_core,snd_hda_core,snd_pcm_dmaengine
coretemp               20480  0
kvm_intel             282624  0
iwlmvm                380928  0
snd_seq_midi           20480  0
snd_seq_midi_event     16384  1 snd_seq_midi
kvm                   663552  1 kvm_intel
mac80211              843776  1 iwlmvm
snd_rawmidi            36864  1 snd_seq_midi
rapl                   20480  0
libarc4                16384  1 mac80211
snd_seq                69632  2 snd_seq_midi,snd_seq_midi_event
intel_cstate           20480  0
snd_seq_device         16384  3 snd_seq,snd_seq_midi,snd_rawmidi
snd_timer              36864  2 snd_seq,snd_pcm
uvcvideo               98304  0
iwlwifi               331776  1 iwlmvm
videobuf2_vmalloc      20480  1 uvcvideo
snd                    90112  24 snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek,snd_timer,snd_compress,snd_soc_core,snd_pcm,snd_soc_skl_hda_dsp,snd_rawmidi
videobuf2_memops       20480  1 videobuf2_vmalloc
videobuf2_v4l2         24576  1 uvcvideo
hid_sensor_als         20480  1
videobuf2_common       49152  2 videobuf2_v4l2,uvcvideo
btusb                  57344  0
hid_sensor_trigger     20480  2 hid_sensor_als
hp_wmi                 16384  0
btrtl                  24576  1 btusb
videodev              225280  3 videobuf2_v4l2,uvcvideo,videobuf2_common
industrialio_triggered_buffer    16384  1 hid_sensor_als
btbcm                  16384  1 btusb
cfg80211              704512  3 iwlmvm,iwlwifi,mac80211
soundcore              16384  1 snd
wmi_bmof               16384  0
serio_raw              20480  0
sparse_keymap          16384  1 hp_wmi
intel_wmi_thunderbolt    20480  0
joydev                 24576  0
input_leds             16384  0
mc                     53248  4 videodev,videobuf2_v4l2,uvcvideo,videobuf2_common
kfifo_buf              16384  1 industrialio_triggered_buffer
btintel                24576  1 btusb
hid_sensor_iio_common    20480  2 hid_sensor_trigger,hid_sensor_als
hid_multitouch         28672  0
bluetooth             548864  31 btrtl,btintel,btbcm,bnep,btusb,rfcomm
industrialio           73728  5 industrialio_triggered_buffer,hid_sensor_trigger,kfifo_buf,hid_sensor_als
ecdh_generic           16384  1 bluetooth
ecc                    28672  1 ecdh_generic
processor_thermal_device    24576  0
mei_me                 40960  1
cros_ec_ishtp          20480  0
intel_rapl_common      24576  2 intel_rapl_msr,processor_thermal_device
cros_ec                20480  1 cros_ec_ishtp
ucsi_acpi              16384  0
intel_soc_dts_iosf     20480  1 processor_thermal_device
mei                   106496  3 mei_hdcp,mei_me
typec_ucsi             40960  1 ucsi_acpi
int3403_thermal        20480  0
intel_pch_thermal      16384  0
typec                  45056  1 typec_ucsi
int340x_thermal_zone    16384  2 int3403_thermal,processor_thermal_device
int3400_thermal        20480  0
acpi_thermal_rel       16384  1 int3400_thermal
acpi_pad              184320  0
mac_hid                16384  0
hp_wireless            16384  0
nf_log_ipv6            16384  5
ip6t_REJECT            16384  1
nf_reject_ipv6         20480  1 ip6t_REJECT
xt_hl                  16384  22
ip6t_rt                20480  3
nf_log_ipv4            16384  5
nf_log_common          16384  2 nf_log_ipv4,nf_log_ipv6
ipt_REJECT             16384  5
nf_reject_ipv4         16384  1 ipt_REJECT
xt_LOG                 20480  10
xt_limit               16384  13
xt_addrtype            16384  6
xt_tcpudp              20480  44
xt_conntrack           16384  21
nf_conntrack          139264  5 xt_conntrack,nf_nat,xt_nat,nf_conntrack_netlink,xt_MASQUERADE
nf_defrag_ipv6         24576  1 nf_conntrack
nf_defrag_ipv4         16384  1 nf_conntrack
libcrc32c              16384  2 nf_conntrack,nf_nat
sch_fq_codel           20480  4
ip6table_filter        16384  1
ip6_tables             32768  55 ip6table_filter,ip6table_nat,ip6table_mangle
parport_pc             40960  0
iptable_filter         16384  1
bpfilter               32768  0
ppdev                  24576  0
lp                     20480  0
parport                53248  3 parport_pc,lp,ppdev
ip_tables              32768  11 iptable_filter,iptable_nat,iptable_mangle
x_tables               40960  22 ebtables,ip6table_filter,xt_conntrack,iptable_filter,xt_LOG,xt_tcpudp,xt_addrtype,xt_CHECKSUM,xt_nat,ip6t_rt,xt_policy,ip6_tables,xt_u32,ipt_REJECT,ip_tables,xt_limit,xt_hl,ip6table_mangle,xt_MASQUERADE,ip6t_REJECT,iptable_mangle,xt_mark
autofs4                45056  2
dm_crypt               40960  1
usbhid                 57344  0
hid_sensor_hub         24576  3 hid_sensor_trigger,hid_sensor_iio_common,hid_sensor_als
intel_ishtp_loader     24576  0
intel_ishtp_hid        24576  0
hid_generic            16384  0
crct10dif_pclmul       16384  1
crc32_pclmul           16384  0
ghash_clmulni_intel    16384  0
i915                 1986560  12
aesni_intel           372736  7
crypto_simd            16384  1 aesni_intel
cryptd                 24576  4 crypto_simd,ghash_clmulni_intel
glue_helper            16384  1 aesni_intel
i2c_algo_bit           16384  1 i915
drm_kms_helper        184320  1 i915
nvme                   49152  3
psmouse               155648  0
syscopyarea            16384  1 drm_kms_helper
i2c_i801               32768  0
sysfillrect            16384  1 drm_kms_helper
e1000e                258048  0
sysimgblt              16384  1 drm_kms_helper
thunderbolt           167936  0
fb_sys_fops            16384  1 drm_kms_helper
nvme_core             102400  5 nvme
drm                   491520  5 drm_kms_helper,i915
intel_lpss_pci         20480  0
intel_lpss             16384  1 intel_lpss_pci
idma64                 20480  0
i2c_hid                28672  0
virt_dma               20480  1 idma64
intel_ish_ipc          24576  0
intel_ishtp            49152  4 cros_ec_ishtp,intel_ishtp_hid,intel_ish_ipc,intel_ishtp_loader
hid                   131072  6 i2c_hid,usbhid,hid_multitouch,hid_sensor_hub,intel_ishtp_hid,hid_generic
wmi                    32768  3 hp_wmi,intel_wmi_thunderbolt,wmi_bmof
pinctrl_cannonlake     36864  1
video                  49152  1 i915
pinctrl_intel          28672  1 pinctrl_cannonlake

@altor
Copy link
Contributor

altor commented Nov 24, 2020

Hi, this issue seems to be related to a security vulnerability
A security patch now restrict reading energy value only for privileged users (root)
So don't change permissions of any file it's a security vulnerability

@danglotb
Copy link
Contributor Author

Ok thank you very much for the pointer.

I have a question. It might be related, it might not, but I was trying to use PowerAPI lately, and I have the following errors :

I: 20-11-26 09:07:20 perf<all>: monitoring actor started
I: 20-11-26 09:07:20 perf<powerapi-sensor>: monitoring actor started
I: 20-11-26 09:10:10 perf<powerapi-formula>: monitoring actor started
E: 20-11-26 12:16:47 perf<powerapi-formula>: cannot read perf values for group=core pkg=0 cpu=3
E: 20-11-26 12:16:47 perf<powerapi-formula>: failed to populate payload for timestamp=1606393007464
E: 20-11-26 12:16:47 perf<all>: cannot read perf values for group=msr pkg=0 cpu=3
E: 20-11-26 12:16:47 perf<all>: failed to populate payload for timestamp=1606393007464

Do you think that PowerAPI is also suffering from these wrong permissions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants