Bug 412742 - $pipe for mkfifo has no write permission
Summary: $pipe for mkfifo has no write permission
Status: RESOLVED FIXED
Alias: None
Product: Heaptrack
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Milian Wolff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-08 22:20 UTC by Sam Saffron
Modified: 2019-10-15 21:07 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Saffron 2019-10-08 22:20:03 UTC
When attaching to an existing process as `root` the mkfifo permission for the non `root` process being monitored can not be written to due to a permission error. 

The easy thing I do in production is add
`chmod a+w $pipe` just after the mkfifo, but this is messy. 

Instead perhaps we can inspect the owner of the process we are attaching to and maybe error out if we know we can not create that and add something like

heaptrack -p PID --insecure-pipe , to workaround?
Comment 1 Milian Wolff 2019-10-13 19:49:43 UTC
Hey Sam,

that's an interesting bug report, thanks for pointing this limitation out to me - I certainly never ran into it yet :)

I guess the right approach to fix it is indeed what you point out. First ensure that we attach with the right user, and if not then we should error out. Then using the `insecure-pipe` as a workaround would be a nice cherry on top to improve usability.

Are you willing to provide a patch for that?
Comment 2 Sam Saffron 2019-10-14 04:44:13 UTC
No problems Millan! 

I made https://github.com/KDE/heaptrack/pull/22 which is the simplest way I think
we can work around it.

I also noticed we are not cleaning up the pipe which probably does not matter, but may give us slightly cleaner detach behavior.
Comment 3 Milian Wolff 2019-10-14 12:03:46 UTC
The pipe should be cleaned up via the trap, no?

trap cleanup EXIT

will call

rm -f "$pipe"

is that not working for you?
Comment 4 Sam Saffron 2019-10-14 23:35:03 UTC
Yeah I do see the cleanup working, I think where I was getting confused is that I was doing a CTRL-C on heaptrack when it is attached and that left the file around, but I am not sure if there is any clean thing we can do for such a case.
Comment 5 Milian Wolff 2019-10-15 21:07:58 UTC
Git commit 2d14f5de75b9dae33be0e782bcec043794e3f5e7 by Milian Wolff, on behalf of Sam Saffron.
Committed on 15/10/2019 at 21:06.
Pushed by mwolff into branch 'master'.

Allow high priv user to profile low priv user process

In some cases `root` may attach to a non `root` process, in that case
we need to ensure th pipe can be written to by the process being
profiled

M  +10   -0    src/track/heaptrack.sh.cmake

https://commits.kde.org/heaptrack/2d14f5de75b9dae33be0e782bcec043794e3f5e7