Skip to content

Commit ef2e9a5

Browse files
committed
Merge tag 'seccomp-v5.9-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull seccomp fixes from Kees Cook: "This fixes a rare race condition in seccomp when using TSYNC and USER_NOTIF together where a memory allocation would not get freed (found by syzkaller, fixed by Tycho). Additionally updates Tycho's MAINTAINERS and .mailmap entries for his new address" * tag 'seccomp-v5.9-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: seccomp: don't leave dangling ->notif if file allocation fails mailmap, MAINTAINERS: move to tycho.pizza seccomp: don't leak memory when filter install races
2 parents 4f8b0a5 + e839317 commit ef2e9a5

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ Tony Luck <tony.luck@intel.com>
308308
TripleX Chung <xxx.phy@gmail.com> <triplex@zh-kernel.org>
309309
TripleX Chung <xxx.phy@gmail.com> <zhongyu@18mail.cn>
310310
Tsuneo Yoshioka <Tsuneo.Yoshioka@f-secure.com>
311+
Tycho Andersen <tycho@tycho.pizza> <tycho@tycho.ws>
311312
Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
312313
Uwe Kleine-König <ukl@pengutronix.de>
313314
Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9800,7 +9800,7 @@ F: drivers/scsi/53c700*
98009800

98019801
LEAKING_ADDRESSES
98029802
M: Tobin C. Harding <me@tobin.cc>
9803-
M: Tycho Andersen <tycho@tycho.ws>
9803+
M: Tycho Andersen <tycho@tycho.pizza>
98049804
L: kernel-hardening@lists.openwall.com
98059805
S: Maintained
98069806
T: git git://git.kernel.org/pub/scm/linux/kernel/git/tobin/leaks.git

kernel/seccomp.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,13 +1109,18 @@ static long seccomp_set_mode_strict(void)
11091109
}
11101110

11111111
#ifdef CONFIG_SECCOMP_FILTER
1112-
static int seccomp_notify_release(struct inode *inode, struct file *file)
1112+
static void seccomp_notify_free(struct seccomp_filter *filter)
1113+
{
1114+
kfree(filter->notif);
1115+
filter->notif = NULL;
1116+
}
1117+
1118+
static void seccomp_notify_detach(struct seccomp_filter *filter)
11131119
{
1114-
struct seccomp_filter *filter = file->private_data;
11151120
struct seccomp_knotif *knotif;
11161121

11171122
if (!filter)
1118-
return 0;
1123+
return;
11191124

11201125
mutex_lock(&filter->notify_lock);
11211126

@@ -1139,9 +1144,15 @@ static int seccomp_notify_release(struct inode *inode, struct file *file)
11391144
complete(&knotif->ready);
11401145
}
11411146

1142-
kfree(filter->notif);
1143-
filter->notif = NULL;
1147+
seccomp_notify_free(filter);
11441148
mutex_unlock(&filter->notify_lock);
1149+
}
1150+
1151+
static int seccomp_notify_release(struct inode *inode, struct file *file)
1152+
{
1153+
struct seccomp_filter *filter = file->private_data;
1154+
1155+
seccomp_notify_detach(filter);
11451156
__put_seccomp_filter(filter);
11461157
return 0;
11471158
}
@@ -1488,7 +1499,7 @@ static struct file *init_listener(struct seccomp_filter *filter)
14881499

14891500
out_notif:
14901501
if (IS_ERR(ret))
1491-
kfree(filter->notif);
1502+
seccomp_notify_free(filter);
14921503
out:
14931504
return ret;
14941505
}
@@ -1581,6 +1592,7 @@ static long seccomp_set_mode_filter(unsigned int flags,
15811592
listener_f->private_data = NULL;
15821593
fput(listener_f);
15831594
put_unused_fd(listener);
1595+
seccomp_notify_detach(prepared);
15841596
} else {
15851597
fd_install(listener, listener_f);
15861598
ret = listener;

0 commit comments

Comments
 (0)