Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1742643

Re: [PATCH v2 2/2] pid: Remove pidhash

From Gargi Sharma <gs051095@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 2/2] pid: Remove pidhash
Date 2017-09-30 17:50 +0200
Message-ID <uvsbE-62p-7@gated-at.bofh.it> (permalink)
References <uucLD-6o3-3@gated-at.bofh.it> <uucLE-6o3-5@gated-at.bofh.it> <uumL0-51X-7@gated-at.bofh.it> <uunnH-5tL-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Sep 27, 2017 at 9:58 PM, Oleg Nesterov <oleg@redhat.com> wrote:
> If I was not clear...
>
> in short, after this patch the very first idr_alloc_cyclic() is already
> wrong. Because, once again, the new not-fully-initialized pid can be found
> by find_pid_ns().

 If the PIDNS_ADDING check fails, I jump to the flag that performs
 this
 while (++i <= ns->level)
                 idr_remove(&ns->idr, (pid->numbers + i)->nr);
 So when find_pid_ns() is called, it will not find this pid.

>
> perhaps you should chane the previous patch to do
> idr_alloc_cyclic(ptr = NULL) and use idr_replace() in this patch after
> the PIDNS_HASH_ADDING check.

I'm not sure if I understand this. Do we want to do this to make sure
the pid namespace is
initialized before the first process enters into
the namespace? If yes, how does idr_alloc_cyclic(ptr = NULL) help?

>
> And I just noticed you didn't cc Eric Biederman <ebiederm@xmission.com>,
> please do next time.

Sorry for missing out on this. Will do with the next version.

Thanks!
Gargi
>
>
> On 09/27, Oleg Nesterov wrote:
>>
>> On 09/27, Gargi Sharma wrote:
>> >
>> > -#define find_next_offset(map, off)                                 \
>> > -           find_next_zero_bit((map)->page, BITS_PER_PAGE, off)
>> > -
>>
>> this should go into the previous patch, but this is minor...
>>
>> > @@ -208,12 +200,10 @@ struct pid *alloc_pid(struct pid_namespace *ns)
>> >
>> >     upid = pid->numbers + ns->level;
>> >     spin_lock_irq(&pidmap_lock);
>> > -   if (!(ns->nr_hashed & PIDNS_HASH_ADDING))
>> > +   if (!(ns->pid_allocated & PIDNS_ADDING))
>> >             goto out_unlock;
>> >     for ( ; upid >= pid->numbers; --upid) {
>> > -           hlist_add_head_rcu(&upid->pid_chain,
>> > -                           &pid_hash[pid_hashfn(upid->nr, upid->ns)]);
>> > -           upid->ns->nr_hashed++;
>> > +           upid->ns->pid_allocated++;
>>
>> No, this is wrong.
>>
>> It is too late to check PIDNS_HASH_ADDING/PIDNS_ADDING and increment pid_allocated,
>> once we call idr_alloc_cyclic() this pid is already "hashed" in that it can be found
>> by find_pid_ns() with this patch applied.
>>
>> And of course, it is too late to do atomic_set(&pid->count, 1) and initialize
>> pid->tasks[type] lists by the same reason.
>>
>> Oleg.
>

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/2] Replace PID bitmap allocation with IDR API Gargi Sharma <gs051095@gmail.com> - 2017-09-27 07:10 +0200
  [PATCH v2 1/2] pid: Replace pid bitmap implementation with IDR API Gargi Sharma <gs051095@gmail.com> - 2017-09-27 07:10 +0200
    Re: [PATCH v2 1/2] pid: Replace pid bitmap implementation with IDR  API Rik van Riel <riel@surriel.com> - 2017-09-27 15:20 +0200
      Re: [PATCH v2 1/2] pid: Replace pid bitmap implementation with IDR  API Oleg Nesterov <oleg@redhat.com> - 2017-09-27 16:10 +0200
        Re: [PATCH v2 1/2] pid: Replace pid bitmap implementation with IDR API Gargi Sharma <gs051095@gmail.com> - 2017-09-27 17:10 +0200
          Re: [PATCH v2 1/2] pid: Replace pid bitmap implementation with IDR  API Oleg Nesterov <oleg@redhat.com> - 2017-09-27 17:20 +0200
      Re: [PATCH v2 1/2] pid: Replace pid bitmap implementation with IDR API Gargi Sharma <gs051095@gmail.com> - 2017-09-27 17:10 +0200
    Re: [PATCH v2 1/2] pid: Replace pid bitmap implementation with IDR  API Oleg Nesterov <oleg@redhat.com> - 2017-09-27 17:10 +0200
    Re: [PATCH v2 1/2] pid: Replace pid bitmap implementation with IDR  API Christoph Hellwig <hch@infradead.org> - 2017-10-01 11:20 +0200
      Re: [PATCH v2 1/2] pid: Replace pid bitmap implementation with IDR API Gargi Sharma <gs051095@gmail.com> - 2017-10-01 12:40 +0200
        Re: [PATCH v2 1/2] pid: Replace pid bitmap implementation with IDR  API Rik van Riel <riel@surriel.com> - 2017-10-02 15:20 +0200
      Re: [PATCH v2 1/2] pid: Replace pid bitmap implementation with IDR  API Rik van Riel <riel@surriel.com> - 2017-10-02 15:10 +0200
  [PATCH v2 2/2] pid: Remove pidhash Gargi Sharma <gs051095@gmail.com> - 2017-09-27 07:10 +0200
    Re: [PATCH v2 2/2] pid: Remove pidhash Oleg Nesterov <oleg@redhat.com> - 2017-09-27 17:50 +0200
      Re: [PATCH v2 2/2] pid: Remove pidhash Oleg Nesterov <oleg@redhat.com> - 2017-09-27 18:30 +0200
        Re: [PATCH v2 2/2] pid: Remove pidhash Gargi Sharma <gs051095@gmail.com> - 2017-09-30 17:50 +0200
      Re: [PATCH v2 2/2] pid: Remove pidhash Rik van Riel <riel@surriel.com> - 2017-10-02 22:50 +0200
        Re: [PATCH v2 2/2] pid: Remove pidhash Gargi Sharma <gs051095@gmail.com> - 2017-10-02 22:50 +0200
      Re: [PATCH v2 2/2] pid: Remove pidhash Oleg Nesterov <oleg@redhat.com> - 2017-10-02 22:50 +0200
      Re: [PATCH v2 2/2] pid: Remove pidhash Rik van Riel <riel@surriel.com> - 2017-10-02 22:50 +0200
  Re: [PATCH v2 0/2] Replace PID bitmap allocation with IDR API ebiederm@xmission.com (Eric W. Biederman) - 2017-09-27 19:20 +0200
    Re: [PATCH v2 0/2] Replace PID bitmap allocation with IDR API Rik van Riel <riel@surriel.com> - 2017-09-28 21:50 +0200
      Re: [PATCH v2 0/2] Replace PID bitmap allocation with IDR API Gargi Sharma <gs051095@gmail.com> - 2017-09-28 22:10 +0200
        Re: [PATCH v2 0/2] Replace PID bitmap allocation with IDR API Rik van Riel <riel@surriel.com> - 2017-09-29 02:40 +0200

csiph-web