linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masatake YAMATO <yamato@redhat.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk,
	linux-fsdevel@vger.kernel.org, keescook@chromium.org
Subject: Re: [PATCH RESEND] eventfd: prepare id to userspace via fdinfo
Date: Thu, 21 Mar 2019 12:37:06 +0900 (JST)	[thread overview]
Message-ID: <20190321.123706.289086486788904430.yamato@redhat.com> (raw)
In-Reply-To: <20190320120525.3ed8d21648ea8a573bbd4acf@linux-foundation.org>

Thank you for the comment.

On Wed, 20 Mar 2019 12:05:25 -0700, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Wed, 20 Mar 2019 18:29:29 +0900 Masatake YAMATO <yamato@redhat.com> wrote:
> 
>> Finding endpoints of an IPC channel is one of essential task to
>> understand how a user program works. Procfs and netlink socket provide
>> enough hints to find endpoints for IPC channels like pipes, unix
>> sockets, and pseudo terminals. However, there is no simple way to find
>> endpoints for an eventfd file from userland. An inode number doesn't
>> hint. Unlike pipe, all eventfd files share the same inode object.
>> 
>> To provide the way to find endpoints of an eventfd file, this patch
>> adds "eventfd-id" field to /proc/PID/fdinfo of eventfd as identifier.
>> Address for eventfd context is used as id.
>> 
>> A tool like lsof can utilize the information to print endpoints.
>> 
>> ...
>>
>> --- a/fs/eventfd.c
>> +++ b/fs/eventfd.c
>> @@ -297,6 +297,7 @@ static void eventfd_show_fdinfo(struct seq_file *m, struct file *f)
>>  	seq_printf(m, "eventfd-count: %16llx\n",
>>  		   (unsigned long long)ctx->count);
>>  	spin_unlock_irq(&ctx->wqh.lock);
>> +	seq_printf(m, "eventfd-id: %p\n", ctx);
>>  }
>>  #endif
> 
> Is it a good idea to use a bare kernel address for this?  How does this
> interact with printk pointer randomization and hashing?
> 

My understanding is that an address printed with %p for a bare kernel
address is stable after ptr_key in vsprintf.c is filled, and ptr_key
is filled enough early stage. so, for my usecase, resolving IPC endpoints,
printing a bare kernel address with %p may be enough. Am I missing something?

For the same purpose, I submitted a ida based patch a year ago.
(https://patchwork.kernel.org/patch/10413589/)
I quote it here for getting comments:

This one doesn't use any bare kernel addresses. I implemented new one (%p version)
bacause is is much shorter.

Do you think ida based one is better than %p based one?

Masatake YAMATO

  reply	other threads:[~2019-03-21  3:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20  9:29 [PATCH RESEND] eventfd: prepare id to userspace via fdinfo Masatake YAMATO
2019-03-20 19:05 ` Andrew Morton
2019-03-21  3:37   ` Masatake YAMATO [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-03-06  7:08 Masatake YAMATO
2019-02-05 11:46 Masatake YAMATO

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=20190321.123706.289086486788904430.yamato@redhat.com \
    --to=yamato@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 NNTP newsgroup(s).