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

nice fails with EACCES/Permission denied #1838

Closed
iltep64 opened this issue Mar 31, 2017 · 25 comments
Closed

nice fails with EACCES/Permission denied #1838

iltep64 opened this issue Mar 31, 2017 · 25 comments

Comments

@iltep64
Copy link

iltep64 commented Mar 31, 2017

nice fails to set priority on process, failing with permission denied.

  • Expected (build <=14986)
$ nice -n 5 nice
5
  • Actual (build >=15048)
$ nice -n 5 nice
nice: cannot set nicencess: Permission denied
0
  • Windows build
    15063 (issue started on 15048)

  • Steps / All commands required to reproduce the error from a brand new installation
    Run nice -n 5 nice.

  • Strace of the failing command

execve("/usr/bin/nice", ["nice", "-n", "5", "nice"], [/* 12 vars */]) = 0
brk(NULL)                               = 0x7ee000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffb68ac0000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=24701, ...}) = 0
mmap(NULL, 24701, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ffb68ab9000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\t\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1864888, ...}) = 0
mmap(NULL, 3967392, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ffb68430000
mprotect(0x7ffb685ef000, 2097152, PROT_NONE) = 0
mmap(0x7ffb687ef000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bf000) = 0x7ffb687ef000
mmap(0x7ffb687f5000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7ffb687f5000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffb68ab0000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffb68aa0000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffb68a90000
arch_prctl(ARCH_SET_FS, 0x7ffb68aa0700) = 0
mprotect(0x7ffb687ef000, 16384, PROT_READ) = 0
mprotect(0x607000, 4096, PROT_READ)     = 0
mprotect(0x7ffb68a25000, 4096, PROT_READ) = 0
munmap(0x7ffb68ab9000, 24701)           = 0
brk(NULL)                               = 0x7ee000
brk(0x80f000)                           = 0x80f000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1668976, ...}) = 0
mmap(NULL, 1668976, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ffb6888d000
close(3)                                = 0
getpriority(PRIO_PROCESS, 0)            = 20
setpriority(PRIO_PROCESS, 0, 5)         = -1 EACCES (Permission denied)
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2995, ...}) = 0
read(3, "# Locale name alias data base.\n#"..., 512) = 512
read(3, "See the\n# GNU General Public Lic"..., 512) = 512
read(3, "nd for the time being for\n# back"..., 512) = 512
read(3, "hese lines were removed\n# becaus"..., 512) = 512
read(3, "8859-1\ngalego\t\tgl_ES.ISO-8859-1\n"..., 512) = 512
read(3, "O.ISO-8859-1 nb_NO.ISO-8859-1\nno"..., 512) = 435
read(3, "", 512)                        = 0
close(3)                                = 0
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "nice: ", 6nice: )                   = 6
write(2, "cannot set niceness", 19cannot set niceness)     = 19
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": Permission denied", 19: Permission denied)     = 19
write(2, "\n", 1
)                       = 1
execve("/usr/local/sbin/nice", ["nice"], [/* 12 vars */]) = -1 ENOENT (No such file or directory)
execve("/usr/local/bin/nice", ["nice"], [/* 12 vars */]) = -1 ENOENT (No such file or directory)
execve("/usr/sbin/nice", ["nice"], [/* 12 vars */]) = -1 ENOENT (No such file or directory)
execve("/usr/bin/nice", ["nice"], [/* 12 vars */]) = 0
brk(NULL)                               = 0x1357000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f99a5ca0000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=24701, ...}) = 0
mmap(NULL, 24701, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f99a5ca3000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\t\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1864888, ...}) = 0
mmap(NULL, 3967392, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f99a5630000
mprotect(0x7f99a57ef000, 2097152, PROT_NONE) = 0
mmap(0x7f99a59ef000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bf000) = 0x7f99a59ef000
mmap(0x7f99a59f5000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f99a59f5000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f99a5c90000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f99a5c80000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f99a5c70000
arch_prctl(ARCH_SET_FS, 0x7f99a5c80700) = 0
mprotect(0x7f99a59ef000, 16384, PROT_READ) = 0
mprotect(0x607000, 4096, PROT_READ)     = 0
mprotect(0x7f99a5c25000, 4096, PROT_READ) = 0
munmap(0x7f99a5ca3000, 24701)           = 0
brk(NULL)                               = 0x1357000
brk(0x1378000)                          = 0x1378000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1668976, ...}) = 0
mmap(NULL, 1668976, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f99a5a8d000
close(3)                                = 0
getpriority(PRIO_PROCESS, 0)            = 20
fstat(1, {st_mode=S_IFCHR|0660, st_rdev=makedev(4, 3), ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
write(1, "0\n", 20
)                      = 2
close(1)                                = 0
close(2)                                = 0
exit_group(0)                           = ?
+++ exited with 0 +++
  • Required packages and commands to install
    None, /usr/bin/nice is from coreutils.
@iltep64 iltep64 changed the title setpriority syscall fails with EACCES nice fails with EACCES/Permission denied Mar 31, 2017
@iltep64
Copy link
Author

iltep64 commented Mar 31, 2017

On closer inspection, nice is calling setpriority with the user-provided value of 5. Glibc is supposed to handle the translation of userland nice values to kernel nice values (e.g. 5 -> 15, -5 -> 25), according to https://linux.die.net/man/2/setpriority.

On older builds, non privileged users could execute nice -n -5 <command>, which should fail with EACCES, thus the new builds actually are the correct ones in implementing the syscall behavior. However, somehow nice or glibc is not doing the conversion.

Testing on a linux box, strace gives

$ strace nice -n 5 nice
<snip>
getpriority(PRIO_PROCESS, 0)            = 20
setpriority(PRIO_PROCESS, 0, 5)         = 0
<snip>
$ strace nice -n -5 nice
<snip>
getpriority(PRIO_PROCESS, 0)            = 20
setpriority(PRIO_PROCESS, 0, -5)        = -1 EACCES (Permission denied)
<snip>

@iltep64
Copy link
Author

iltep64 commented Mar 31, 2017

Problem still persists on latest libc 2.23.

@pefoley2
Copy link

This also causes the python os.nice() function to return "Operation not permitted".

@tnguyen14
Copy link

I see a bunch of these errors

nice: cannot set niceness: Permission denied

every time I use linuxbrew and run brew install ...

@farmerbean
Copy link

@tnguyen14 - Yes, same issue here (wsl16)

@ChickenFur
Copy link

same issue here

@swun90
Copy link

swun90 commented Oct 16, 2017

I am using zsh and oh-my-zsh, and had the same issue before.
Add upsetopt BG_LINE to ~/.zshrc to fix the issue.

@farmerbean
Copy link

@swun90 when I source ~/.zshrc it says 'command not found' (upsetopt).

I note I already have 'unsetopt BG_NICE' on the last line, but still getting the issue.

when I add 'unsetopt BG_LINE' I get 'no such option BG_LINE'

@iegik
Copy link

iegik commented Jan 26, 2018

Thanks @swun90, I`m also use oh-my-zsh. Your solution fix this annoying message,
but only with small correction:

nice(5) failed: operation not permitted

Add unsetopt BG_LINE to ~/.zshrc to fix the issue.

@farmerbean try unsetopt BG_NICE

@farmerbean
Copy link

Thanks @iegik - in there already, but persists.

@bouvyd
Copy link

bouvyd commented Mar 22, 2018

Still happening on 16299 (when using the os.nice(val) python call on python 3.5+) using the basic bash.

@BelfordZ
Copy link

+1 to being rekd by this

@phifa
Copy link

phifa commented Aug 7, 2018

same over here.

@jsonMartin
Copy link

Also having this issue. Adding upsetopt BG_LINE to zshrc fixed it as well for now, but looking forward to native fix.

@sjackman
Copy link

sjackman commented Aug 7, 2018

This issue also affects Linuxbrew. See Linuxbrew/brew#695

@benhillis
Copy link
Member

benhillis commented Aug 7, 2018

Looks like we're being too strict about checking the permissions for the setpriority syscall when who = 0. I'll fix this.

@benhillis
Copy link
Member

Fixed in 17738.

@sjackman
Copy link

Woohoo! Thanks, Ben!

@WaqqasI
Copy link

WaqqasI commented Nov 11, 2018

I still seem to be getting this issue on a updated version of wsl
It does however work with sudo, which is unusual

arcadia-devtools pushed a commit to catboost/catboost that referenced this issue Mar 30, 2019
Does not work with WSL: https://paste.yandex-team.ru/687055
It's known issue microsoft/WSL#1838
issue:https://st.yandex-team.ru/DEVTOOLS-4896

ref:10223a059c4b3467c1dad27c9dece5cb794a1fc5
@sjackman
Copy link

@benhillis Some people are reporting that they're still seeing this issue. Are there particular instructions that the user needs to follow to get this fix?

@benhillis
Copy link
Member

@sjackman - What Windows build are they running?

@sjackman
Copy link

@EshChn @LightningsFury Are you still seeing this issue with nice: cannot set niceness: permission denied? What Windows build are you running?

@shewlian
Copy link

shewlian commented Aug 4, 2019

Hi, folks.
I'm still seeing this issue on Windows 10, Version 1803, Build 17134.
I'll be upgrading to a Windows Insider version and check if the issue persists.

@craigloewen-msft
Copy link
Member

@juliandres this issue is marked as fixed in build 17738. So make sure to upgrade to that version or higher!

@shewlian
Copy link

shewlian commented Aug 8, 2019

@mscraigloewen I've just upgraded to Version 1903, Build 18362. The issue seems to be gone. Thank you. :)

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