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: <20090711055418.GA7686@in.ibm.com>
Date:	Sat, 11 Jul 2009 11:24:18 +0530
From:	"K.Prasad" <prasad@...ux.vnet.ibm.com>
To:	Li Zefan <lizf@...fujitsu.com>
Cc:	Ingo Molnar <mingo@...e.hu>,
	Alan Stern <stern@...land.harvard.edu>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Steven Rostedt <rostedt@...dmis.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/8] ksym_tracer: Rewrite ksym_trace_filter_read()

On Tue, Jul 07, 2009 at 01:52:52PM +0800, Li Zefan wrote:
> Reading ksym_trace_filter gave me some arbitrary characters,
> when it should show nothing. It's because buf is not initialized
> when there's no filter.
> 

I started noticing this behaviour recently.

A simple
char buf[KSYM_FILTER_ENTRY_LEN * KSYM_TRACER_MAX] = "\0";
solves the problem.

> Also reduce stack usage by about 512 bytes.
> 

The stack usage would be much lesser on other architectures with fewer
breakpoint registers (like PPC64), and should really be an issue.

> Signed-off-by: Li Zefan <lizf@...fujitsu.com>
> ---
>  kernel/trace/trace_ksym.c |   29 ++++++++++++++++++-----------
>  1 files changed, 18 insertions(+), 11 deletions(-)
> 
> diff --git a/kernel/trace/trace_ksym.c b/kernel/trace/trace_ksym.c
> index 085ff05..b6710d3 100644
> --- a/kernel/trace/trace_ksym.c
> +++ b/kernel/trace/trace_ksym.c
> @@ -35,7 +35,6 @@
>  #define KSYM_TRACER_MAX HBP_NUM
> 
>  #define KSYM_TRACER_OP_LEN 3 /* rw- */
> -#define KSYM_FILTER_ENTRY_LEN (KSYM_NAME_LEN + KSYM_TRACER_OP_LEN + 1)
> 
>  struct trace_ksym {
>  	struct hw_breakpoint	*ksym_hbp;
> @@ -230,25 +229,33 @@ static ssize_t ksym_trace_filter_read(struct file *filp, char __user *ubuf,
>  {
>  	struct trace_ksym *entry;
>  	struct hlist_node *node;
> -	char buf[KSYM_FILTER_ENTRY_LEN * KSYM_TRACER_MAX];
> -	ssize_t ret, cnt = 0;
> +	struct trace_seq *s;
> +	ssize_t cnt = 0;
> +	int ret;
> +
> +	s = kmalloc(sizeof(*s), GFP_KERNEL);
> +	if (!s)
> +		return -ENOMEM;
> +	trace_seq_init(s);
> 
>  	mutex_lock(&ksym_tracer_mutex);
> 
>  	hlist_for_each_entry(entry, node, &ksym_filter_head, ksym_hlist) {
> -		cnt += snprintf(&buf[cnt], KSYM_FILTER_ENTRY_LEN - cnt, "%s:",
> -				entry->ksym_hbp->info.name);
> +		ret = trace_seq_printf(s, "%s:", entry->ksym_hbp->info.name);
>  		if (entry->ksym_hbp->info.type == HW_BREAKPOINT_WRITE)
> -			cnt += snprintf(&buf[cnt], KSYM_FILTER_ENTRY_LEN - cnt,
> -								"-w-\n");
> +			ret = trace_seq_puts(s, "-w-\n");
>  		else if (entry->ksym_hbp->info.type == HW_BREAKPOINT_RW)
> -			cnt += snprintf(&buf[cnt], KSYM_FILTER_ENTRY_LEN - cnt,
> -								"rw-\n");
> +			ret = trace_seq_puts(s, "rw-\n");
> +		WARN_ON_ONCE(!ret);

Given that this change uses the tracer defined functions and a seq-file
implementation, the patch is welcome.

Thanks,
K.Prasad

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