]> git.baikalelectronics.ru Git - kernel.git/commit
seccomp: don't leave dangling ->notif if file allocation fails
authorTycho Andersen <tycho@tycho.pizza>
Wed, 2 Sep 2020 14:09:53 +0000 (08:09 -0600)
committerKees Cook <keescook@chromium.org>
Tue, 8 Sep 2020 18:30:16 +0000 (11:30 -0700)
commit8a5609105caef2cdbe39e6c5da324a34e3324770
tree2b62afa93e55a872f5fa56e6f36bbd48a8b080e7
parent6bfeeb7022b1f71e845b2225808f13893f751eeb
seccomp: don't leave dangling ->notif if file allocation fails

Christian and Kees both pointed out that this is a bit sloppy to open-code
both places, and Christian points out that we leave a dangling pointer to
->notif if file allocation fails. Since we check ->notif for null in order
to determine if it's ok to install a filter, this means people won't be
able to install a filter if the file allocation fails for some reason, even
if they subsequently should be able to.

To fix this, let's hoist this free+null into its own little helper and use
it.

Reported-by: Kees Cook <keescook@chromium.org>
Reported-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Link: https://lore.kernel.org/r/20200902140953.1201956-1-tycho@tycho.pizza
Signed-off-by: Kees Cook <keescook@chromium.org>
kernel/seccomp.c