From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD6FAC43381 for ; Thu, 21 Mar 2019 03:37:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A399F2075D for ; Thu, 21 Mar 2019 03:37:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727809AbfCUDhK (ORCPT ); Wed, 20 Mar 2019 23:37:10 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55432 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726914AbfCUDhK (ORCPT ); Wed, 20 Mar 2019 23:37:10 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA581406E82E; Thu, 21 Mar 2019 03:37:08 +0000 (UTC) Received: from localhost (unknown [10.64.242.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2AA6517468; Thu, 21 Mar 2019 03:37:06 +0000 (UTC) Date: Thu, 21 Mar 2019 12:37:06 +0900 (JST) Message-Id: <20190321.123706.289086486788904430.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 From: Masatake YAMATO In-Reply-To: <20190320120525.3ed8d21648ea8a573bbd4acf@linux-foundation.org> References: <20190320092929.14628-1-yamato@redhat.com> <20190320120525.3ed8d21648ea8a573bbd4acf@linux-foundation.org> Organization: Red Hat Japan, Inc. Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 21 Mar 2019 03:37:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 21 Mar 2019 03:37:08 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'yamato@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thank you for the comment. On Wed, 20 Mar 2019 12:05:25 -0700, Andrew Morton wrote: > On Wed, 20 Mar 2019 18:29:29 +0900 Masatake YAMATO 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