Patch "sctp: sysctl: rto_min/max: avoid using current->nsproxy" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    sctp: sysctl: rto_min/max: avoid using current->nsproxy

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     sctp-sysctl-rto_min-max-avoid-using-current-nsproxy.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit c22d413bad9a7b906c475b929133687c2ff17d51
Author: Matthieu Baerts (NGI0) <matttbe@xxxxxxxxxx>
Date:   Wed Jan 8 16:34:33 2025 +0100

    sctp: sysctl: rto_min/max: avoid using current->nsproxy
    
    [ Upstream commit 9fc17b76fc70763780aa78b38fcf4742384044a5 ]
    
    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.rto_min/max' is used.
    
    Fixes: 4f3fdf3bc59c ("sctp: add check rto_min and rto_max in sysctl")
    Cc: stable@xxxxxxxxxxxxxxx
    Link: https://lore.kernel.org/67769ecb.050a0220.3a8527.003f.GAE@xxxxxxxxxx [1]
    Suggested-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
    Signed-off-by: Matthieu Baerts (NGI0) <matttbe@xxxxxxxxxx>
    Link: https://patch.msgid.link/20250108-net-sysctl-current-nsproxy-v1-5-5df34b2083e8@xxxxxxxxxx
    Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index 8be80096fbb6..82b736843c9d 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -396,7 +396,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write,
 static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
 				void *buffer, size_t *lenp, loff_t *ppos)
 {
-	struct net *net = current->nsproxy->net_ns;
+	struct net *net = container_of(ctl->data, struct net, sctp.rto_min);
 	unsigned int min = *(unsigned int *) ctl->extra1;
 	unsigned int max = *(unsigned int *) ctl->extra2;
 	struct ctl_table tbl;
@@ -424,7 +424,7 @@ static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
 static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
 				void *buffer, size_t *lenp, loff_t *ppos)
 {
-	struct net *net = current->nsproxy->net_ns;
+	struct net *net = container_of(ctl->data, struct net, sctp.rto_max);
 	unsigned int min = *(unsigned int *) ctl->extra1;
 	unsigned int max = *(unsigned int *) ctl->extra2;
 	struct ctl_table tbl;




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux