relay: check return of create_buf_file() properly
commit167a0989ec15a0b738dc8fd25922b1fae00c0dba
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 31 Jan 2019 12:57:58 +0000 (31 13:57 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Mar 2019 21:03:20 +0000 (13 14:03 -0700)
treef264e4926d9d60cae38683b85829d3e70fcab521
parent8939e8cdd004ba5d7dd3bbf9c105990f9ebe96f8
relay: check return of create_buf_file() properly

[ Upstream commit 2c1cf00eeacb784781cf1c9896b8af001246d339 ]

If create_buf_file() returns an error, don't try to reference it later
as a valid dentry pointer.

This problem was exposed when debugfs started to return errors instead
of just NULL for some calls when they do not succeed properly.

Also, the check for WARN_ON(dentry) was just wrong :)

Reported-by: Kees Cook <keescook@chromium.org>
Reported-and-tested-by: syzbot+16c3a70e1e9b29346c43@syzkaller.appspotmail.com
Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Rientjes <rientjes@google.com>
Fixes: ff9fb72bc077 ("debugfs: return error values, not NULL")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/relay.c