The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: jkosina@suse.cz, joe@perches.com, viro@zeniv.linux.org.uk,
	davem@davemloft.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lib/vsprintf: add %pT[C012] format specifier
Date: Fri, 27 Dec 2013 15:02:11 -0800	[thread overview]
Message-ID: <20131227150211.61328c02d61722cb212649e9@linux-foundation.org> (raw)
In-Reply-To: <201312252137.IDC43215.OLtJQFHOFMVFSO@I-love.SAKURA.ne.jp>

On Wed, 25 Dec 2013 21:37:33 +0900 Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> wrote:

> Some examples for converting direct ->comm users are shown below.
> 
>   pr_info("comm=%s\n", p->comm);                => pr_info("comm=%pTC\n", p);
>   pr_info("%s[%u]\n", p->comm, p->pid);         => pr_info("%pT0\n", p);
>   pr_info("%s[%u]\n", p->comm, task_pid_nr(p)); => pr_info("%pT0\n", p);
>   pr_info("%s/%u\n", p->comm, p->pid);          => pr_info("%pT1\n", p);
>   pr_info("%s,%u\n", p->comm, p->pid);          => pr_info("%pT2\n", p);

Places where one task accesses a different tasks's ->comm are rare, and
those places damn well better have a lot of locking in place -
otherwise they are racy against much more serious things than prctl().

The vast majority of ->comm accesses are accessing current->comm, for
debug reasons.  I'm counting 350-odd sites.  At all these sites it's
pointless passing `current' to the printk function at all!

I wonder if there's some way in which we can invent a vsprintf token
which means "insert corrent->comm here" and which doesn't require that
the caller pass in the additional argument?



That being said.....

current->comm isn't a terribly good way of identifying a task - it's
unaware of namespaces, is non-unique, userspace can overwrite ->comm[]
to anything it wants and evil users can probably write silly stuff into
->comm[] to confuse sysadmin tools.

So perhaps the world would be a better place if we were to invent a
standard kernel-wide way of identifying a process within a debug
printk.  Presumably it would include ->comm and the pid, but other
things can be added later if needed.

So a usage site would look like:

	pr_warn("%s: hair on fire\n", this_task_id());

but we need storage so it's really

	char b[THIS_TASK_ID_SIZE];

	pr_warn("%s: hair on fire\n", this_task_id(b));

which is painful, so we also provide the new vsprintf token as a
convenience:

	pr_warn("%|: hair on fire\n");

but I don't know what we can use in place of %|.




  parent reply	other threads:[~2013-12-27 23:02 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-25 12:37 [PATCH] lib/vsprintf: add %pT[C012] format specifier Tetsuo Handa
2013-12-26  8:43 ` Joe Perches
2013-12-27 23:02 ` Andrew Morton [this message]
2013-12-28  3:43   ` Tetsuo Handa
2013-12-28 18:57     ` Geert Uytterhoeven
2013-12-28 19:25       ` Andrew Morton
2013-12-28 19:25         ` Geert Uytterhoeven
2013-12-28 19:53           ` Joe Perches
2013-12-28 20:08             ` Andrew Morton
2013-12-28 20:24               ` Joe Perches
2013-12-29  0:32                 ` Tetsuo Handa
2013-12-29  2:07                   ` Joe Perches
2013-12-29 12:13                     ` Tetsuo Handa
2013-12-30 16:55                       ` Joe Perches
2013-12-31  6:53                         ` Tetsuo Handa
2013-12-31 16:24                           ` Joe Perches
2014-01-01  5:34                             ` Tetsuo Handa
2014-01-01  5:49                               ` Joe Perches
2014-01-01 10:02                                 ` Tetsuo Handa
2014-01-02  1:33                                   ` Joe Perches
2014-01-02  4:49                                     ` Tetsuo Handa
2014-01-03 17:08                                       ` Kees Cook
2014-01-03 17:39                                         ` Joe Perches
2014-01-03 17:49                                           ` Kees Cook
2014-01-04  2:26                                             ` Tetsuo Handa
2014-01-05  3:15                                               ` Tetsuo Handa
2014-01-05 18:09                                                 ` Joe Perches
2014-01-06 14:00                                                   ` Tetsuo Handa
2014-01-06 17:34                                                     ` Joe Perches
2014-01-06 21:41                                                       ` Tetsuo Handa
2014-01-06 22:25                                                         ` Joe Perches
2014-01-07  0:16                                                           ` Pavel Machek
2014-01-07  1:03                                                             ` Joe Perches
2014-01-07  8:37                                                               ` Pavel Machek
2014-01-07 17:34                                                                 ` Joe Perches
2014-01-07 17:56                                                                   ` Pavel Machek
2014-01-07 18:28                                                                     ` Geert Uytterhoeven
2014-01-08 14:19                                                                     ` Tetsuo Handa
2014-01-08 14:46                                                                       ` Pavel Machek
2014-01-06 21:34                                                     ` Pavel Machek
2014-01-05 22:27                                                 ` Pavel Machek
2014-01-06 14:02                                                   ` Tetsuo Handa
2014-01-10 13:15                                                     ` Tetsuo Handa
2014-01-02  1:38                                   ` Joe Perches
2014-01-02 11:51               ` Pavel Machek

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=20131227150211.61328c02d61722cb212649e9@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=jkosina@suse.cz \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --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