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]
Date:	Sun, 5 Oct 2014 15:56:55 -0400
From:	Tejun Heo <tj@...nel.org>
To:	NeilBrown <neilb@...e.de>
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	linux-kernel@...r.kernel.org, Al Viro <viro@...IV.linux.org.uk>
Subject: Re: [PATCH 1/2] sysfs - allow attributes to request write buffer be
 pre-allocated.

Hello,

Generally looks good to me.  Some nitpicks follow.

On Tue, Sep 30, 2014 at 12:33:34PM +1000, NeilBrown wrote:
...
> diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
> index 4429d6d9217f..73bd5ed143cd 100644
> --- a/fs/kernfs/file.c
> +++ b/fs/kernfs/file.c
> @@ -278,16 +278,12 @@ static ssize_t kernfs_fop_write(struct file *file, const char __user *user_buf,
>  		len = min_t(size_t, count, PAGE_SIZE);
>  	}
>  
> -	buf = kmalloc(len + 1, GFP_KERNEL);
> +	buf = of->buf;
> +	if (!buf)
> +		buf = kmalloc(len + 1, GFP_KERNEL);
>  	if (!buf)
>  		return -ENOMEM;
>  
> -	if (copy_from_user(buf, user_buf, len)) {
> -		len = -EFAULT;
> -		goto out_free;
> -	}
> -	buf[len] = '\0';	/* guarantee string termination */
> -
>  	/*
>  	 * @of->mutex nests outside active ref and is just to ensure that
>  	 * the ops aren't called concurrently for the same open file.

We probably should update the above comment.

> diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
> index 30faf797c2c3..07c326761671 100644
> --- a/include/linux/kernfs.h
> +++ b/include/linux/kernfs.h
> @@ -179,6 +179,7 @@ struct kernfs_open_file {
>  	struct mutex		mutex;
>  	int			event;
>  	struct list_head	list;
> +	char			*buf;

Maybe something like ->prealloc_buf is better?

Thanks.

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