net: sysctl: avoid using current->nsproxy
Status from this message: This series was applied to netdev/net.git (main)
Get series with b4
b4 am [email protected] change-id 20250108-net-sysctl-current-nsproxy-672ae21a873fVersions newest first
Patches in v1 All 9 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/9 | mptcp: sysctl: avail sched: remove write accessnet/ | +1 | 1 reply | Applied |
| 2/9 | mptcp: sysctl: sched: avoid using current->nsproxynet/ | +5 | 0 replies | Applied |
| 3/9 | mptcp: sysctl: blackhole timeout: avoid using current->nsproxynet/ | +3 | 0 replies | Applied |
| 4/9 | sctp: sysctl: cookie_hmac_alg: avoid using current->nsproxynet/ | +2 | 0 replies | Applied |
| 5/9 | sctp: sysctl: rto_min/max: avoid using current->nsproxynet/ | +2 | 0 replies | Applied |
| 6/9 | sctp: sysctl: auth_enable: avoid using current->nsproxynet/ | +1 | 0 replies | Applied |
| 7/9 | sctp: sysctl: udp_port: avoid using current->nsproxynet/ | +1 | 0 replies | Applied |
| 8/9 | sctp: sysctl: plpmtud_probe_interval: avoid using current->nsproxynet/ | +2 | 0 replies | Applied |
| 9/9 | rds: sysctl: rds_tcp_{rcv,snd}buf: avoid using current->nsproxynet/ | +32 | 0 replies | Applied |
Reviews trailers per patch
3 of 9 patches have a Reviewed-by or Acked-by.
| Patch | Mat Martineau | Eric Dumazet |
|---|---|---|
| 1/9 | R-b | R-b |
| 2/9 | R-b | |
| 3/9 | R-b | |
| 4/9 | ||
| 5/9 | ||
| 6/9 | ||
| 7/9 | ||
| 8/9 | ||
| 9/9 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH net 0/9] net: sysctl: avoid using current->nsproxy
As pointed out by Al Viro and Eric Dumazet in [1], 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 as it is usually done. This could cause unexpected issues when other operations are done on the wrong 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' or 'pernet' structure can be obtained from the table->data using container_of().
Note that table->data could also be used directly in more places, but that would increase the size of this fix to replace all accesses via 'net'. Probably best to avoid that for fixes.
Patches 2-9 remove access of net via current->nsproxy in sysfs handlers in MPTCP, SCTP and RDS. There are multiple patches doing almost the same thing, but the reason is to ease the backports.
Patch 1 is not directly linked to this, but it is a small fix for MPTCP available_schedulers sysctl knob to explicitly mark it as read-only.
Please note that this series does not address Al's comment [2]. In SCTP, some sysctl knobs set other sysfs-exposed variables for the min/max: two processes could then write two linked values at the same time, resulting in new values being outside the new boundaries. It would be great if SCTP developers can look at this problem.
---
Matthieu Baerts (NGI0) (9):
mptcp: sysctl: avail sched: remove write access
mptcp: sysctl: sched: avoid using current->nsproxy
mptcp: sysctl: blackhole timeout: avoid using current->nsproxy
sctp: sysctl: cookie_hmac_alg: avoid using current->nsproxy
sctp: sysctl: rto_min/max: avoid using current->nsproxy
sctp: sysctl: auth_enable: avoid using current->nsproxy
sctp: sysctl: udp_port: avoid using current->nsproxy
sctp: sysctl: plpmtud_probe_interval: avoid using current->nsproxy
rds: sysctl: rds_tcp_{rcv,snd}buf: avoid using current->nsproxynet/mptcp/ctrl.c | 17 +++++++++-------- net/rds/tcp.c | 39 ++++++++++++++++++++++++++++++++------- net/sctp/sysctl.c | 14 ++++++++------ 3 files changed, 49 insertions(+), 21 deletions(-)
---
base-commit: db78475ba0d3c66d430f7ded2388cc041078a542
change-id: 20250108-net-sysctl-current-nsproxy-672ae21a873f
Best regards,
Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>