16 Oct, 2020

1 commit

  • Pull networking updates from Jakub Kicinski:

    - Add redirect_neigh() BPF packet redirect helper, allowing to limit
    stack traversal in common container configs and improving TCP
    back-pressure.

    Daniel reports ~10Gbps => ~15Gbps single stream TCP performance gain.

    - Expand netlink policy support and improve policy export to user
    space. (Ge)netlink core performs request validation according to
    declared policies. Expand the expressiveness of those policies
    (min/max length and bitmasks). Allow dumping policies for particular
    commands. This is used for feature discovery by user space (instead
    of kernel version parsing or trial and error).

    - Support IGMPv3/MLDv2 multicast listener discovery protocols in
    bridge.

    - Allow more than 255 IPv4 multicast interfaces.

    - Add support for Type of Service (ToS) reflection in SYN/SYN-ACK
    packets of TCPv6.

    - In Multi-patch TCP (MPTCP) support concurrent transmission of data on
    multiple subflows in a load balancing scenario. Enhance advertising
    addresses via the RM_ADDR/ADD_ADDR options.

    - Support SMC-Dv2 version of SMC, which enables multi-subnet
    deployments.

    - Allow more calls to same peer in RxRPC.

    - Support two new Controller Area Network (CAN) protocols - CAN-FD and
    ISO 15765-2:2016.

    - Add xfrm/IPsec compat layer, solving the 32bit user space on 64bit
    kernel problem.

    - Add TC actions for implementing MPLS L2 VPNs.

    - Improve nexthop code - e.g. handle various corner cases when nexthop
    objects are removed from groups better, skip unnecessary
    notifications and make it easier to offload nexthops into HW by
    converting to a blocking notifier.

    - Support adding and consuming TCP header options by BPF programs,
    opening the doors for easy experimental and deployment-specific TCP
    option use.

    - Reorganize TCP congestion control (CC) initialization to simplify
    life of TCP CC implemented in BPF.

    - Add support for shipping BPF programs with the kernel and loading
    them early on boot via the User Mode Driver mechanism, hence reusing
    all the user space infra we have.

    - Support sleepable BPF programs, initially targeting LSM and tracing.

    - Add bpf_d_path() helper for returning full path for given 'struct
    path'.

    - Make bpf_tail_call compatible with bpf-to-bpf calls.

    - Allow BPF programs to call map_update_elem on sockmaps.

    - Add BPF Type Format (BTF) support for type and enum discovery, as
    well as support for using BTF within the kernel itself (current use
    is for pretty printing structures).

    - Support listing and getting information about bpf_links via the bpf
    syscall.

    - Enhance kernel interfaces around NIC firmware update. Allow
    specifying overwrite mask to control if settings etc. are reset
    during update; report expected max time operation may take to users;
    support firmware activation without machine reboot incl. limits of
    how much impact reset may have (e.g. dropping link or not).

    - Extend ethtool configuration interface to report IEEE-standard
    counters, to limit the need for per-vendor logic in user space.

    - Adopt or extend devlink use for debug, monitoring, fw update in many
    drivers (dsa loop, ice, ionic, sja1105, qed, mlxsw, mv88e6xxx,
    dpaa2-eth).

    - In mlxsw expose critical and emergency SFP module temperature alarms.
    Refactor port buffer handling to make the defaults more suitable and
    support setting these values explicitly via the DCBNL interface.

    - Add XDP support for Intel's igb driver.

    - Support offloading TC flower classification and filtering rules to
    mscc_ocelot switches.

    - Add PTP support for Marvell Octeontx2 and PP2.2 hardware, as well as
    fixed interval period pulse generator and one-step timestamping in
    dpaa-eth.

    - Add support for various auth offloads in WiFi APs, e.g. SAE (WPA3)
    offload.

    - Add Lynx PHY/PCS MDIO module, and convert various drivers which have
    this HW to use it. Convert mvpp2 to split PCS.

    - Support Marvell Prestera 98DX3255 24-port switch ASICs, as well as
    7-port Mediatek MT7531 IP.

    - Add initial support for QCA6390 and IPQ6018 in ath11k WiFi driver,
    and wcn3680 support in wcn36xx.

    - Improve performance for packets which don't require much offloads on
    recent Mellanox NICs by 20% by making multiple packets share a
    descriptor entry.

    - Move chelsio inline crypto drivers (for TLS and IPsec) from the
    crypto subtree to drivers/net. Move MDIO drivers out of the phy
    directory.

    - Clean up a lot of W=1 warnings, reportedly the actively developed
    subsections of networking drivers should now build W=1 warning free.

    - Make sure drivers don't use in_interrupt() to dynamically adapt their
    code. Convert tasklets to use new tasklet_setup API (sadly this
    conversion is not yet complete).

    * tag 'net-next-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next: (2583 commits)
    Revert "bpfilter: Fix build error with CONFIG_BPFILTER_UMH"
    net, sockmap: Don't call bpf_prog_put() on NULL pointer
    bpf, selftest: Fix flaky tcp_hdr_options test when adding addr to lo
    bpf, sockmap: Add locking annotations to iterator
    netfilter: nftables: allow re-computing sctp CRC-32C in 'payload' statements
    net: fix pos incrementment in ipv6_route_seq_next
    net/smc: fix invalid return code in smcd_new_buf_create()
    net/smc: fix valid DMBE buffer sizes
    net/smc: fix use-after-free of delayed events
    bpfilter: Fix build error with CONFIG_BPFILTER_UMH
    cxgb4/ch_ipsec: Replace the module name to ch_ipsec from chcr
    net: sched: Fix suspicious RCU usage while accessing tcf_tunnel_info
    bpf: Fix register equivalence tracking.
    rxrpc: Fix loss of final ack on shutdown
    rxrpc: Fix bundle counting for exclusive connections
    netfilter: restore NF_INET_NUMHOOKS
    ibmveth: Identify ingress large send packets.
    ibmveth: Switch order of ibmveth_helper calls.
    cxgb4: handle 4-tuple PEDIT to NAT mode translation
    selftests: Add VRF route leaking tests
    ...

    Linus Torvalds
     

13 Oct, 2020

1 commit

  • Pull copy_and_csum cleanups from Al Viro:
    "Saner calling conventions for csum_and_copy_..._user() and friends"

    [ Removing 800+ lines of code and cleaning stuff up is good - Linus ]

    * 'work.csum_and_copy' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    ppc: propagate the calling conventions change down to csum_partial_copy_generic()
    amd64: switch csum_partial_copy_generic() to new calling conventions
    sparc64: propagate the calling convention changes down to __csum_partial_copy_...()
    xtensa: propagate the calling conventions change down into csum_partial_copy_generic()
    mips: propagate the calling convention change down into __csum_partial_copy_..._user()
    mips: __csum_partial_copy_kernel() has no users left
    mips: csum_and_copy_{to,from}_user() are never called under KERNEL_DS
    sparc32: propagate the calling conventions change down to __csum_partial_copy_sparc_generic()
    i386: propagate the calling conventions change down to csum_partial_copy_generic()
    sh: propage the calling conventions change down to csum_partial_copy_generic()
    m68k: get rid of zeroing destination on error in csum_and_copy_from_user()
    arm: propagate the calling convention changes down to csum_partial_copy_from_user()
    alpha: propagate the calling convention changes down to csum_partial_copy.c helpers
    saner calling conventions for csum_and_copy_..._user()
    csum_and_copy_..._user(): pass 0xffffffff instead of 0 as initial sum
    csum_partial_copy_nocheck(): drop the last argument
    unify generic instances of csum_partial_copy_nocheck()
    icmp_push_reply(): reorder adding the checksum up
    skb_copy_and_csum_bits(): don't bother with the last argument

    Linus Torvalds
     

05 Sep, 2020

1 commit

  • We got slightly different patches removing a double word
    in a comment in net/ipv4/raw.c - picked the version from net.

    Simple conflict in drivers/net/ethernet/ibm/ibmvnic.c. Use cached
    values instead of VNIC login response buffer (following what
    commit 507ebe6444a4 ("ibmvnic: Fix use-after-free of VNIC login
    response buffer") did).

    Signed-off-by: Jakub Kicinski

    Jakub Kicinski
     

27 Aug, 2020

1 commit


25 Aug, 2020

2 commits


21 Aug, 2020

1 commit

  • It's always 0. Note that we theoretically could use ~0U as well -
    result will be the same modulo 0xffff, _if_ the damn thing did the
    right thing for any value of initial sum; later we'll make use of
    that when convenient.

    However, unlike csum_and_copy_..._user(), there are instances that
    did not work for arbitrary initial sums; c6x is one such.

    Signed-off-by: Al Viro

    Al Viro
     

25 Jul, 2020

1 commit

  • Rework the remaining setsockopt code to pass a sockptr_t instead of a
    plain user pointer. This removes the last remaining set_fs(KERNEL_DS)
    outside of architecture specific code.

    Signed-off-by: Christoph Hellwig
    Acked-by: Stefan Schmidt [ieee802154]
    Acked-by: Matthieu Baerts
    Signed-off-by: David S. Miller

    Christoph Hellwig
     

20 Jul, 2020

1 commit


12 Mar, 2020

1 commit

  • Sparse reports warnings at raw_seq_start() and raw_seq_stop()

    warning: context imbalance in raw_seq_start() - wrong count at exit
    warning: context imbalance in raw_seq_stop() - unexpected unlock

    The root cause is the missing annotations at raw_seq_start()
    and raw_seq_stop()
    Add the missing __acquires(&h->lock) annotation
    Add the missing __releases(&h->lock) annotation

    Signed-off-by: Jules Irenge
    Signed-off-by: David S. Miller

    Jules Irenge
     

02 Oct, 2019

1 commit

  • commit 174e23810cd31
    ("sk_buff: drop all skb extensions on free and skb scrubbing") made napi
    recycle always drop skb extensions. The additional skb_ext_del() that is
    performed via nf_reset on napi skb recycle is not needed anymore.

    Most nf_reset() calls in the stack are there so queued skb won't block
    'rmmod nf_conntrack' indefinitely.

    This removes the skb_ext_del from nf_reset, and renames it to a more
    fitting nf_reset_ct().

    In a few selected places, add a call to skb_ext_reset to make sure that
    no active extensions remain.

    I am submitting this for "net", because we're still early in the release
    cycle. The patch applies to net-next too, but I think the rename causes
    needless divergence between those trees.

    Suggested-by: Eric Dumazet
    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso

    Florian Westphal
     

14 Sep, 2019

1 commit

  • Enable setting skb->mark for UDP and RAW sockets using cmsg.

    This is analogous to existing support for TOS, TTL, txtime, etc.

    Packet sockets already support this as of commit c7d39e32632e
    ("packet: support per-packet fwmark for af_packet sendmsg").

    Similar to other fields, implement by
    1. initialize the sockcm_cookie.mark from socket option sk_mark
    2. optionally overwrite this in ip_cmsg_send/ip6_datagram_send_ctl
    3. initialize inet_cork.mark from sockcm_cookie.mark
    4. initialize each (usually just one) skb->mark from inet_cork.mark

    Step 1 is handled in one location for most protocols by ipcm_init_sk
    as of commit 351782067b6b ("ipv4: ipcm_cookie initializers").

    Signed-off-by: Willem de Bruijn
    Signed-off-by: David S. Miller

    Willem de Bruijn
     

26 Jun, 2019

1 commit

  • In commit 19e4e768064a8 ("ipv4: Fix raw socket lookup for local
    traffic"), the dif argument to __raw_v4_lookup() is coming from the
    returned value of inet_iif() but the change was done only for the first
    lookup. Subsequent lookups in the while loop still use skb->dev->ifIndex.

    Fixes: 19e4e768064a8 ("ipv4: Fix raw socket lookup for local traffic")
    Signed-off-by: Stephen Suryaputra
    Reviewed-by: David Ahern
    Signed-off-by: David S. Miller

    Stephen Suryaputra
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 3029 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

20 May, 2019

1 commit


09 May, 2019

1 commit

  • inet_iif should be used for the raw socket lookup. inet_iif considers
    rt_iif which handles the case of local traffic.

    As it stands, ping to a local address with the '-I ' option fails
    ever since ping was changed to use SO_BINDTODEVICE instead of
    cmsg + IP_PKTINFO.

    IPv6 works fine.

    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: David Ahern
    Signed-off-by: David S. Miller

    David Ahern
     

21 Dec, 2018

1 commit


18 Dec, 2018

1 commit

  • SOF_TIMESTAMPING_OPT_ID is supported on TCP, UDP and RAW sockets.
    But it was missing on RAW with IPPROTO_IP, PF_PACKET and CAN.

    Add skb_setup_tx_timestamp that configures both tx_flags and tskey
    for these paths that do not need corking or use bytestream keys.

    Fixes: 09c2d251b707 ("net-timestamp: add key to disambiguate concurrent datagrams")
    Signed-off-by: Willem de Bruijn
    Acked-by: Soheil Hassas Yeganeh
    Signed-off-by: David S. Miller

    Willem de Bruijn
     

28 Nov, 2018

1 commit

  • Randy reported when CONFIG_PROC_FS is not enabled:
    ld: net/ipv4/af_inet.o: in function `inet_init':
    af_inet.c:(.init.text+0x42d): undefined reference to `raw_init'

    Fix by moving the endif up to the end of the proc entries

    Fixes: 6897445fb194c ("net: provide a sysctl raw_l3mdev_accept for raw socket lookup with VRFs")
    Reported-by: Randy Dunlap
    Cc: Mike Manning
    Signed-off-by: David Ahern
    Signed-off-by: David S. Miller

    David Ahern
     

08 Nov, 2018

2 commits

  • When there exist a pair of raw sockets one unbound and one bound
    to a VRF but equal in all other respects, when a packet is received
    in the VRF context, __raw_v4_lookup() matches on both sockets.

    This results in the packet being delivered over both sockets,
    instead of only the raw socket bound to the VRF. The bound device
    checks in __raw_v4_lookup() are replaced with a call to
    raw_sk_bound_dev_eq() which correctly handles whether the packet
    should be delivered over the unbound socket in such cases.

    In __raw_v6_lookup() the match on the device binding of the socket is
    similarly updated to use raw_sk_bound_dev_eq() which matches the
    handling in __raw_v4_lookup().

    Importantly raw_sk_bound_dev_eq() takes the raw_l3mdev_accept sysctl
    into account.

    Signed-off-by: Duncan Eastoe
    Signed-off-by: Mike Manning
    Reviewed-by: David Ahern
    Tested-by: David Ahern
    Signed-off-by: David S. Miller

    Duncan Eastoe
     
  • Add a sysctl raw_l3mdev_accept to control raw socket lookup in a manner
    similar to use of tcp_l3mdev_accept for stream and of udp_l3mdev_accept
    for datagram sockets. Have this default to enabled for reasons of
    backwards compatibility. This is so as to specify the output device
    with cmsg and IP_PKTINFO, but using a socket not bound to the
    corresponding VRF. This allows e.g. older ping implementations to be
    run with specifying the device but without executing it in the VRF.
    If the option is disabled, packets received in a VRF context are only
    handled by a raw socket bound to the VRF, and correspondingly packets
    in the default VRF are only handled by a socket not bound to any VRF.

    Signed-off-by: Mike Manning
    Reviewed-by: David Ahern
    Tested-by: David Ahern
    Signed-off-by: David S. Miller

    Mike Manning
     

03 Oct, 2018

1 commit

  • It is useful to be able to use the same socket for listening in a
    specific VRF, as for sending multicast packets out of a specific
    interface. However, the bound device on the socket currently takes
    precedence and results in the packets not being sent.

    Relax the condition on overriding the output interface to use for
    sending packets out of UDP, raw and ping sockets to allow multicast
    packets to be sent using the specified multicast interface.

    Signed-off-by: Robert Shearman
    Signed-off-by: Mike Manning
    Reviewed-by: David Ahern
    Signed-off-by: David S. Miller

    Robert Shearman
     

07 Jul, 2018

2 commits

  • skb_shinfo(skb)->tx_flags is derived from sk->sk_tsflags, possibly
    after modification by __sock_cmsg_send, by calling sock_tx_timestamp.

    The IPv4 and IPv6 paths do this conversion differently. In IPv4, the
    individual protocols that support tx timestamps call this function
    and store the result in ipc.tx_flags. In IPv6, sock_tx_timestamp is
    called in __ip6_append_data.

    There is no need to store both tx_flags and ts_flags in the cookie
    as one is derived from the other. Convert when setting up the cork
    and remove the redundant field. This is similar to IPv6, only have
    the conversion happen only once per datagram, in ip(6)_setup_cork.

    Also change __ip6_append_data to match __ip_append_data. Only update
    tskey if timestamping is enabled with OPT_ID. The SOCK_.. test is
    redundant: only valid protocols can have non-zero cork->tx_flags.

    After this change the IPv4 and IPv6 logic is the same.

    Signed-off-by: Willem de Bruijn
    Signed-off-by: David S. Miller

    Willem de Bruijn
     
  • Initialize the cookie in one location to reduce code duplication and
    avoid bugs from inconsistent initialization, such as that fixed in
    commit 9887cba19978 ("ip: limit use of gso_size to udp").

    Signed-off-by: Willem de Bruijn
    Signed-off-by: David S. Miller

    Willem de Bruijn
     

04 Jul, 2018

1 commit

  • Add a transmit_time field to struct inet_cork, then copy the
    timestamp from the CMSG cookie at ip_setup_cork() so we can
    safely copy it into the skb later during __ip_make_skb().

    For the raw fast path, just perform the copy at raw_send_hdrinc().

    Signed-off-by: Richard Cochran
    Signed-off-by: Jesus Sanchez-Palencia
    Signed-off-by: David S. Miller

    Jesus Sanchez-Palencia
     

16 May, 2018

2 commits


28 Mar, 2018

1 commit


27 Mar, 2018

1 commit

  • Prefer the direct use of octal for permissions.

    Done with checkpatch -f --types=SYMBOLIC_PERMS --fix-inplace
    and some typing.

    Miscellanea:

    o Whitespace neatening around these conversions.

    Signed-off-by: Joe Perches
    Signed-off-by: David S. Miller

    Joe Perches
     

23 Mar, 2018

1 commit

  • This reverts commit 1215e51edad1.
    Since raw_close() is used on every RAW socket destruction,
    the changes made by 1215e51edad1 scale sadly. This clearly
    seen on endless unshare(CLONE_NEWNET) test, and cleanup_net()
    kwork spends a lot of time waiting for rtnl_lock() introduced
    by this commit.

    Previous patch moved IP_ROUTER_ALERT out of rtnl_lock(),
    so we revert this patch.

    Signed-off-by: Kirill Tkhai
    Signed-off-by: David S. Miller

    Kirill Tkhai
     

13 Feb, 2018

1 commit

  • arp_net_ops just addr/removes /proc entry.

    devinet_ops allocates and frees duplicate of init_net tables
    and (un)registers sysctl entries.

    fib_net_ops allocates and frees pernet tables, creates/destroys
    netlink socket and (un)initializes /proc entries. Foreign
    pernet_operations do not touch them.

    ip_rt_proc_ops only modifies pernet /proc entries.

    xfrm_net_ops creates/destroys /proc entries, allocates/frees
    pernet statistics, hashes and tables, and (un)initializes
    sysctl files. These are not touched by foreigh pernet_operations

    xfrm4_net_ops allocates/frees private pernet memory, and
    configures sysctls.

    sysctl_route_ops creates/destroys sysctls.

    rt_genid_ops only initializes fields of just allocated net.

    ipv4_inetpeer_ops allocated/frees net private memory.

    igmp_net_ops just creates/destroys /proc files and socket,
    noone else interested in.

    tcp_sk_ops seems to be safe, because tcp_sk_init() does not
    depend on any other pernet_operations modifications. Iteration
    over hash table in inet_twsk_purge() is made under RCU lock,
    and it's safe to iterate the table this way. Removing from
    the table happen from inet_twsk_deschedule_put(), but this
    function is safe without any extern locks, as it's synchronized
    inside itself. There are many examples, it's used in different
    context. So, it's safe to leave tcp_sk_exit_batch() unlocked.

    tcp_net_metrics_ops is synchronized on tcp_metrics_lock and safe.

    udplite4_net_ops only creates/destroys pernet /proc file.

    icmp_sk_ops creates percpu sockets, not touched by foreign
    pernet_operations.

    ipmr_net_ops creates/destroys pernet fib tables, (un)registers
    fib rules and /proc files. This seem to be safe to execute
    in parallel with foreign pernet_operations.

    af_inet_ops just sets up default parameters of newly created net.

    ipv4_mib_ops creates and destroys pernet percpu statistics.

    raw_net_ops, tcp4_net_ops, udp4_net_ops, ping_v4_net_ops
    and ip_proc_ops only create/destroy pernet /proc files.

    ip4_frags_ops creates and destroys sysctl file.

    So, it's safe to make the pernet_operations async.

    Signed-off-by: Kirill Tkhai
    Acked-by: Andrei Vagin
    Signed-off-by: David S. Miller

    Kirill Tkhai
     

04 Feb, 2018

1 commit

  • Pull hardened usercopy whitelisting from Kees Cook:
    "Currently, hardened usercopy performs dynamic bounds checking on slab
    cache objects. This is good, but still leaves a lot of kernel memory
    available to be copied to/from userspace in the face of bugs.

    To further restrict what memory is available for copying, this creates
    a way to whitelist specific areas of a given slab cache object for
    copying to/from userspace, allowing much finer granularity of access
    control.

    Slab caches that are never exposed to userspace can declare no
    whitelist for their objects, thereby keeping them unavailable to
    userspace via dynamic copy operations. (Note, an implicit form of
    whitelisting is the use of constant sizes in usercopy operations and
    get_user()/put_user(); these bypass all hardened usercopy checks since
    these sizes cannot change at runtime.)

    This new check is WARN-by-default, so any mistakes can be found over
    the next several releases without breaking anyone's system.

    The series has roughly the following sections:
    - remove %p and improve reporting with offset
    - prepare infrastructure and whitelist kmalloc
    - update VFS subsystem with whitelists
    - update SCSI subsystem with whitelists
    - update network subsystem with whitelists
    - update process memory with whitelists
    - update per-architecture thread_struct with whitelists
    - update KVM with whitelists and fix ioctl bug
    - mark all other allocations as not whitelisted
    - update lkdtm for more sensible test overage"

    * tag 'usercopy-v4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: (38 commits)
    lkdtm: Update usercopy tests for whitelisting
    usercopy: Restrict non-usercopy caches to size 0
    kvm: x86: fix KVM_XEN_HVM_CONFIG ioctl
    kvm: whitelist struct kvm_vcpu_arch
    arm: Implement thread_struct whitelist for hardened usercopy
    arm64: Implement thread_struct whitelist for hardened usercopy
    x86: Implement thread_struct whitelist for hardened usercopy
    fork: Provide usercopy whitelisting for task_struct
    fork: Define usercopy region in thread_stack slab caches
    fork: Define usercopy region in mm_struct slab caches
    net: Restrict unwhitelisted proto caches to size 0
    sctp: Copy struct sctp_sock.autoclose to userspace using put_user()
    sctp: Define usercopy region in SCTP proto slab cache
    caif: Define usercopy region in caif proto slab cache
    ip: Define usercopy region in IP proto slab cache
    net: Define usercopy region in struct proto slab cache
    scsi: Define usercopy region in scsi_sense_cache slab cache
    cifs: Define usercopy region in cifs_request slab cache
    vxfs: Define usercopy region in vxfs_inode slab cache
    ufs: Define usercopy region in ufs_inode_cache slab cache
    ...

    Linus Torvalds
     

26 Jan, 2018

1 commit

  • Message sends to the local broadcast address (255.255.255.255) require
    uc_index or sk_bound_dev_if to be set to an egress device. However,
    responses or only received if the socket is bound to the device. This
    is overly constraining for processes running in an L3 domain. This
    patch allows a socket bound to the VRF device to send to the local
    broadcast address by using IP_UNICAST_IF to set the egress interface
    with packet receipt handled by the VRF binding.

    Similar to IP_MULTICAST_IF, relax the constraint on setting
    IP_UNICAST_IF if a socket is bound to an L3 master device. In this
    case allow uc_index to be set to an enslaved if sk_bound_dev_if is
    an L3 master device and is the master device for the ifindex.

    In udp and raw sendmsg, allow uc_index to override the oif if
    uc_index master device is oif (ie., the oif is an L3 master and the
    index is an L3 slave).

    Signed-off-by: David Ahern
    Signed-off-by: David S. Miller

    David Ahern
     

17 Jan, 2018

1 commit

  • /proc has been ignoring struct file_operations::owner field for 10 years.
    Specifically, it started with commit 786d7e1612f0b0adb6046f19b906609e4fe8b1ba
    ("Fix rmmod/read/write races in /proc entries"). Notice the chunk where
    inode->i_fop is initialized with proxy struct file_operations for
    regular files:

    - if (de->proc_fops)
    - inode->i_fop = de->proc_fops;
    + if (de->proc_fops) {
    + if (S_ISREG(inode->i_mode))
    + inode->i_fop = &proc_reg_file_ops;
    + else
    + inode->i_fop = de->proc_fops;
    + }

    VFS stopped pinning module at this point.

    Signed-off-by: Alexey Dobriyan
    Signed-off-by: David S. Miller

    Alexey Dobriyan
     

16 Jan, 2018

1 commit

  • The ICMP filters for IPv4 and IPv6 raw sockets need to be copied to/from
    userspace. In support of usercopy hardening, this patch defines a region
    in the struct proto slab cache in which userspace copy operations are
    allowed.

    example usage trace:

    net/ipv4/raw.c:
    raw_seticmpfilter(...):
    ...
    copy_from_user(&raw_sk(sk)->filter, ..., optlen)

    raw_geticmpfilter(...):
    ...
    copy_to_user(..., &raw_sk(sk)->filter, len)

    net/ipv6/raw.c:
    rawv6_seticmpfilter(...):
    ...
    copy_from_user(&raw6_sk(sk)->filter, ..., optlen)

    rawv6_geticmpfilter(...):
    ...
    copy_to_user(..., &raw6_sk(sk)->filter, len)

    This region is known as the slab cache's usercopy region. Slab caches
    can now check that each dynamically sized copy operation involving
    cache-managed memory falls entirely within the slab's usercopy region.

    This patch is modified from Brad Spengler/PaX Team's PAX_USERCOPY
    whitelisting code in the last public patch of grsecurity/PaX based on my
    understanding of the code. Changes or omissions from the original code are
    mine and don't reflect the original grsecurity/PaX code.

    Signed-off-by: David Windsor
    [kees: split from network patch, provide usage trace]
    Cc: "David S. Miller"
    Cc: Alexey Kuznetsov
    Cc: Hideaki YOSHIFUJI
    Cc: netdev@vger.kernel.org
    Signed-off-by: Kees Cook

    David Windsor
     

10 Jan, 2018

1 commit

  • Commit 8f659a03a0ba ("net: ipv4: fix for a race condition in
    raw_sendmsg") fixed the issue of possibly inconsistent ->hdrincl handling
    due to concurrent updates by reading this bit-field member into a local
    variable and using the thus stabilized value in subsequent tests.

    However, aforementioned commit also adds the (correct) comment that

    /* hdrincl should be READ_ONCE(inet->hdrincl)
    * but READ_ONCE() doesn't work with bit fields
    */

    because as it stands, the compiler is free to shortcut or even eliminate
    the local variable at its will.

    Note that I have not seen anything like this happening in reality and thus,
    the concern is a theoretical one.

    However, in order to be on the safe side, emulate a READ_ONCE() on the
    bit-field by doing it on the local 'hdrincl' variable itself:

    int hdrincl = inet->hdrincl;
    hdrincl = READ_ONCE(hdrincl);

    This breaks the chain in the sense that the compiler is not allowed
    to replace subsequent reads from hdrincl with reloads from inet->hdrincl.

    Fixes: 8f659a03a0ba ("net: ipv4: fix for a race condition in raw_sendmsg")
    Signed-off-by: Nicolai Stange
    Reviewed-by: Stefano Brivio
    Signed-off-by: David S. Miller

    Nicolai Stange
     

12 Dec, 2017

1 commit


08 Aug, 2017

2 commits


01 Jul, 2017

1 commit

  • refcount_t type and corresponding API should be
    used instead of atomic_t when the variable is used as
    a reference counter. This allows to avoid accidental
    refcounter overflows that might lead to use-after-free
    situations.

    This patch uses refcount_inc_not_zero() instead of
    atomic_inc_not_zero_hint() due to absense of a _hint()
    version of refcount API. If the hint() version must
    be used, we might need to revisit API.

    Signed-off-by: Elena Reshetova
    Signed-off-by: Hans Liljestrand
    Signed-off-by: Kees Cook
    Signed-off-by: David Windsor
    Signed-off-by: David S. Miller

    Reshetova, Elena