All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH?] reiserfs: prevent panic: don't allow %-char in journal dev. name
@ 2018-04-05  1:25 Randy Dunlap
  2018-04-05  1:45 ` Andrew Morton
  0 siblings, 1 reply; 11+ messages in thread
From: Randy Dunlap @ 2018-04-05  1:25 UTC (permalink / raw)
  To: LKML, reiserfs-devel
  Cc: Alexander Viro, Jeff Mahoney, Jan Kara, Frederic Weisbecker,
	Artem Bityutskiy, Andrew Morton, syzkaller-bugs,
	syzbot+6bd77b88c1977c03f584

From: Randy Dunlap <rdunlap@infradead.org>

If the reiserfs mount option's journal name contains a '%' character,
it can lead to a WARN_ONCE() in lib/vsprintf.c::format_decode(),
saying: "Please remove unsupported %/ in format string."
That's OK until panic_on_warn is set, at which point it's dead, Jim.

To placate this situation, check the journal name string for a '%'
character and return an error if one is found. Also print a warning
(one that won't panic the kernel) about the invalid journal name (e.g.):

  reiserfs: journal device name is invalid: %/file0

(In this example, the caller app specified the journal device name as
"%/file0".)

Fixes: https://syzkaller.appspot.com/bug?id=0627d4551fdc39bf1ef5d82cd9eef587047f7718

Reported-by: syzbot+6bd77b88c1977c03f584@syzkaller.appspotmail.com
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: stable@vger.kernel.org # many kernel versions
Cc: reiserfs-devel@vger.kernel.org
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Jeff Mahoney <jeffm@suse.com>
Cc: Jan Kara <jack@suse.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: Andrew Morton <akpm@linuxfoundation.org>
---
 fs/reiserfs/super.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

--- lnx-416.orig/fs/reiserfs/super.c
+++ lnx-416/fs/reiserfs/super.c
@@ -1239,6 +1239,8 @@ static int reiserfs_parse_options(struct
 		}
 
 		if (c == 'j') {
+			char *badfmt;	// jdev_name (arg) cannot contain '%'
+
 			if (arg && *arg && jdev_name) {
 				/* Hm, already assigned? */
 				if (*jdev_name) {
@@ -1248,6 +1250,15 @@ static int reiserfs_parse_options(struct
 							 "be %s", *jdev_name);
 					return 0;
 				}
+
+				badfmt = strchr(arg, '%');
+				if (badfmt) {
+					printk(KERN_WARNING "reiserfs: "
+						 "journal device name "
+						 "is invalid: %s",
+						 arg);
+					return 0;
+				}
 				*jdev_name = arg;
 			}
 		}

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

end of thread, other threads:[~2018-04-09 14:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-05  1:25 [PATCH?] reiserfs: prevent panic: don't allow %-char in journal dev. name Randy Dunlap
2018-04-05  1:45 ` Andrew Morton
2018-04-05  1:48   ` Jeff Mahoney
2018-04-05  2:05     ` Randy Dunlap
2018-04-09 14:25     ` Jan Kara
2018-04-09 14:25       ` Jan Kara
2018-04-09 14:30       ` Dmitry Vyukov
2018-04-09 14:34       ` Jan Kara
2018-04-05  9:04   ` Rasmus Villemoes
2018-04-06 13:45     ` Rasmus Villemoes
2018-04-06 16:55     ` Jeff Mahoney

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.