All of lore.kernel.org
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] proc/wchan: Use printk format instead of lookup_symbol_name()
Date: Wed, 23 Dec 2020 10:48:10 +0100	[thread overview]
Message-ID: <b54649ea-1bec-25a9-2c22-35bdfabc89a9@gmx.de> (raw)
In-Reply-To: <20201222181807.360cd9458d50b625608b8b44@linux-foundation.org>

On 12/23/20 3:18 AM, Andrew Morton wrote:
> On Thu, 17 Dec 2020 17:54:13 +0100 Helge Deller <deller@gmx.de> wrote:
>
>> To resolve the symbol fuction name for wchan, use the printk format
>> specifier %ps instead of manually looking up the symbol function name
>> via lookup_symbol_name().
>>
>> Signed-off-by: Helge Deller <deller@gmx.de>
>>
>
> Please don't forget the "^---$" to separate the changelog from the
> diff.

Ok.

>
>>  #include <linux/module.h>
>> @@ -386,19 +385,17 @@ static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns,
>>  			  struct pid *pid, struct task_struct *task)
>>  {
>>  	unsigned long wchan;
>> -	char symname[KSYM_NAME_LEN];
>>
>> -	if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS))
>> -		goto print0;
>> +	if (ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS))
>> +		wchan = get_wchan(task);
>> +	else
>> +		wchan = 0;
>>
>> -	wchan = get_wchan(task);
>> -	if (wchan && !lookup_symbol_name(wchan, symname)) {
>> -		seq_puts(m, symname);
>> -		return 0;
>> -	}
>> +	if (wchan)
>> +		seq_printf(m, "%ps", (void *) wchan);
>> +	else
>> +		seq_putc(m, '0');
>>
>> -print0:
>> -	seq_putc(m, '0');
>>  	return 0;
>>  }
>
> We can simplify this further?
>
> static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns,
> 			  struct pid *pid, struct task_struct *task)
> {
> 	if (ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS))
> 		seq_printf(m, "%ps", (void *)get_wchan(task));
> 	else
> 		seq_putc(m, '0');
>
> 	return 0;
> }
>
>
> --- a/fs/proc/base.c~proc-wchan-use-printk-format-instead-of-lookup_symbol_name-fix
> +++ a/fs/proc/base.c
> @@ -384,15 +384,8 @@ static const struct file_operations proc
>  static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns,
>  			  struct pid *pid, struct task_struct *task)
>  {
> -	unsigned long wchan;
> -
>  	if (ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS))
> -		wchan = get_wchan(task);
> -	else
> -		wchan = 0;
> -
> -	if (wchan)
> -		seq_printf(m, "%ps", (void *) wchan);
> +		seq_printf(m, "%ps", (void *)get_wchan(task));
>  	else
>  		seq_putc(m, '0');

get_wchan() does return NULL sometimes, in which case with
your change now "0x0" instead of "0" gets printed.

If that's acceptable, then your patch is Ok.

Helge

  reply	other threads:[~2020-12-23  9:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17 16:54 [PATCH] proc/wchan: Use printk format instead of lookup_symbol_name() Helge Deller
2020-12-23  2:18 ` Andrew Morton
2020-12-23  9:48   ` Helge Deller [this message]
2020-12-23 20:29     ` Andrew Morton
2021-01-03 14:27 ` [proc/wchan] 30a3a19273: leaking-addresses.proc.wchan./proc/bus/input/devices:B:KEY=1000000000007ff980000000007fffebeffdfffeffffffffffffffffffffe kernel test robot
2021-01-03 14:27   ` kernel test robot
2021-01-03 18:25   ` Helge Deller
2021-01-03 18:25     ` Helge Deller
2021-01-04 13:27     ` Oliver Sang
2021-01-04 13:27       ` Oliver Sang
2021-09-24  1:01     ` /proc/$pid/chan kernel address exposures (was Re: [proc/wchan] 30a3a19273: leaking-addresses.proc.wchan./proc/bus/input/devices:B:KEY=1000000000007ff980000000007fffebeffdfffeffffffffffffffffffffe) Kees Cook
2021-09-24  1:01       ` Kees Cook

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=b54649ea-1bec-25a9-2c22-35bdfabc89a9@gmx.de \
    --to=deller@gmx.de \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.