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:   Thu, 14 Nov 2019 07:03:29 +0000
From:   Dmitry Monakhov <dmonakhov@...il.com>
To:     linux-ext4@...r.kernel.org
Cc:     tytso@....edu, Dmitry Monakhov <dmonakhov@...il.com>
Subject: [PATCH 1/2] ext4: Use raw numbers for EXT4_MAP_XXX flags

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),
..
This means that  perf-script can not decode bintrace file because BH_XXX is just a text and it is
unknown for perf's userspace. As result perf will dump this field as raw hex number
This patch use explicit numbers to describe EXT4_MAP_XXX flags so __print_flags will works as expected.

#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>
---
 fs/ext4/ext4.h | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index bf660aa..9ccf736 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -169,14 +169,32 @@ struct ext4_allocation_request {
  * This structure is used to pass requests into ext4_map_blocks() as
  * well as to store the information returned by ext4_map_blocks().  It
  * takes less room on the stack than a struct buffer_head.
+ *
+ * Use explicit mapping of EXT4_MAP_XXX flags to corresponding BH_XXX bits
  */
-#define EXT4_MAP_NEW		(1 << BH_New)
-#define EXT4_MAP_MAPPED		(1 << BH_Mapped)
-#define EXT4_MAP_UNWRITTEN	(1 << BH_Unwritten)
-#define EXT4_MAP_BOUNDARY	(1 << BH_Boundary)
+#define EXT4_MAP_NEW		0x40
+#define EXT4_MAP_MAPPED		0x20
+#define EXT4_MAP_UNWRITTEN	0x1000
+#define EXT4_MAP_BOUNDARY	0x400
 #define EXT4_MAP_FLAGS		(EXT4_MAP_NEW | EXT4_MAP_MAPPED |\
 				 EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY)
 
+/*
+ * Assert that EXT4_MAP_XX is consistent with respect to BH_XXX. If all is well,
+ * the macros will be dropped, so, it won't cost any extra space in the compiled
+ * kernel image, otherwise, the build will fail.
+ */
+#define TEST_MAP_VALUE(FLAG, BIT) (EXT4_MAP_##FLAG == (1 << BH_##BIT))
+#define CHECK_MAP_VALUE(FLAG, BIT) BUILD_BUG_ON(!TEST_MAP_VALUE(FLAG, BIT))
+
+static inline void ext4_check_map_values(void)
+{
+	CHECK_MAP_VALUE(NEW, New);
+	CHECK_MAP_VALUE(MAPPED, Mapped);
+	CHECK_MAP_VALUE(UNWRITTEN, Unwritten);
+	CHECK_MAP_VALUE(BOUNDARY, Boundary);
+}
+
 struct ext4_map_blocks {
 	ext4_fsblk_t m_pblk;
 	ext4_lblk_t m_lblk;
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ