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


Groups > linux.kernel > #1394627

Re: [PATCH] rlimit: locking tidy ups

From Oleg Nesterov <oleg@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH] rlimit: locking tidy ups
Date 2016-05-04 20:50 +0200
Message-ID <rva1Y-TX-13@gated-at.bofh.it> (permalink)
References <rv7ns-6NC-25@gated-at.bofh.it> <rv8tc-86C-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 05/04, Eric W. Biederman wrote:
>
> Cc'd Oleg as he tends to be deeply involved with this class of locking.
>
> Mateusz Guzik <mguzik@redhat.com> writes:
>
> > proc_pid_limits takes ->sighand lock prior to accessing rlimits, but it
> > serves no purpose as it does not prevent modifications.

Well. I agree this all needs cleanups or at least additional comments, but

> > @@ -618,14 +618,12 @@ static int proc_pid_limits(struct seq_file *m, struct pid_namespace *ns,
> >  			   struct pid *pid, struct task_struct *task)
> >  {
> >  	unsigned int i;
> > -	unsigned long flags;
> >  
> >  	struct rlimit rlim[RLIM_NLIMITS];
> >  
> > -	if (!lock_task_sighand(task, &flags))
> > -		return 0;
> > +	task_lock(task->group_leader);

This is already unsafe. ->group_leader can point to nowhere if this threads
exits. lock_task_sighand() ensures that this can't happen.

> > -	/* protect tsk->signal and tsk->sighand from disappearing */
> > -	read_lock(&tasklist_lock);
> > -	if (!tsk->sighand) {
> > -		retval = -ESRCH;
> > -		goto out;
> > +	task_lock(tsk->group_leader);

The same, but yes the comment is misleading.

Oleg.

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


Thread

[PATCH] rlimit: locking tidy ups Mateusz Guzik <mguzik@redhat.com> - 2016-05-04 18:00 +0200
  Re: [PATCH] rlimit: locking tidy ups ebiederm@xmission.com (Eric W. Biederman) - 2016-05-04 19:10 +0200
    Re: [PATCH] rlimit: locking tidy ups Oleg Nesterov <oleg@redhat.com> - 2016-05-04 20:50 +0200

csiph-web