All of lore.kernel.org
 help / color / mirror / Atom feed
* reiserfs: inconsistent format in __RASSERT
@ 2015-03-16 12:55 Nicolas Iooss
  2015-03-16 13:05 ` Jeff Mahoney
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Iooss @ 2015-03-16 12:55 UTC (permalink / raw)
  To: reiserfs-devel, Jeff Mahoney; +Cc: linux-kernel

Hello,

When adding a __printf attribute to reiserfs_panic, gcc reported an
inconsistent format for __RASSERT.  This macro is currently defined in
fs/reiserfs/reiserfs.h as:

    reiserfs_panic(NULL, "assertion failure", "(" #cond ") at " \
        __FILE__ ":%i:%s: " format "\n",                        \
        in_interrupt() ? -1 : task_pid_nr(current),             \
        __LINE__, __func__ , ##args);

In the format string, the first parameter is a line number, but in the
arguments there is a PID before.  Before c3a9c2109f84 ("reiserfs: rework
reiserfs_panic") [1], the format string began with "reiserfs[%i]" [2],
which explains the PID in the arguments.

I see three possibilities:

* I missed something in my analysis and in fact the PID argument is
processed by reiserfs_panic (don't know where), or
* the PID argument is not used and should be removed, or
* the PID is useful and "[%i]" should be added somewhere in the format
string.

Which one would you prefer?

Also, I found this when building the kernel with "allmodconfig" on
x86_64.  With "defconfig" gcc does not report this error, but I guess it
is because without CONFIG_REISERFS_CHECK, __RASSERT is never used.

Regards,

Nicolas


[1]
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=c3a9c2109f84882b9b3178f6b1838d550d3df0ec
[2]
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/reiserfs_fs.h?id=78b6513d2881f1a759fb9825a036d926392de084#n91

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: reiserfs: inconsistent format in __RASSERT
  2015-03-16 12:55 reiserfs: inconsistent format in __RASSERT Nicolas Iooss
@ 2015-03-16 13:05 ` Jeff Mahoney
  2015-03-16 13:18   ` Nicolas Iooss
  0 siblings, 1 reply; 6+ messages in thread
From: Jeff Mahoney @ 2015-03-16 13:05 UTC (permalink / raw)
  To: Nicolas Iooss, reiserfs-devel; +Cc: linux-kernel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 3/16/15 8:55 AM, Nicolas Iooss wrote:
> Hello,
> 
> When adding a __printf attribute to reiserfs_panic, gcc reported
> an inconsistent format for __RASSERT.  This macro is currently
> defined in fs/reiserfs/reiserfs.h as:
> 
> reiserfs_panic(NULL, "assertion failure", "(" #cond ") at " \ 
> __FILE__ ":%i:%s: " format "\n",                        \ 
> in_interrupt() ? -1 : task_pid_nr(current),             \ __LINE__,
> __func__ , ##args);
> 
> In the format string, the first parameter is a line number, but in
> the arguments there is a PID before.  Before c3a9c2109f84
> ("reiserfs: rework reiserfs_panic") [1], the format string began
> with "reiserfs[%i]" [2], which explains the PID in the arguments.
> 
> I see three possibilities:
> 
> * I missed something in my analysis and in fact the PID argument
> is processed by reiserfs_panic (don't know where), or * the PID
> argument is not used and should be removed, or

This, please. reiserfs_panic calls BUG(), which will contain the PID.

> * the PID is useful and "[%i]" should be added somewhere in the
> format string.
> 
> Which one would you prefer?
> 
> Also, I found this when building the kernel with "allmodconfig" on 
> x86_64.  With "defconfig" gcc does not report this error, but I
> guess it is because without CONFIG_REISERFS_CHECK, __RASSERT is
> never used.

Yeah. If reiserfs was more actively maintained, what is currently
protected by CONFIG_REISERFS_CHECK would be handled a bit better.
There are ton of fsfuzzer bugs that would be caught by it and should
be handled using reiserfs_error. Unfortunately, it also enables some
heavy checks that make the file system very slow.

Thanks for looking into this. It looks like it's been broken for a
while. I suppose the only saving grace is that it would crash in a
path that crashes on purpose a few lines later.

- -Jeff

- -- 
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.19 (Darwin)

iQIcBAEBAgAGBQJVBtUEAAoJEB57S2MheeWysH4P/RBggjHOwREYHiq2RaY8H+sf
rSRaqf14xePP7vcWOvcQRkzjB2f6wnvD40i7j0vLqP5A6mjp+tdrSgl7P1KqGGBV
45oQuibM5LcrDA07cIgXYLVYZxiWCtOyDxjSfoNw4HsrP/gPIx5YevJseb/VZPON
AH1ywT8LSmKx25jz20f6mmfbSuqtHe+ceitVcyjRnTw6363ngSPKj48rpPpo9uQE
SJygrJy1kkEVw0P9EHSa03jSKggPIpEj40lV5L7BDKkEsqor+3jXZDHaM7qQq+N0
eYaYzIxBbWuf8jAHe/XDGDNo0TEjvFk6qgmdUKjn41j+mS4SbUZGk55QFJO32ecv
GK9a/leQ/YyfPS9HBsuk6g51O1RU34nSyMY/i6o//VncgIJqIaxiWMb0KR5f79uL
LWv/A4TDsFC0/o/O25FFFq2jte5i497aFzxpTI+KDRmzxBUM20QzkhwPz2tySace
X0KBsJoLdgXLZhHYSlm2iydCb4C0lt6M3Q42IUlCeB3DQSViFgHnLry0ALULMcOk
N061Pnv+BoM+yEScF5TEF+/S4QgtgqdxNsUzZTF/070rVgtbR0iimikkf2w2ejWM
nYHsrFXJBZ55PtLKrV2ujVg3e25DlHK2irrawWmUF+/9zA/CV08u73XnB+VjAnTm
8Y0B/t6I90I3urltJbYA
=Pcpd
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: reiserfs: inconsistent format in __RASSERT
  2015-03-16 13:05 ` Jeff Mahoney
@ 2015-03-16 13:18   ` Nicolas Iooss
  2015-03-16 13:45     ` [PATCH] reiserfs: fix __RASSERT format string Nicolas Iooss
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Iooss @ 2015-03-16 13:18 UTC (permalink / raw)
  To: Jeff Mahoney, reiserfs-devel; +Cc: linux-kernel

On 03/16/2015 09:05 PM, Jeff Mahoney wrote:
> On 3/16/15 8:55 AM, Nicolas Iooss wrote:
>> * I missed something in my analysis and in fact the PID argument
>> is processed by reiserfs_panic (don't know where), or * the PID
>> argument is not used and should be removed, or
> 
> This, please. reiserfs_panic calls BUG(), which will contain the PID.

Whoo, thanks for the quick answer.  I will send a patch as soon as possible.

>> * the PID is useful and "[%i]" should be added somewhere in the
>> format string.
> 
>> Which one would you prefer?
> 
>> Also, I found this when building the kernel with "allmodconfig" on 
>> x86_64.  With "defconfig" gcc does not report this error, but I
>> guess it is because without CONFIG_REISERFS_CHECK, __RASSERT is
>> never used.
> 
> Yeah. If reiserfs was more actively maintained, what is currently
> protected by CONFIG_REISERFS_CHECK would be handled a bit better.
> There are ton of fsfuzzer bugs that would be caught by it and should
> be handled using reiserfs_error. Unfortunately, it also enables some
> heavy checks that make the file system very slow.
> 
> Thanks for looking into this. It looks like it's been broken for a
> while. I suppose the only saving grace is that it would crash in a
> path that crashes on purpose a few lines later.

Yes, and this is also why I believe this bug is not a security issue nor
something which needs an urgent fix.

Thanks,

Nicolas

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] reiserfs: fix __RASSERT format string
  2015-03-16 13:18   ` Nicolas Iooss
@ 2015-03-16 13:45     ` Nicolas Iooss
  2015-03-17 14:26       ` Jeff Mahoney
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Iooss @ 2015-03-16 13:45 UTC (permalink / raw)
  To: jeffm; +Cc: reiserfs-devel, linux-kernel, Nicolas Iooss

__RASSERT format string does not use the PID argument.  reiserfs_panic
arguments are therefore formatted with the wrong format specifier (for
example __LINE__ with %s).  This bug was introduced when commit
c3a9c2109f84 ("reiserfs: rework reiserfs_panic") removed a
"reiserfs[%i]" prefix.

This bug is only triggered when using CONFIG_REISERFS_CHECK, otherwise
__RASSERT is never used.

Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Fixes: c3a9c2109f84 ("reiserfs: rework reiserfs_panic")
---
 fs/reiserfs/reiserfs.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
index bb79cddf0a1f..2adcde137c3f 100644
--- a/fs/reiserfs/reiserfs.h
+++ b/fs/reiserfs/reiserfs.h
@@ -910,7 +910,6 @@ do {									\
 	if (!(cond))							\
 		reiserfs_panic(NULL, "assertion failure", "(" #cond ") at " \
 			       __FILE__ ":%i:%s: " format "\n",		\
-			       in_interrupt() ? -1 : task_pid_nr(current), \
 			       __LINE__, __func__ , ##args);		\
 } while (0)
 
-- 
2.3.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] reiserfs: fix __RASSERT format string
  2015-03-16 13:45     ` [PATCH] reiserfs: fix __RASSERT format string Nicolas Iooss
@ 2015-03-17 14:26       ` Jeff Mahoney
  2015-03-17 15:22         ` Jan Kara
  0 siblings, 1 reply; 6+ messages in thread
From: Jeff Mahoney @ 2015-03-17 14:26 UTC (permalink / raw)
  To: Nicolas Iooss; +Cc: reiserfs-devel, linux-kernel, Jan Kara

On 3/16/15 9:45 AM, Nicolas Iooss wrote:
> __RASSERT format string does not use the PID argument.
> reiserfs_panic arguments are therefore formatted with the wrong
> format specifier (for example __LINE__ with %s).  This bug was
> introduced when commit c3a9c2109f84 ("reiserfs: rework
> reiserfs_panic") removed a "reiserfs[%i]" prefix.
> 
> This bug is only triggered when using CONFIG_REISERFS_CHECK,
> otherwise __RASSERT is never used.
> 
> Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Acked-by: Jeff Mahoney <jeffm@suse.com>

> Fixes: c3a9c2109f84 ("reiserfs: rework reiserfs_panic") --- 
> fs/reiserfs/reiserfs.h | 1 - 1 file changed, 1 deletion(-)
> 
> diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h index
> bb79cddf0a1f..2adcde137c3f 100644 --- a/fs/reiserfs/reiserfs.h +++
> b/fs/reiserfs/reiserfs.h @@ -910,7 +910,6 @@ do {									\ if
> (!(cond))							\ reiserfs_panic(NULL, "assertion failure", "("
> #cond ") at " \ __FILE__ ":%i:%s: " format "\n",		\ -
> in_interrupt() ? -1 : task_pid_nr(current), \ __LINE__, __func__ ,
> ##args);		\ } while (0)
> 
> 


-- 
Jeff Mahoney
SUSE Labs


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] reiserfs: fix __RASSERT format string
  2015-03-17 14:26       ` Jeff Mahoney
@ 2015-03-17 15:22         ` Jan Kara
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Kara @ 2015-03-17 15:22 UTC (permalink / raw)
  To: Jeff Mahoney; +Cc: Nicolas Iooss, reiserfs-devel, linux-kernel, Jan Kara

On Tue 17-03-15 10:26:44, Jeff Mahoney wrote:
> On 3/16/15 9:45 AM, Nicolas Iooss wrote:
> > __RASSERT format string does not use the PID argument.
> > reiserfs_panic arguments are therefore formatted with the wrong
> > format specifier (for example __LINE__ with %s).  This bug was
> > introduced when commit c3a9c2109f84 ("reiserfs: rework
> > reiserfs_panic") removed a "reiserfs[%i]" prefix.
> > 
> > This bug is only triggered when using CONFIG_REISERFS_CHECK,
> > otherwise __RASSERT is never used.
> > 
> > Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
> Acked-by: Jeff Mahoney <jeffm@suse.com>
  Thanks. I've added the patch to my tree.

							Honza

> 
> > Fixes: c3a9c2109f84 ("reiserfs: rework reiserfs_panic") --- 
> > fs/reiserfs/reiserfs.h | 1 - 1 file changed, 1 deletion(-)
> > 
> > diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h index
> > bb79cddf0a1f..2adcde137c3f 100644 --- a/fs/reiserfs/reiserfs.h +++
> > b/fs/reiserfs/reiserfs.h @@ -910,7 +910,6 @@ do {									\ if
> > (!(cond))							\ reiserfs_panic(NULL, "assertion failure", "("
> > #cond ") at " \ __FILE__ ":%i:%s: " format "\n",		\ -
> > in_interrupt() ? -1 : task_pid_nr(current), \ __LINE__, __func__ ,
> > ##args);		\ } while (0)
> > 
> > 
> 
> 
> -- 
> Jeff Mahoney
> SUSE Labs
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-03-17 15:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-16 12:55 reiserfs: inconsistent format in __RASSERT Nicolas Iooss
2015-03-16 13:05 ` Jeff Mahoney
2015-03-16 13:18   ` Nicolas Iooss
2015-03-16 13:45     ` [PATCH] reiserfs: fix __RASSERT format string Nicolas Iooss
2015-03-17 14:26       ` Jeff Mahoney
2015-03-17 15:22         ` Jan Kara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.