Skip to content

Commit c10377b

Browse files
matttbekuba-moo
authored andcommitted
sctp: sysctl: udp_port: 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, but that would increase the size of this fix, while 'sctp.ctl_sock' still needs to be retrieved from 'net' structure. Fixes: 046c052 ("sctp: enable udp tunneling socks") 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 15649fd commit c10377b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/sctp/sysctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ static int proc_sctp_do_auth(const struct ctl_table *ctl, int write,
528528
static int proc_sctp_do_udp_port(const struct ctl_table *ctl, int write,
529529
void *buffer, size_t *lenp, loff_t *ppos)
530530
{
531-
struct net *net = current->nsproxy->net_ns;
531+
struct net *net = container_of(ctl->data, struct net, sctp.udp_port);
532532
unsigned int min = *(unsigned int *)ctl->extra1;
533533
unsigned int max = *(unsigned int *)ctl->extra2;
534534
struct ctl_table tbl;

0 commit comments

Comments
 (0)