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: <20120308135643.225920ad.akpm@linux-foundation.org>
Date:	Thu, 8 Mar 2012 13:56:43 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	David Rientjes <rientjes@...gle.com>
Cc:	Dave Jones <davej@...hat.com>, linux-kernel@...r.kernel.org,
	linux-mm@...ck.org
Subject: Re: [patch] mm, hugetlb: add thread name and pid to SHM_HUGETLB
 mlock rlimit warning

On Thu, 8 Mar 2012 13:37:57 -0800 (PST)
David Rientjes <rientjes@...gle.com> wrote:

> On Thu, 8 Mar 2012, Andrew Morton wrote:
> 
> > > --- a/fs/hugetlbfs/inode.c
> > > +++ b/fs/hugetlbfs/inode.c
> > > @@ -946,7 +946,11 @@ struct file *hugetlb_file_setup(const char *name, size_t size,
> > >  	if (creat_flags == HUGETLB_SHMFS_INODE && !can_do_hugetlb_shm()) {
> > >  		*user = current_user();
> > >  		if (user_shm_lock(size, *user)) {
> > > -			printk_once(KERN_WARNING "Using mlock ulimits for SHM_HUGETLB is deprecated\n");
> > > +			task_lock(current);
> > > +			printk_once(KERN_WARNING
> > > +				"%s (%d): Using mlock ulimits for SHM_HUGETLB is deprecated\n",
> > > +				current->comm, current->pid);
> > > +			task_unlock(current);
> > 
> > I assume the task_lock() is there to protect current->comm.
> 
> Yup.
> 
> > If so, it
> > is unneeded - we're protecting against prctl(PR_SET_NAME), and
> > PR_SET_NAME only operates on current, and we know this task isn't
> > currently running PR_SET_NAME.
> > 
> > If there's a way for another task to alter this task's ->comm then we
> > _do_ need locking.  But there isn't a way, I hope.
> > 
> 
> I wish there wasn't as well, it would prevent a lot of the currently buggy 
> reads to current->comm and allow us to avoid so many otherwise pointless 
> task_lock()s.
> 
> This protects against /proc/pid/comm, which is writable by threads in the 
> same thread group.

Oh crap.

>  We have a get_task_comm() that does the task_lock() 
> internally but requires a TASK_COMM_LEN buffer in the calling code.  It's 
> just easier for the calling code to the task_lock() itself for a tiny 
> little printk().

Well for a tiny little printk we could just omit the locking?  The
printk() won't oops and once in a million years one person will see a
garbled comm[] string?

--
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