* fanotify and pidfd?
@ 2019-06-07 13:48 Marko Rauhamaa
2019-06-07 17:29 ` Amir Goldstein
0 siblings, 1 reply; 3+ messages in thread
From: Marko Rauhamaa @ 2019-06-07 13:48 UTC (permalink / raw)
To: linux-fsdevel
As it stands, fanotify reports the process ID of the file that is being
operated on:
struct fanotify_event_metadata {
__u32 event_len;
__u8 vers;
__u8 reserved;
__u16 metadata_len;
__aligned_u64 mask;
__s32 fd;
__s32 pid;
};
One nasty problem with this is that the process often is long gone by
the time the notification arrives.
Would it be possible to amend this format with:
__s32 pidfd;
It would hold the pid still for the duration of notification processing
and allow for the fanotify monitor to safely use the pid field to
inspect /proc/<pid>.
And the possibility of sending signals to the monitored process might
come in handy as well.
Thinking about this a bit more, could the fd field take on the dual role
of allowing you to read the file in question as well as acting as a
pidfd?
Marko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: fanotify and pidfd?
2019-06-07 13:48 fanotify and pidfd? Marko Rauhamaa
@ 2019-06-07 17:29 ` Amir Goldstein
2019-06-08 10:55 ` Marko Rauhamaa
0 siblings, 1 reply; 3+ messages in thread
From: Amir Goldstein @ 2019-06-07 17:29 UTC (permalink / raw)
To: Marko Rauhamaa; +Cc: linux-fsdevel
On Fri, Jun 7, 2019 at 5:31 PM Marko Rauhamaa
<marko.rauhamaa@f-secure.com> wrote:
>
>
> As it stands, fanotify reports the process ID of the file that is being
> operated on:
>
> struct fanotify_event_metadata {
> __u32 event_len;
> __u8 vers;
> __u8 reserved;
> __u16 metadata_len;
> __aligned_u64 mask;
> __s32 fd;
> __s32 pid;
> };
>
> One nasty problem with this is that the process often is long gone by
> the time the notification arrives.
>
> Would it be possible to amend this format with:
>
> __s32 pidfd;
>
It's possible to report pidfd instead of pid with user opt-in
(i.e. FAN_REPORT_PIDFD)
If you want to implement this, follow the footsteps of code, test and
man page for FAN_REPORT_TID.
> It would hold the pid still for the duration of notification processing
> and allow for the fanotify monitor to safely use the pid field to
> inspect /proc/<pid>.
>
It will hold pid until someone closes pidfd.
That also needs to be documented.
> And the possibility of sending signals to the monitored process might
> come in handy as well.
>
> Thinking about this a bit more, could the fd field take on the dual role
> of allowing you to read the file in question as well as acting as a
> pidfd?
>
Please no.
Thanks,
Amir.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: fanotify and pidfd?
2019-06-07 17:29 ` Amir Goldstein
@ 2019-06-08 10:55 ` Marko Rauhamaa
0 siblings, 0 replies; 3+ messages in thread
From: Marko Rauhamaa @ 2019-06-08 10:55 UTC (permalink / raw)
To: Amir Goldstein; +Cc: linux-fsdevel
Amir Goldstein <amir73il@gmail.com>:
> On Fri, Jun 7, 2019 at 5:31 PM Marko Rauhamaa
> <marko.rauhamaa@f-secure.com> wrote:
>> Would it be possible to amend this format with:
>>
>> __s32 pidfd;
>>
>
> It's possible to report pidfd instead of pid with user opt-in
> (i.e. FAN_REPORT_PIDFD)
>
> If you want to implement this, follow the footsteps of code, test and
> man page for FAN_REPORT_TID.
I hear you.
Marko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-06-08 10:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-07 13:48 fanotify and pidfd? Marko Rauhamaa
2019-06-07 17:29 ` Amir Goldstein
2019-06-08 10:55 ` Marko Rauhamaa
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 NNTP newsgroup(s).