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: <20091004231027.GA5701@hmsreliant.think-freely.org>
Date:	Sun, 4 Oct 2009 19:10:27 -0400
From:	Neil Horman <nhorman@...driver.com>
To:	Marcin Slusarz <marcin.slusarz@...il.com>
Cc:	linux-kernel@...r.kernel.org, akpm@...ux-foundation.org
Subject: Re: [PATCH 1/3] extend get/setrlimit to support setting rlimits
	external to a process (v3)

On Sun, Oct 04, 2009 at 10:04:20PM +0200, Marcin Slusarz wrote:
> Neil Horman wrote:
> >>> +static ssize_t proc_pid_limit_write(struct file *file, const char __user *buf,
> >>> +		size_t count, loff_t *ppos)
> >>> +{
> >>> +	char *buffer;
> >>> +	char *element, *vmc, *vmm;
> >>> +	struct rlimit new_rlim;
> >>> +	unsigned long flags;
> >>> +	int i;
> >>> +	int index = -1;
> >>> +	size_t wcount = 0;
> >>> +	struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
> >>> +
> >>> +
> >>> +	if (*ppos != 0)
> >>> +		goto out;
> >>> +
> >>> +	if (count > 128)
> >>> +		goto out;
> >>> +	buffer = kzalloc(128, GFP_KERNEL);
> >>> +
> >>> +	if (!buffer)
> >>> +		goto out;
> >> element, vmc, vmm are not initialized and you kfree them in this case
> >>
> > Yep, I'll fix that
> > 
> >>> +
> >>> +	element = kzalloc(sizeof(buffer), GFP_KERNEL);
> >>> +	vmc = kzalloc(sizeof(buffer), GFP_KERNEL);
> >>> +	vmm = kzalloc(sizeof(buffer), GFP_KERNEL);
> >> sizeof(buffer) == 4 or 8 - pretty short buffer...
> >>
> >>> +
> >>> +	if (!element || !vmm || !vmc)
> >>> +		goto out_free;
> >>> +
> >>> +	wcount = count - copy_from_user(buffer, buf, count);
> >>> +	if (wcount < count)
> >>> +		goto out_free;
> >> copy_from_user usage usually looks like:
> >> if (copy_from_user()) {
> >> 	ret = -EFAULT;
> >> 	goto err;
> >> }
> >> you don't seem to use copy_from_user return value for anything useful
> >>
> > I did at one point, a few versions ago, that can likely be removed now.
> > 
> >>> +
> >>> +	i = sscanf(buffer, "%s %s %s", element, vmc, vmm);
> >> what if user pass strings longer than size of buffers?
> >>
> > You fail the write, theres a check at the top of the function for that.  By the
> > time you get here, buffer is guaranteed to be no more than 128 bytes.
> 
Crud, you're right, that only works with static arrays, I'll fix that up.
Thanks!
> 
--
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