linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Fengguang Wu <fengguang.wu@intel.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: yama_ptrace_access_check(): possible recursive locking detected
Date: Wed, 15 Aug 2012 11:09:30 -0700	[thread overview]
Message-ID: <CAGXu5jJ+HOdSxS7Ec=TW06h6KEpEmi-rF+Jk8L5LiQsp9gyAtg@mail.gmail.com> (raw)
In-Reply-To: <20120815175651.GA17814@redhat.com>

On Wed, Aug 15, 2012 at 10:56 AM, Oleg Nesterov <oleg@redhat.com> wrote:
> On 08/15, Peter Zijlstra wrote:
>>
>> On Wed, 2012-08-15 at 15:01 +0200, Oleg Nesterov wrote:
>> > BTW, set_task_comm()->wmb() and memset() should die. There are
>> > not needed afaics, and the comment is misleading.
>>
>> As long as we guarantee there's always a terminating '\0',
>
> Yes, but we already have this guarantee?
>
> Unless of course some buggy code does something wrong with task->comm[],
> but nobody should do this.
>
> IOW, task->comm[TASK_COMM_LEN - 1] is always 0, no?
>
>> now strlcpy()
>> doesn't pad the result,
>
> afaics set_task_comm()->strlcpy() doesn't change the last byte too.
>
>> however if we initialize the ->comm to all 0s in
>> fork()
>
> fork() is special, yes. ->comm is copied by dup_task_struct() and
> the new task_struct can have everything in ->comm. But nobody can
> see the new task yet, and nobody can play with its ->comm.
>
> Or I misunderstood?
>
>> That barrier is indeed completely pointless as there's no pairing
>> barrier anywhere.
>
> Yes, agreed.

It sounds like get_task_comm shouldn't have locking at all then? It
should just do a length-limited copy and make sure there is a trailing
0-byte?

-Kees

-- 
Kees Cook
Chrome OS Security

  reply	other threads:[~2012-08-15 18:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-26 13:47 yama_ptrace_access_check(): possible recursive locking detected Fengguang Wu
2012-07-26 15:41 ` Oleg Nesterov
2012-07-30 17:00   ` Kees Cook
2012-08-10  1:39 ` Kees Cook
2012-08-10  1:52   ` Fengguang Wu
2012-08-14 21:16     ` Kees Cook
2012-08-15  3:01       ` Fengguang Wu
2012-08-15  5:56         ` Kees Cook
2012-08-15  8:05           ` Peter Zijlstra
2012-08-15 13:01           ` Oleg Nesterov
2012-08-15 14:30             ` Peter Zijlstra
2012-08-15 17:56               ` Oleg Nesterov
2012-08-15 18:09                 ` Kees Cook [this message]
2012-08-15 18:17                   ` Oleg Nesterov
2012-08-15 18:30                     ` Kees Cook
2012-08-15 18:44                   ` Alan Cox
2012-08-15 18:43                     ` 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='CAGXu5jJ+HOdSxS7Ec=TW06h6KEpEmi-rF+Jk8L5LiQsp9gyAtg@mail.gmail.com' \
    --to=keescook@chromium.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=fengguang.wu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    /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).