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  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:   Thu, 14 Nov 2019 13:01:17 -0800
From:   "Darrick J. Wong" <darrick.wong@...cle.com>
To:     Dmitry Monakhov <dmonakhov@...il.com>
Cc:     linux-ext4@...r.kernel.org, tytso@....edu
Subject: Re: [PATCH 1/2] ext4: fix symbolic enum printing in trace output

On Thu, Nov 14, 2019 at 08:01:46PM +0000, Dmitry Monakhov wrote:
> Trace's macro __print_flags() produce raw event's decraration w/o knowing actual
> flags value
> 
> cat /sys/kernel/debug/tracing/events/ext4/ext4_ext_map_blocks_exit/format
> ..
> __print_flags(REC->mflags, "", { (1 << BH_New),
> 
> For that reason we have to explicitly define it via special macro TRACE_DEFINE_ENUM()
> Also add missed EXTENT_STATUS_REFERENCED flag.
> 
> #Before patch
> ext4:ext4_ext_map_blocks_exit: dev 253,0 ino 2 flags  lblk 0 pblk 4177 len 1 mflags 0x20 ret 1
> ext4:ext4_ext_map_blocks_exit: dev 253,0 ino 12 flags CREATE lblk 0 pblk 34304 len 1 mflags 0x60 ret 1
> 
> #With patch
> ext4:ext4_ext_map_blocks_exit: dev 253,0 ino 2 flags  lblk 0 pblk 4177 len 1 mflags M ret 1
> ext4:ext4_ext_map_blocks_exit: dev 253,0 ino 12 flags CREATE lblk 0 pblk 34816 len 1 mflags NM ret 1
> 
> Signed-off-by: Dmitry Monakhov <dmonakhov@...il.com>
> ---
>  include/trace/events/ext4.h | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
> index 182c9fe..3bf7128 100644
> --- a/include/trace/events/ext4.h
> +++ b/include/trace/events/ext4.h
> @@ -48,6 +48,16 @@ struct partial_cluster;
>  	{ EXT4_GET_BLOCKS_KEEP_SIZE,		"KEEP_SIZE" },		\
>  	{ EXT4_GET_BLOCKS_ZERO,			"ZERO" })
>  
> +/*
> + * __print_flags() requires that all enum values be wrapped in the
> + * TRACE_DEFINE_ENUM macro so that the enum value can be encoded in the ftrace
> + * ring buffer.
> + */
> +TRACE_DEFINE_ENUM(BH_New);
> +TRACE_DEFINE_ENUM(BH_Mapped);
> +TRACE_DEFINE_ENUM(BH_Unwritten);
> +TRACE_DEFINE_ENUM(BH_Boundary);
> +
>  #define show_mflags(flags) __print_flags(flags, "",	\
>  	{ EXT4_MAP_NEW,		"N" },			\
>  	{ EXT4_MAP_MAPPED,	"M" },			\
> @@ -62,11 +72,18 @@ struct partial_cluster;
>  	{ EXT4_FREE_BLOCKS_NOFREE_FIRST_CLUSTER,"1ST_CLUSTER" },\
>  	{ EXT4_FREE_BLOCKS_NOFREE_LAST_CLUSTER,	"LAST_CLUSTER" })
>  
> +TRACE_DEFINE_ENUM(ES_WRITTEN_B);
> +TRACE_DEFINE_ENUM(ES_UNWRITTEN_B);
> +TRACE_DEFINE_ENUM(ES_DELAYED_B);
> +TRACE_DEFINE_ENUM(ES_HOLE_B);
> +TRACE_DEFINE_ENUM(ES_REFERENCED_B);

I wonder if it's worth leaving a comment wherever this enum is defined
warning developers to keep this TRACE_DEFINE_NUM list (and the string
mapping) up to date?

--D

>  #define show_extent_status(status) __print_flags(status, "",	\
>  	{ EXTENT_STATUS_WRITTEN,	"W" },			\
>  	{ EXTENT_STATUS_UNWRITTEN,	"U" },			\
>  	{ EXTENT_STATUS_DELAYED,	"D" },			\
> -	{ EXTENT_STATUS_HOLE,		"H" })
> +	{ EXTENT_STATUS_HOLE,		"H" },			\
> +	{ EXTENT_STATUS_REFERENCED,	"R" })
>  
>  #define show_falloc_mode(mode) __print_flags(mode, "|",		\
>  	{ FALLOC_FL_KEEP_SIZE,		"KEEP_SIZE"},		\
> -- 
> 2.7.4
> 

Powered by blists - more mailing lists