mbox series

[v2,net,00/12] sysctl: Fix data-races around ipv4_table.

Message ID 20220706234003.66760-1-kuniyu@amazon.com (mailing list archive)
Headers show
Series sysctl: Fix data-races around ipv4_table. | expand

Message

Kuniyuki Iwashima July 6, 2022, 11:39 p.m. UTC
A sysctl variable is accessed concurrently, and there is always a chance
of data-race.  So, all readers and writers need some basic protection to
avoid load/store-tearing.

The first half of this series changes some proc handlers used in ipv4_table
to use READ_ONCE() and WRITE_ONCE() internally to fix data-races on the
sysctl side.  Then, the second half adds READ_ONCE() to the other readers
of ipv4_table.


Changes:
  v2:
    * Drop some changes that makes backporting difficult
      * First cleanup patch
      * Lockless helpers and .proc_handler changes
    * Drop the tracing part for .sysctl_mem
      * Steve already posted a fix
    * Drop int-to-bool change for cipso
      * Should be posted to net-next later
    * Drop proc_dobool() change
      * Can be included in another series

  v1: https://lore.kernel.org/netdev/20220706052130.16368-1-kuniyu@amazon.com/


Kuniyuki Iwashima (12):
  sysctl: Fix data races in proc_dointvec().
  sysctl: Fix data races in proc_douintvec().
  sysctl: Fix data races in proc_dointvec_minmax().
  sysctl: Fix data races in proc_douintvec_minmax().
  sysctl: Fix data races in proc_doulongvec_minmax().
  sysctl: Fix data races in proc_dointvec_jiffies().
  tcp: Fix a data-race around sysctl_tcp_max_orphans.
  inetpeer: Fix data-races around sysctl.
  net: Fix data-races around sysctl_mem.
  cipso: Fix data-races around sysctl.
  icmp: Fix data-races around sysctl.
  ipv4: Fix a data-race around sysctl_fib_sync_mem.

 Documentation/networking/ip-sysctl.rst |  2 +-
 include/net/sock.h                     |  2 +-
 kernel/sysctl.c                        | 25 ++++++++++++++-----------
 net/ipv4/cipso_ipv4.c                  | 12 +++++++-----
 net/ipv4/fib_trie.c                    |  2 +-
 net/ipv4/icmp.c                        |  5 +++--
 net/ipv4/inetpeer.c                    | 12 ++++++++----
 net/ipv4/tcp.c                         |  3 ++-
 8 files changed, 37 insertions(+), 26 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org July 8, 2022, 11:50 a.m. UTC | #1
Hello:

This series was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Wed, 6 Jul 2022 16:39:51 -0700 you wrote:
> A sysctl variable is accessed concurrently, and there is always a chance
> of data-race.  So, all readers and writers need some basic protection to
> avoid load/store-tearing.
> 
> The first half of this series changes some proc handlers used in ipv4_table
> to use READ_ONCE() and WRITE_ONCE() internally to fix data-races on the
> sysctl side.  Then, the second half adds READ_ONCE() to the other readers
> of ipv4_table.
> 
> [...]

Here is the summary with links:
  - [v2,net,01/12] sysctl: Fix data races in proc_dointvec().
    https://git.kernel.org/netdev/net/c/1f1be04b4d48
  - [v2,net,02/12] sysctl: Fix data races in proc_douintvec().
    https://git.kernel.org/netdev/net/c/4762b532ec95
  - [v2,net,03/12] sysctl: Fix data races in proc_dointvec_minmax().
    https://git.kernel.org/netdev/net/c/f613d86d014b
  - [v2,net,04/12] sysctl: Fix data races in proc_douintvec_minmax().
    https://git.kernel.org/netdev/net/c/2d3b559df3ed
  - [v2,net,05/12] sysctl: Fix data races in proc_doulongvec_minmax().
    https://git.kernel.org/netdev/net/c/c31bcc8fb89f
  - [v2,net,06/12] sysctl: Fix data races in proc_dointvec_jiffies().
    https://git.kernel.org/netdev/net/c/e87782087766
  - [v2,net,07/12] tcp: Fix a data-race around sysctl_tcp_max_orphans.
    https://git.kernel.org/netdev/net/c/47e6ab24e8c6
  - [v2,net,08/12] inetpeer: Fix data-races around sysctl.
    https://git.kernel.org/netdev/net/c/3d32edf1f3c3
  - [v2,net,09/12] net: Fix data-races around sysctl_mem.
    https://git.kernel.org/netdev/net/c/310731e2f161
  - [v2,net,10/12] cipso: Fix data-races around sysctl.
    https://git.kernel.org/netdev/net/c/dd44f04b9214
  - [v2,net,11/12] icmp: Fix data-races around sysctl.
    https://git.kernel.org/netdev/net/c/48d7ee321ea5
  - [v2,net,12/12] ipv4: Fix a data-race around sysctl_fib_sync_mem.
    https://git.kernel.org/netdev/net/c/73318c4b7dbd

You are awesome, thank you!