@@ -391,7 +391,8 @@ static struct ctl_table sctp_net_table[] = {
391391static int proc_sctp_do_hmac_alg (struct ctl_table * ctl , int write ,
392392 void * buffer , size_t * lenp , loff_t * ppos )
393393{
394- struct net * net = current -> nsproxy -> net_ns ;
394+ struct net * net = container_of (ctl -> data , struct net ,
395+ sctp .sctp_hmac_alg );
395396 struct ctl_table tbl ;
396397 bool changed = false;
397398 char * none = "none" ;
@@ -436,7 +437,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write,
436437static int proc_sctp_do_rto_min (struct ctl_table * ctl , int write ,
437438 void * buffer , size_t * lenp , loff_t * ppos )
438439{
439- struct net * net = current -> nsproxy -> net_ns ;
440+ struct net * net = container_of ( ctl -> data , struct net , sctp . rto_min ) ;
440441 unsigned int min = * (unsigned int * ) ctl -> extra1 ;
441442 unsigned int max = * (unsigned int * ) ctl -> extra2 ;
442443 struct ctl_table tbl ;
@@ -464,7 +465,7 @@ static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
464465static int proc_sctp_do_rto_max (struct ctl_table * ctl , int write ,
465466 void * buffer , size_t * lenp , loff_t * ppos )
466467{
467- struct net * net = current -> nsproxy -> net_ns ;
468+ struct net * net = container_of ( ctl -> data , struct net , sctp . rto_max ) ;
468469 unsigned int min = * (unsigned int * ) ctl -> extra1 ;
469470 unsigned int max = * (unsigned int * ) ctl -> extra2 ;
470471 struct ctl_table tbl ;
@@ -502,7 +503,7 @@ static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write,
502503static int proc_sctp_do_auth (struct ctl_table * ctl , int write ,
503504 void * buffer , size_t * lenp , loff_t * ppos )
504505{
505- struct net * net = current -> nsproxy -> net_ns ;
506+ struct net * net = container_of ( ctl -> data , struct net , sctp . auth_enable ) ;
506507 struct ctl_table tbl ;
507508 int new_value , ret ;
508509
@@ -528,10 +529,12 @@ static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
528529 return ret ;
529530}
530531
532+ static DEFINE_MUTEX (sctp_sysctl_mutex );
533+
531534static int proc_sctp_do_udp_port (struct ctl_table * ctl , int write ,
532535 void * buffer , size_t * lenp , loff_t * ppos )
533536{
534- struct net * net = current -> nsproxy -> net_ns ;
537+ struct net * net = container_of ( ctl -> data , struct net , sctp . udp_port ) ;
535538 unsigned int min = * (unsigned int * )ctl -> extra1 ;
536539 unsigned int max = * (unsigned int * )ctl -> extra2 ;
537540 struct ctl_table tbl ;
@@ -552,6 +555,7 @@ static int proc_sctp_do_udp_port(struct ctl_table *ctl, int write,
552555 if (new_value > max || new_value < min )
553556 return - EINVAL ;
554557
558+ mutex_lock (& sctp_sysctl_mutex );
555559 net -> sctp .udp_port = new_value ;
556560 sctp_udp_sock_stop (net );
557561 if (new_value ) {
@@ -564,6 +568,7 @@ static int proc_sctp_do_udp_port(struct ctl_table *ctl, int write,
564568 lock_sock (sk );
565569 sctp_sk (sk )-> udp_port = htons (net -> sctp .udp_port );
566570 release_sock (sk );
571+ mutex_unlock (& sctp_sysctl_mutex );
567572 }
568573
569574 return ret ;
@@ -572,7 +577,8 @@ static int proc_sctp_do_udp_port(struct ctl_table *ctl, int write,
572577static int proc_sctp_do_probe_interval (struct ctl_table * ctl , int write ,
573578 void * buffer , size_t * lenp , loff_t * ppos )
574579{
575- struct net * net = current -> nsproxy -> net_ns ;
580+ struct net * net = container_of (ctl -> data , struct net ,
581+ sctp .probe_interval );
576582 struct ctl_table tbl ;
577583 int ret , new_value ;
578584
0 commit comments