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: <20221216193248.71333-1-frank.li@vivo.com>
Date:   Sat, 17 Dec 2022 03:32:48 +0800
From:   Yangtao Li <frank.li@...o.com>
To:     jaegeuk@...nel.org, chao@...nel.org
Cc:     linux-f2fs-devel@...ts.sourceforge.net,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] f2fs: merge f2fs_show_injection_info() into time_to_inject()

Hi Chao,

> After moving f2fs_show_injection_info() core functionality into time_to_inject(),
> __builtin_return_address(0) result changes from return address of caller of
> f2fs_show_injection_info() to return address of time_to_inject().

It seems you are wrong, and the original patch didn't change the logic here.
Because time_to_inject is an inline function, __builtin_return_address(0)
has not return address of time_to_inject().

My test:

(1). w/ below patch, we found that the value of __builtin_return_address(0) in
	__time_to_inject() is the same as that in f2fs_show_injection_info().

# mount -t f2fs -o fault_type=0xffff,fault_injection=1 /mnt/9p/f2fs.img /mnt/f2fs
[   19.739661] loop0: detected capacity change from 0 to 2097152
[   19.749759]  new F2FS-fs (loop0) : inject kmalloc in f2fs_kmalloc of f2fs_fill_super+0x7eb/0x1780
[   19.750313] raw F2FS-fs (loop0) : inject kmalloc in f2fs_kmalloc of f2fs_fill_super+0x7eb/0x1780
mount: mounting /dev/loop0 on /mnt/f2fs failed: Cannot allocate memory

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 4035dab1f570..1e5030633f4d 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1876,11 +1876,13 @@ struct f2fs_sb_info {

 #ifdef CONFIG_F2FS_FAULT_INJECTION
 #define f2fs_show_injection_info(sbi, type)                                    \
-       printk_ratelimited("%sF2FS-fs (%s) : inject %s in %s of %pS\n", \
+       printk_ratelimited("%sraw F2FS-fs (%s) : inject %s in %s of %pS\n",     \
                KERN_INFO, sbi->sb->s_id,                               \
                f2fs_fault_name[type],                                  \
                __func__, __builtin_return_address(0))
-static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
+
+#define time_to_inject(sbi, type) __time_to_inject(sbi, type, __func__)
+static inline bool __time_to_inject(struct f2fs_sb_info *sbi, int type, const char *func_name)
 {
        struct f2fs_fault_info *ffi = &F2FS_OPTION(sbi).fault_info;

@@ -1893,6 +1895,10 @@ static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
        atomic_inc(&ffi->inject_ops);
        if (atomic_read(&ffi->inject_ops) >= ffi->inject_rate) {
                atomic_set(&ffi->inject_ops, 0);
+               printk_ratelimited("%s new F2FS-fs (%s) : inject %s in %s of %pS\n",
+                       KERN_INFO, sbi->sb->s_id,
+                       f2fs_fault_name[type],
+                       func_name, __builtin_return_address(0));
                return true;
        }
        return false;

(2). w/ below patch(remove inline form __time_to_inject()), we found that the value of
	__builtin_return_address(0) in __time_to_inject() is different from that in
	f2fs_show_injection_info().

# mount -t f2fs -o fault_type=0xffff,fault_injection=1 /mnt/9p/f2fs.img /mnt/f2fs
[   81.019451] loop0: detected capacity change from 0 to 2097152
[   81.031058]  new F2FS-fs (loop0) : inject kmalloc in f2fs_kmalloc of f2fs_init_write_merge_io+0x35/0x1c0
[   81.031745] raw F2FS-fs (loop0) : inject kmalloc in f2fs_kmalloc of f2fs_fill_super+0x7eb/0x1710
mount: mounting /dev/loop0 on /mnt/f2fs failed: Cannot allocate memory

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 4035dab1f570..f15001b5d73b 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1876,11 +1876,13 @@ struct f2fs_sb_info {

 #ifdef CONFIG_F2FS_FAULT_INJECTION
 #define f2fs_show_injection_info(sbi, type)                                    \
-       printk_ratelimited("%sF2FS-fs (%s) : inject %s in %s of %pS\n", \
+       printk_ratelimited("%sraw F2FS-fs (%s) : inject %s in %s of %pS\n",     \
                KERN_INFO, sbi->sb->s_id,                               \
                f2fs_fault_name[type],                                  \
                __func__, __builtin_return_address(0))
-static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
+
+#define time_to_inject(sbi, type) __time_to_inject(sbi, type, __func__)
+static bool __time_to_inject(struct f2fs_sb_info *sbi, int type, const char *func_name)
 {
        struct f2fs_fault_info *ffi = &F2FS_OPTION(sbi).fault_info;

@@ -1893,6 +1895,10 @@ static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
        atomic_inc(&ffi->inject_ops);
        if (atomic_read(&ffi->inject_ops) >= ffi->inject_rate) {
                atomic_set(&ffi->inject_ops, 0);
+               printk_ratelimited("%s new F2FS-fs (%s) : inject %s in %s of %pS\n",
+                       KERN_INFO, sbi->sb->s_id,
+                       f2fs_fault_name[type],
+                       func_name, __builtin_return_address(0));
                return true;
        }
        return false;

Thx,
Yangtao

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ