Skip to content

Commit 92cf7a5

Browse files
matttbekuba-moo
authored andcommitted
mptcp: sysctl: blackhole timeout: avoid using current->nsproxy
As mentioned in the previous commit, using the 'net' structure via 'current' is not recommended for different reasons: - Inconsistency: getting info from the reader's/writer's netns vs only from the opener's netns. - current->nsproxy can be NULL in some cases, resulting in an 'Oops' (null-ptr-deref), e.g. when the current task is exiting, as spotted by syzbot [1] using acct(2). The 'pernet' structure can be obtained from the table->data using container_of(). Fixes: 27069e7 ("mptcp: disable active MPTCP in case of blackhole") Cc: [email protected] Link: https://lore.kernel.org/[email protected] [1] Suggested-by: Al Viro <[email protected]> Reviewed-by: Mat Martineau <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d38e26e commit 92cf7a5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/mptcp/ctrl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ static int proc_blackhole_detect_timeout(const struct ctl_table *table,
160160
int write, void *buffer, size_t *lenp,
161161
loff_t *ppos)
162162
{
163-
struct mptcp_pernet *pernet = mptcp_get_pernet(current->nsproxy->net_ns);
163+
struct mptcp_pernet *pernet = container_of(table->data,
164+
struct mptcp_pernet,
165+
blackhole_timeout);
164166
int ret;
165167

166168
ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);

0 commit comments

Comments
 (0)