tomoyo: Don't use nifty names on sockets.
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Mon, 25 Nov 2019 01:46:51 +0000 (10:46 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 4 Jan 2020 18:18:42 +0000 (19:18 +0100)
commit9c24cc6a9d9570d1312af1b379ab1764face8cd8
treee6bb48c4377dee03e694d58af2ae26b2b8b07729
parent2cd7c5f23ff1b2ce5d15720334861cb902519e8b
tomoyo: Don't use nifty names on sockets.

commit 6f7c41374b62fd80bbd8aae3536c43688c54d95e upstream.

syzbot is reporting that use of SOCKET_I()->sk from open() can result in
use after free problem [1], for socket's inode is still reachable via
/proc/pid/fd/n despite destruction of SOCKET_I()->sk already completed.

At first I thought that this race condition applies to only open/getattr
permission checks. But James Morris has pointed out that there are more
permission checks where this race condition applies to. Thus, get rid of
tomoyo_get_socket_name() instead of conditionally bypassing permission
checks on sockets. As a side effect of this patch,
"socket:[family=\$:type=\$:protocol=\$]" in the policy files has to be
rewritten to "socket:[\$]".

[1] https://syzkaller.appspot.com/bug?id=73d590010454403d55164cca23bd0565b1eb3b74

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reported-by: syzbot <syzbot+0341f6a4d729d4e0acf1@syzkaller.appspotmail.com>
Reported-by: James Morris <jmorris@namei.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
security/tomoyo/realpath.c