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, 3 Nov 2013 12:36:47 -0500
From:	Steven Rostedt <rostedt@...dmis.org>
To:	Chen Gang <gang.chen@...anux.com>
Cc:	Frederic Weisbecker <fweisbec@...il.com>,
	Jens Axboe <axboe@...nel.dk>, Tejun Heo <tj@...nel.org>,
	Jan Kara <jack@...e.cz>, "mingo@...hat.com" <mingo@...hat.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] kernel: trace: blktrace: remove redundent memcpy() in
 compat_blk_trace_setup()

A quick review of this patch looks fine to me.

Although, using ARRAY_SIZE() for a character string seems to me a bit
over paranoid. But I'm fine with it, as it makes sure that the string
is an array and not a pointer.

Jens,

Can you give me an Acked-by?

-- Steve


On Sun, 03 Nov 2013 22:23:39 +0800
Chen Gang <gang.chen@...anux.com> wrote:

> do_blk_trace_setup() will fully initialize 'buts.name', so can remove
> the related memcpy(). And also use BLKTRACE_BDEV_SIZE and ARRAY_SIZE
> instead of hard code number '32'.
> 
> 
> Signed-off-by: Chen Gang <gang.chen@...anux.com>
> ---
>  include/linux/blktrace_api.h |    2 +-
>  kernel/trace/blktrace.c      |    3 +--
>  2 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
> index a12f6ed..afc1343 100644
> --- a/include/linux/blktrace_api.h
> +++ b/include/linux/blktrace_api.h
> @@ -89,7 +89,7 @@ static inline int blk_trace_init_sysfs(struct device *dev)
>  #ifdef CONFIG_COMPAT
>  
>  struct compat_blk_user_trace_setup {
> -	char name[32];
> +	char name[BLKTRACE_BDEV_SIZE];
>  	u16 act_mask;
>  	u32 buf_size;
>  	u32 buf_nr;
> diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
> index 7f727b3..f785aef 100644
> --- a/kernel/trace/blktrace.c
> +++ b/kernel/trace/blktrace.c
> @@ -579,13 +579,12 @@ static int compat_blk_trace_setup(struct request_queue *q, char *name,
>  		.end_lba = cbuts.end_lba,
>  		.pid = cbuts.pid,
>  	};
> -	memcpy(&buts.name, &cbuts.name, 32);
>  
>  	ret = do_blk_trace_setup(q, name, dev, bdev, &buts);
>  	if (ret)
>  		return ret;
>  
> -	if (copy_to_user(arg, &buts.name, 32)) {
> +	if (copy_to_user(arg, &buts.name, ARRAY_SIZE(buts.name))) {
>  		blk_trace_remove(q);
>  		return -EFAULT;
>  	}

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