public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "craig.ringer at 2ndquadrant dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sourceware.org
Subject: [Bug runtime/27224] stap 4.4 'cannot attach to module' in debugfs mode as non-root
Date: Fri, 22 Jan 2021 04:42:36 +0000	[thread overview]
Message-ID: <bug-27224-6586-QI09rzEuzR@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-27224-6586@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=27224

--- Comment #3 from Craig Ringer <craig.ringer at 2ndquadrant dot com> ---
OK, bit more digging done.

If I build the module with

    $stap -m test_transport -p4 -DSTAP_TRANS_DEBUGFS \
          -e 'probe begin { printf("started\n"); exit(); }'

then on default mount mode:

    $ sudo mount /sys/kernel/debug -o remount,mode=700

running staprun as non-root fails:

    $ staprun -R -v  test_transport.ko
    staprun:insert_module:191 Module test_tr_380170 inserted from file
/home/craig/projects/2Q/systemtap/test_transport.ko
    ERROR: Cannot attach to module test_tr_380170 control channel; not running?
    ERROR: Cannot attach to module test_tr_380170 control channel; not running?
    ERROR: 'test_tr_380170' is not a zombie systemtap module.

but as root works:

    $ sudo staprun -R -v  test_transport.ko
    staprun:insert_module:191 Module test_tr_380194 inserted from file
/home/craig/projects/2Q/systemtap/test_transport.ko
started
    stapio:cleanup_and_exit:536 detach=0
    stapio:cleanup_and_exit:553 closing control channel
    staprun:remove_module:284 Module test_tr_380194 removed.

And I see the same behaviour from running stap itself:

    $ stap -vp 00005 -DSTAP_TRANS_DEBUGFS -e 'probe begin {
printf("started\n"); exit(); }' 
    Pass 1: parsed user script and 496 library scripts using
337684virt/95784res/12788shr/82644data kb, in 140usr/30sys/176real ms.
    Pass 2: analyzed script: 1 probe, 1 function, 0 embeds, 0 globals using
339268virt/97432res/12860shr/84228data kb, in 10usr/0sys/6real ms.
    Pass 3: using cached
/home/craig/.systemtap/cache/67/stap_67a78d650b7aca78a67c0155dbf23b64_1010.c
    Pass 4: using cached
/home/craig/.systemtap/cache/67/stap_67a78d650b7aca78a67c0155dbf23b64_1010.ko
    Pass 5: starting run.
    ERROR: Cannot attach to module stap_67a78d650b7aca78a67c0155dbf23b_380255
control channel; not running?
    ERROR: Cannot attach to module stap_67a78d650b7aca78a67c0155dbf23b_380255
control channel; not running?
    ERROR: 'stap_67a78d650b7aca78a67c0155dbf23b_380255' is not a zombie
systemtap module.
    WARNING: /usr/bin/staprun exited with status: 1
    Pass 5: run completed in 0usr/0sys/3real ms.
    Pass 5: run failed.  [man error::pass5]

    $ sudo stap -vp 00005 -DSTAP_TRANS_DEBUGFS -e 'probe begin {
printf("started\n"); exit(); }' 
    Pass 1: parsed user script and 496 library scripts using
330692virt/95728res/12740shr/82480data kb, in 150usr/20sys/172real ms.
    Pass 2: analyzed script: 1 probe, 1 function, 0 embeds, 0 globals using
332276virt/97376res/12812shr/84064data kb, in 10usr/0sys/6real ms.
    Pass 3: translated to C into
"/tmp/stapDRx9sx/stap_df533545ae591f1f9eca48caaf372255_1007_src.c" using
332408virt/97376res/12812shr/84196data kb, in 0usr/0sys/0real ms.
    Pass 4: compiled C into "stap_df533545ae591f1f9eca48caaf372255_1007.ko" in
1800usr/620sys/2244real ms.
    Pass 5: starting run.
    started
    Pass 5: run completed in 10usr/30sys/377real ms.

Repeating the same with debugfs mode 755, I see that the non-root runs now work
too:

    $ sudo mount /sys/kernel/debug -o remount,mode=700

    $ staprun -R -v  test_transport.ko
    staprun:insert_module:191 Module test_tr_381074 inserted from file
/home/craig/projects/2Q/systemtap/test_transport.ko
    started
    stapio:cleanup_and_exit:536 detach=0
    stapio:cleanup_and_exit:553 closing control channel
    staprun:remove_module:284 Module test_tr_381074 removed.

    $ sudo stap -vp 00005 -DSTAP_TRANS_DEBUGFS -e 'probe begin {
printf("started\n"); exit(); }'
    Pass 1: parsed user script and 496 library scripts using
330692virt/95384res/12400shr/82480data kb, in 150usr/10sys/172real ms.
    Pass 2: analyzed script: 1 probe, 1 function, 0 embeds, 0 globals using
332276virt/97032res/12472shr/84064data kb, in 10usr/0sys/5real ms.
    Pass 3: using cached
/root/.systemtap/cache/df/stap_df533545ae591f1f9eca48caaf372255_1007.c
    Pass 4: using cached
/root/.systemtap/cache/df/stap_df533545ae591f1f9eca48caaf372255_1007.ko
    Pass 5: starting run.
    started
    Pass 5: run completed in 0usr/20sys/377real ms.

-- 
You are receiving this mail because:
You are the assignee for the bug.

  parent reply	other threads:[~2021-01-22  4:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-22  4:26 [Bug runtime/27224] New: " craig.ringer at 2ndquadrant dot com
2021-01-22  4:26 ` [Bug runtime/27224] " craig.ringer at 2ndquadrant dot com
2021-01-22  4:27 ` craig.ringer at 2ndquadrant dot com
2021-01-22  4:31 ` craig.ringer at 2ndquadrant dot com
2021-01-22  4:42 ` craig.ringer at 2ndquadrant dot com [this message]
2021-01-22  4:42 ` [Bug runtime/27224] stap 4.4 'cannot attach to module' in debugfs mode as non-root (WITH WORKAROUND) craig.ringer at 2ndquadrant dot com
2021-01-22 22:30 ` fche at redhat dot com
2021-01-22 22:31 ` fche at redhat dot com
2021-01-29 10:43 ` craig.ringer at 2ndquadrant dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-27224-6586-QI09rzEuzR@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).