Skip to content

Commit 6259d24

Browse files
matttbekuba-moo
authored andcommitted
sctp: sysctl: plpmtud_probe_interval: avoid using current->nsproxy
As mentioned in a previous commit of this series, 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 'net' structure can be obtained from the table->data using container_of(). Note that table->data could also be used directly, as this is the only member needed from the 'net' structure, but that would increase the size of this fix, to use '*data' everywhere 'net->sctp.probe_interval' is used. Fixes: d1e462a ("sctp: add probe_interval in sysctl and sock/asoc/transport") Cc: [email protected] Link: https://lore.kernel.org/[email protected] [1] Suggested-by: Al Viro <[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 c10377b commit 6259d24

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/sctp/sysctl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,8 @@ static int proc_sctp_do_udp_port(const struct ctl_table *ctl, int write,
569569
static int proc_sctp_do_probe_interval(const struct ctl_table *ctl, int write,
570570
void *buffer, size_t *lenp, loff_t *ppos)
571571
{
572-
struct net *net = current->nsproxy->net_ns;
572+
struct net *net = container_of(ctl->data, struct net,
573+
sctp.probe_interval);
573574
struct ctl_table tbl;
574575
int ret, new_value;
575576

0 commit comments

Comments
 (0)