snap run --strace can't find setpriority on (at least 4.4)

Bug #1825218 reported by Jamie Strandboge
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
Confirmed
Low
Unassigned

Bug Description

In investigating a different issue, I ran this on bionic and newer:

$ sudo snap install test-snapd-tools
$ sudo snap run --strace test-snapd-tools.cmd nice -n -10 uptime 2>&1 | grep setpriority
[pid 28394] setpriority(PRIO_PROCESS, 0, -10) = -1 EPERM (Operation not permitted)

which is the expected output.

# xenial

I then tried on xenial and got different behavior:

$ sudo snap install test-snapd-tools
$ sudo snap run --strace test-snapd-tools.cmd nice -n -10 uptime 2>&1 | grep setpriority
$

Ie, strace didn't report the setpriority syscall. I then looked at the full strace and found that strace couldn't find setpriority (strace will prefix syscall_ with a hex value when it can't find the syscall, as per its man page):

[pid 5770] syscall_18446744073709551615(0, 0, 0xfffffff6, 0x865, 0, 0x1999999999999999) = -1 (errno 1)

Note, this 18446744073709551615 seems an odd value for the syscall...

If I use the old method of stracing described in https://forum.snapcraft.io/t/stracing-snap-commands/1433, the syscall is also not found:

$ sudo strace -e '!select,pselect6,_newselect,clock_gettime' -f -D -vv test-snapd-tools.cmd nice -n -10 uptime 2>&1 | grep syscall_
[pid 5875] syscall_18446744073709551615(0, 0, 0xfffffff6, 0x865, 0, 0x1999999999999999) = -1 (errno 1)

However, it does if I just call strace directly on the command outside of snap run:

$ sudo strace -- nice -n -10 uptime 2>&1 | grep -E '(syscall_|setpriority)'
setpriority(PRIO_PROCESS, 0, -10) = 0

# trusty
On trusty with the 4.4 linux-generic-lts-xenial kernel, I found that '_newselect' is not a valid syscall, so snap run --strace fails:

$ sudo snap run --strace test-snapd-tools.cmd nice -n -10 uptime 2>&1
/usr/bin/strace: invalid system call '_newselect'
error: exit status 1

Using the old way without _newselect strace doesn't report it at all (just see the write() that nice failed but no syscall_* or sepriority).

Stracing nice outside of the snap command has strace finding setpriority:

$ sudo strace -e '!select,pselect6,clock_gettime' -f -D -vv nice -n -10 uptime 2>&1|grep setprio
setpriority(PRIO_PROCESS, 0, 4294967286) = 0

Please note in all Ubuntu releases the setpriority call was correctly mediated; it is just that on xenial and trusty the strace output was mysterious.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Looking at the versions of strace, xenial has 4.11, trusty 4.8 and bionic 4.21. Upstream is very active: https://github.com/strace/strace/commits/v4.21 but while bionic has 4.21, if I remove strace from xenial and snap install strace-static --edge, I get 4.23 and similar behavior, so there is something more going on:

$ sudo snap run --strace test-snapd-tools.cmd nice -n -10 uptime 2>&1 | grep syscall
[pid 6358] syscall_0xffffffffffffffff(0, 0, 0xfffffff6, 0x865, 0, 0x1999999999999999) = -1 EPERM (Operation not permitted)

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

I ran into this issue myself while working with the field and certification sprints during the Malta engineering sprint. I think we should either default to strace-from-snap or at least detect when strace is too old for the running kernel.

I'm marking it as triaged and low.

Changed in snapd:
status: New → Triaged
importance: Undecided → Low
status: Triaged → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.