From mboxrd@z Thu Jan 1 00:00:00 1970 From: Greg KH Subject: [PATCH] sysfs: turn WARN() into pr_warn() Date: Mon, 22 Jan 2018 15:57:59 +0100 Message-ID: <20180122145759.GA18798@kroah.com> References: <001a11c14bc837f9760560a03d51@google.com> <20171219090121.GA10221@kroah.com> <20180122140015.GA30036@kroah.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: syzbot , LKML , syzkaller-bugs@googlegroups.com, David Miller , Daniel Borkmann , Eric Dumazet , jakub.kicinski@netronome.com, Willem de Bruijn , Rasmus Villemoes , John Fastabend , "Tobin C. Harding" , netdev , linux-wireless@vger.kernel.org To: Dmitry Vyukov Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org From: Greg Kroah-Hartman It's not good to crash the machine if panic_on_warn() is set just because someone made a stupid mistake of trying to create a sysfs file with the same name of an existing one. This makes the automated testing tools a lot harder to find the real bugs in the kernel. So just print a warning out and dump the stack to get the attention of the developer that they did something foolish. Then keep on trucking, as this should not be a fatal error at all. Reported-by: Dmitry Vyukov Signed-off-by: Greg Kroah-Hartman --- Dmitry, does this look good to you? If so, I'll queue it up for 4.16-rc1. diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 2b67bda2021b..3a36a48a4b3f 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c @@ -10,6 +10,7 @@ * Please see Documentation/filesystems/sysfs.txt for more information. */ +#define pr_fmt(fmt) "sysfs: " fmt #undef DEBUG #include @@ -27,8 +28,8 @@ void sysfs_warn_dup(struct kernfs_node *parent, const char *name) if (buf) kernfs_path(parent, buf, PATH_MAX); - WARN(1, KERN_WARNING "sysfs: cannot create duplicate filename '%s/%s'\n", - buf, name); + pr_warn("cannot create duplicate filename '%s/%s'\n", buf, name); + dump_stack(); kfree(buf); }