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] [day] [month] [year] [list]
Date:   Tue, 23 Feb 2021 11:35:30 -0500
From:   Steven Rostedt <rostedt@...dmis.org>
To:     Andrew Scull <ascull@...gle.com>
Cc:     kvmarm@...ts.cs.columbia.edu, linux-kernel@...r.kernel.org,
        maz@...nel.org, james.morse@....com, suzuki.poulose@....com,
        julien.thierry.kdev@...il.com, will@...nel.org,
        catalin.marinas@....com, kernel-team@...roid.com,
        Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH v2 2/4] bug: Factor out a getter for a bug's file line

On Tue, 23 Feb 2021 15:57:57 +0000
Andrew Scull <ascull@...gle.com> wrote:

> There is some non-trivial config-based logic to get the file name and
> line number associated with a bug. Factor this out to a getter that can
> be resused.
> 
> Signed-off-by: Andrew Scull <ascull@...gle.com>
> Cc: Peter Zijlstra <peterz@...radead.org>
> Cc: "Steven Rostedt (VMware)" <rostedt@...dmis.org>
> ---
>  include/linux/bug.h |  3 +++
>  lib/bug.c           | 27 +++++++++++++++++----------
>  2 files changed, 20 insertions(+), 10 deletions(-)
> 
> diff --git a/include/linux/bug.h b/include/linux/bug.h
> index f639bd0122f3..e3841bee4c8d 100644
> --- a/include/linux/bug.h
> +++ b/include/linux/bug.h
> @@ -36,6 +36,9 @@ static inline int is_warning_bug(const struct bug_entry *bug)
>  	return bug->flags & BUGFLAG_WARNING;
>  }
>  
> +void bug_get_file_line(struct bug_entry *bug, const char **file,
> +		       unsigned int *line);
> +
>  struct bug_entry *find_bug(unsigned long bugaddr);
>  
>  enum bug_trap_type report_bug(unsigned long bug_addr, struct pt_regs *regs);
> diff --git a/lib/bug.c b/lib/bug.c
> index 4ab398a2de93..f936615176b8 100644
> --- a/lib/bug.c
> +++ b/lib/bug.c
> @@ -130,6 +130,22 @@ static inline struct bug_entry *module_find_bug(unsigned long bugaddr)
>  }
>  #endif
>  
> +void bug_get_file_line(struct bug_entry *bug, const char **file,
> +		       unsigned int *line)
> +{
> +	*file = NULL;
> +	*line = 0;
> +
> +#ifdef CONFIG_DEBUG_BUGVERBOSE
> +#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
> +	*file = bug->file;
> +#else
> +	*file = (const char *)bug + bug->file_disp;
> +#endif
> +	*line = bug->line;

Not that it should be part of this patch, as this patch is moving the code
and shouldn't modify it, but as a micro optimization, we could remove the
initialization from the beginning and place it here:

#else 
	*file = NULL;
	*line = 0;

But again, this patch is fine.

Reviewed-by: Steven Rostedt (VMware) <rostedt@...dmis.org>

-- Steve


> +#endif
> +}
> +
>  struct bug_entry *find_bug(unsigned long bugaddr)
>  {
>  	struct bug_entry *bug;
> @@ -156,17 +172,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
>  
>  	disable_trace_on_warning();
>  
> -	file = NULL;
> -	line = 0;
> +	bug_get_file_line(bug, &file, &line);
>  
> -#ifdef CONFIG_DEBUG_BUGVERBOSE
> -#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
> -	file = bug->file;
> -#else
> -	file = (const char *)bug + bug->file_disp;
> -#endif
> -	line = bug->line;
> -#endif
>  	warning = (bug->flags & BUGFLAG_WARNING) != 0;
>  	once = (bug->flags & BUGFLAG_ONCE) != 0;
>  	done = (bug->flags & BUGFLAG_DONE) != 0;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ