From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752754AbeDEBZz (ORCPT ); Wed, 4 Apr 2018 21:25:55 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:48790 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752583AbeDEBZx (ORCPT ); Wed, 4 Apr 2018 21:25:53 -0400 To: LKML , reiserfs-devel@vger.kernel.org From: Randy Dunlap Subject: [PATCH?] reiserfs: prevent panic: don't allow %-char in journal dev. name Cc: Alexander Viro , Jeff Mahoney , Jan Kara , Frederic Weisbecker , Artem Bityutskiy , Andrew Morton , syzkaller-bugs@googlegroups.com, syzbot+6bd77b88c1977c03f584@syzkaller.appspotmail.com Message-ID: Date: Wed, 4 Apr 2018 18:25:16 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Randy Dunlap 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 Cc: stable@vger.kernel.org # many kernel versions Cc: reiserfs-devel@vger.kernel.org Cc: Alexander Viro Cc: Jeff Mahoney Cc: Jan Kara Cc: Frederic Weisbecker Cc: Artem Bityutskiy Cc: Andrew Morton --- 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; } }