Skip to content

Commit 2c1cf00

Browse files
committed
relay: check return of create_buf_file() properly
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: ff9fb72 ("debugfs: return error values, not NULL") Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 37ea7b6 commit 2c1cf00

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kernel/relay.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ static struct dentry *relay_create_buf_file(struct rchan *chan,
428428
dentry = chan->cb->create_buf_file(tmpname, chan->parent,
429429
S_IRUSR, buf,
430430
&chan->is_global);
431+
if (IS_ERR(dentry))
432+
dentry = NULL;
431433

432434
kfree(tmpname);
433435

@@ -461,7 +463,7 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu)
461463
dentry = chan->cb->create_buf_file(NULL, NULL,
462464
S_IRUSR, buf,
463465
&chan->is_global);
464-
if (WARN_ON(dentry))
466+
if (IS_ERR_OR_NULL(dentry))
465467
goto free_buf;
466468
}
467469

0 commit comments

Comments
 (0)