lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1305691896.2915.136.camel@work-vm>
Date:	Tue, 17 May 2011 21:11:36 -0700
From:	John Stultz <john.stultz@...aro.org>
To:	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>
Cc:	linux-kernel@...r.kernel.org, joe@...ches.com, mingo@...e.hu,
	mina86@...a86.com, apw@...onical.com, jirislaby@...il.com,
	rientjes@...gle.com, dave@...ux.vnet.ibm.com,
	akpm@...ux-foundation.org, linux-mm@...ck.org
Subject: Re: [PATCH 1/4] comm: Introduce comm_lock spinlock to protect
 task->comm access

On Wed, 2011-05-18 at 11:01 +0900, KOSAKI Motohiro wrote:
> > diff --git a/fs/exec.c b/fs/exec.c
> > index 5e62d26..34fa611 100644
> > --- a/fs/exec.c
> > +++ b/fs/exec.c
> > @@ -998,17 +998,28 @@ static void flush_old_files(struct files_struct * files)
> > 
> >   char *get_task_comm(char *buf, struct task_struct *tsk)
> >   {
> > -	/* buf must be at least sizeof(tsk->comm) in size */
> > -	task_lock(tsk);
> > +	unsigned long flags;
> > +
> > +	spin_lock_irqsave(&tsk->comm_lock, flags);
> >   	strncpy(buf, tsk->comm, sizeof(tsk->comm));
> > -	task_unlock(tsk);
> > +	spin_unlock_irqrestore(&tsk->comm_lock, flags);
> >   	return buf;
> >   }
> > 
> >   void set_task_comm(struct task_struct *tsk, char *buf)
> >   {
> > +	unsigned long flags;
> > +
> > +	/*
> > +	 * XXX - Even though comm is protected by comm_lock,
> > +	 * we take the task_lock here to serialize against
> > +	 * current users that directly access comm.
> > +	 * Once those users are removed, we can drop the
> > +	 * task locking&  memsetting.
> > +	 */
> 
> If we provide __get_task_comm(), we can't remove memset() forever.

True enough. I'll fix that comment up then.

> 
> >   	task_lock(tsk);
> > +	spin_lock_irqsave(&tsk->comm_lock, flags);
> 
> This is strange order. task_lock() doesn't disable interrupt.

Strange order? Can you explain why you think that is? Having comm_lock
as an inner-most lock seems quite reasonable, given the limited nature
of what it protects.

> And, can you please document why we need interrupt disabling?

Since we might access current->comm from irq context. Where would you
like this documented? Just there in the code?

thanks
-john


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ