linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: remove static from struct match_token used in token2str
@ 2012-09-22  1:21 Herton Ronaldo Krzesinski
  2012-09-24  2:59 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Herton Ronaldo Krzesinski @ 2012-09-22  1:21 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: Andreas Dilger, linux-ext4, linux-kernel

There is no reason to use static there, and it will cause issues when
reading /proc/fs/ext4/<partition>/options concurrently.

Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
Cc: stable@vger.kernel.org # 3.4+
---
 fs/ext4/super.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

The problem is easy to reproduce, for example running:
$ cat /proc/fs/ext4/<partition>/options > options.txt
$ while diff /proc/fs/ext4/<partition>/options options.txt; do true; done
- And concurrently on another terminal:
$ while diff /proc/fs/ext4/<partition>/options options.txt; do true; done

One of the diff loops will get incomplete options contents because of
the issue, and exit.

I also believe the same problem is the cause of the following bug:
https://bugs.launchpad.net/bugs/1053019, that happened while running
test 234 from xfstests.

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 41598ee..975405c 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1748,7 +1748,7 @@ static inline void ext4_show_quota_options(struct seq_file *seq,
 
 static const char *token2str(int token)
 {
-	static const struct match_token *t;
+	const struct match_token *t;
 
 	for (t = tokens; t->token != Opt_err; t++)
 		if (t->token == token && !strchr(t->pattern, '='))
-- 
1.7.9.5


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

* Re: [PATCH] ext4: remove static from struct match_token used in token2str
  2012-09-22  1:21 [PATCH] ext4: remove static from struct match_token used in token2str Herton Ronaldo Krzesinski
@ 2012-09-24  2:59 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2012-09-24  2:59 UTC (permalink / raw)
  To: Herton Ronaldo Krzesinski; +Cc: Andreas Dilger, linux-ext4, linux-kernel

On Fri, Sep 21, 2012 at 10:21:00PM -0300, Herton Ronaldo Krzesinski wrote:
> There is no reason to use static there, and it will cause issues when
> reading /proc/fs/ext4/<partition>/options concurrently.
> 
> Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
> Cc: stable@vger.kernel.org # 3.4+

Herton,

Thanks for finding the bug fix!  I changed the commit descipription
slightly and have applied your patch to the ext4 tree.

	     	  	       	     	    - Ted

ext4: fix crash when accessing /proc/mounts concurrently

From: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>

The crash was caused by a variable being erronously declared static in
token2str().

In addition to /proc/mounts, the problem can also be easily replicated
by accessing /proc/fs/ext4/<partition>/options in parallel:

$ cat /proc/fs/ext4/<partition>/options > options.txt

... and then running the following command in two different terminals:

$ while diff /proc/fs/ext4/<partition>/options options.txt; do true; done

This is also the cause of the following a crash while running xfstests
#234, as reported in the following bug reports:

	https://bugs.launchpad.net/bugs/1053019
	https://bugzilla.kernel.org/show_bug.cgi?id=47731

Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Brad Figg <brad.figg@canonical.com>
Cc: stable@vger.kernel.org

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

end of thread, other threads:[~2012-09-24  2:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-22  1:21 [PATCH] ext4: remove static from struct match_token used in token2str Herton Ronaldo Krzesinski
2012-09-24  2:59 ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).