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: <20200519144539.GB317569@hirez.programming.kicks-ass.net>
Date:   Tue, 19 May 2020 16:45:39 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Joe Perches <joe@...ches.com>
Cc:     Dmitry Vyukov <dvyukov@...gle.com>,
        LKML <linux-kernel@...r.kernel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Will Deacon <will@...nel.org>
Subject: Re: lockdep tracing and using of printk return value ?

On Tue, May 19, 2020 at 05:41:47AM -0700, Joe Perches wrote:
> Except for some ancient code in drivers/scsi, this code
> may be the only kernel use of the printk return value.

Is using the printk() return value a problem?

> Code that uses the printk return value in
> kernel/locking/lockdep.c is odd because the printk
> return length includes both the length of a KERN_<LEVEL>
> prefix and the newline.  depth also seems double counted.

Yeah, it seems dodgy. OTOH printk() really ought to discard the
KERN_<level> crud from the return size.

> Perhaps there's a better way to calculate this?
> 
> Maybe:
> ---
>  kernel/locking/lockdep.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 2fadc2635946..265227edc550 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -1960,11 +1960,9 @@ static void print_lock_class_header(struct lock_class *class, int depth)
>  
>  	for (bit = 0; bit < LOCK_USAGE_STATES; bit++) {
>  		if (class->usage_mask & (1 << bit)) {
> -			int len = depth;
> -
> -			len += printk("%*s   %s", depth, "", usage_str[bit]);
> -			len += printk(KERN_CONT " at:\n");
> -			print_lock_trace(class->usage_traces[bit], len);
> +			printk("%*s   %s at:\n", depth, "", usage_str[bit]);
> +			print_lock_trace(class->usage_traces[bit],
> +					 depth + 3 + strlen(usage_str[bit]);
>  		}
>  	}
>  	printk("%*s }\n", depth, "");

Doesn't seem crazy...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ