Skip to content
  1. Jan 24, 2021
  2. Jan 23, 2021
    • Pan Bian's avatar
      net: fec: put child node on error path · 0607a2cd
      Pan Bian authored
      Also decrement the reference count of child device on error path.
      
      Fixes: 3e782985
      
       ("net: ethernet: fec: Allow configuration of MDIO bus speed")
      Signed-off-by: default avatarPan Bian <bianpan2016@163.com>
      Link: https://lore.kernel.org/r/20210120122037.83897-1-bianpan2016@163.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      0607a2cd
    • Pan Bian's avatar
      net: stmmac: dwmac-intel-plat: remove config data on error · 3765d86f
      Pan Bian authored
      Remove the config data when rate setting fails.
      
      Fixes: 9efc9b2b
      
       ("net: stmmac: Add dwmac-intel-plat for GBE driver")
      Signed-off-by: default avatarPan Bian <bianpan2016@163.com>
      Link: https://lore.kernel.org/r/20210120110745.36412-1-bianpan2016@163.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      3765d86f
    • Kevin Hao's avatar
      net: octeontx2: Make sure the buffer is 128 byte aligned · db280515
      Kevin Hao authored
      The octeontx2 hardware needs the buffer to be 128 byte aligned.
      But in the current implementation of napi_alloc_frag(), it can't
      guarantee the return address is 128 byte aligned even the request size
      is a multiple of 128 bytes, so we have to request an extra 128 bytes and
      use the PTR_ALIGN() to make sure that the buffer is aligned correctly.
      
      Fixes: 7a36e491
      
       ("octeontx2-pf: Use the napi_alloc_frag() to alloc the pool buffers")
      Reported-by: default avatarSubbaraya Sundeep <sbhatta@marvell.com>
      Signed-off-by: default avatarKevin Hao <haokexin@gmail.com>
      Tested-by: default avatarSubbaraya Sundeep <sbhatta@marvell.com>
      Link: https://lore.kernel.org/r/20210121070906.25380-1-haokexin@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      db280515
    • Giacinto Cifelli's avatar
      net: usb: qmi_wwan: added support for Thales Cinterion PLSx3 modem family · 7e0e63d0
      Giacinto Cifelli authored
      
      
      Bus 003 Device 009: ID 1e2d:006f
      Device Descriptor:
        bLength                18
        bDescriptorType         1
        bcdUSB               2.00
        bDeviceClass          239 Miscellaneous Device
        bDeviceSubClass         2 ?
        bDeviceProtocol         1 Interface Association
        bMaxPacketSize0        64
        idVendor           0x1e2d
        idProduct          0x006f
        bcdDevice            0.00
        iManufacturer           3 Cinterion Wireless Modules
        iProduct                2 PLSx3
        iSerial                 4 fa3c1419
        bNumConfigurations      1
        Configuration Descriptor:
          bLength                 9
          bDescriptorType         2
          wTotalLength          303
          bNumInterfaces          9
          bConfigurationValue     1
          iConfiguration          1 Cinterion Configuration
          bmAttributes         0xe0
            Self Powered
            Remote Wakeup
          MaxPower              500mA
          Interface Association:
            bLength                 8
            bDescriptorType        11
            bFirstInterface         0
            bInterfaceCount         2
            bFunctionClass          2 Communications
            bFunctionSubClass       2 Abstract (modem)
            bFunctionProtocol       1 AT-commands (v.25ter)
            iFunction               0
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        0
            bAlternateSetting       0
            bNumEndpoints           1
            bInterfaceClass         2 Communications
            bInterfaceSubClass      2 Abstract (modem)
            bInterfaceProtocol      1 AT-commands (v.25ter)
            iInterface              0
            CDC Header:
              bcdCDC               1.10
            CDC ACM:
              bmCapabilities       0x02
                line coding and serial state
            CDC Call Management:
              bmCapabilities       0x03
                call management
                use DataInterface
              bDataInterface          1
            CDC Union:
              bMasterInterface        0
              bSlaveInterface         1
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x81  EP 1 IN
              bmAttributes            3
                Transfer Type            Interrupt
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0040  1x 64 bytes
              bInterval               5
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        1
            bAlternateSetting       0
            bNumEndpoints           2
            bInterfaceClass        10 CDC Data
            bInterfaceSubClass      0 Unused
            bInterfaceProtocol      0
            iInterface              0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x82  EP 2 IN
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x01  EP 1 OUT
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
          Interface Association:
            bLength                 8
            bDescriptorType        11
            bFirstInterface         2
            bInterfaceCount         2
            bFunctionClass          2 Communications
            bFunctionSubClass       2 Abstract (modem)
            bFunctionProtocol       1 AT-commands (v.25ter)
            iFunction               0
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        2
            bAlternateSetting       0
            bNumEndpoints           1
            bInterfaceClass         2 Communications
            bInterfaceSubClass      2 Abstract (modem)
            bInterfaceProtocol      1 AT-commands (v.25ter)
            iInterface              0
            CDC Header:
              bcdCDC               1.10
            CDC ACM:
              bmCapabilities       0x02
                line coding and serial state
            CDC Call Management:
              bmCapabilities       0x03
                call management
                use DataInterface
              bDataInterface          3
            CDC Union:
              bMasterInterface        2
              bSlaveInterface         3
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x83  EP 3 IN
              bmAttributes            3
                Transfer Type            Interrupt
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0040  1x 64 bytes
              bInterval               5
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        3
            bAlternateSetting       0
            bNumEndpoints           2
            bInterfaceClass        10 CDC Data
            bInterfaceSubClass      0 Unused
            bInterfaceProtocol      0
            iInterface              0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x84  EP 4 IN
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x02  EP 2 OUT
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
          Interface Association:
            bLength                 8
            bDescriptorType        11
            bFirstInterface         4
            bInterfaceCount         2
            bFunctionClass          2 Communications
            bFunctionSubClass       2 Abstract (modem)
            bFunctionProtocol       1 AT-commands (v.25ter)
            iFunction               0
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        4
            bAlternateSetting       0
            bNumEndpoints           1
            bInterfaceClass         2 Communications
            bInterfaceSubClass      2 Abstract (modem)
            bInterfaceProtocol      1 AT-commands (v.25ter)
            iInterface              0
            CDC Header:
              bcdCDC               1.10
            CDC ACM:
              bmCapabilities       0x02
                line coding and serial state
            CDC Call Management:
              bmCapabilities       0x03
                call management
                use DataInterface
              bDataInterface          5
            CDC Union:
              bMasterInterface        4
              bSlaveInterface         5
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x85  EP 5 IN
              bmAttributes            3
                Transfer Type            Interrupt
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0040  1x 64 bytes
              bInterval               5
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        5
            bAlternateSetting       0
            bNumEndpoints           2
            bInterfaceClass        10 CDC Data
            bInterfaceSubClass      0 Unused
            bInterfaceProtocol      0
            iInterface              0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x86  EP 6 IN
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x03  EP 3 OUT
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
          Interface Association:
            bLength                 8
            bDescriptorType        11
            bFirstInterface         6
            bInterfaceCount         2
            bFunctionClass          2 Communications
            bFunctionSubClass       2 Abstract (modem)
            bFunctionProtocol       1 AT-commands (v.25ter)
            iFunction               0
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        6
            bAlternateSetting       0
            bNumEndpoints           1
            bInterfaceClass         2 Communications
            bInterfaceSubClass      2 Abstract (modem)
            bInterfaceProtocol      1 AT-commands (v.25ter)
            iInterface              0
            CDC Header:
              bcdCDC               1.10
            CDC ACM:
              bmCapabilities       0x02
                line coding and serial state
            CDC Call Management:
              bmCapabilities       0x03
                call management
                use DataInterface
              bDataInterface          7
            CDC Union:
              bMasterInterface        6
              bSlaveInterface         7
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x87  EP 7 IN
              bmAttributes            3
                Transfer Type            Interrupt
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0040  1x 64 bytes
              bInterval               5
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        7
            bAlternateSetting       0
            bNumEndpoints           2
            bInterfaceClass        10 CDC Data
            bInterfaceSubClass      0 Unused
            bInterfaceProtocol      0
            iInterface              0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x88  EP 8 IN
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x04  EP 4 OUT
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
          Interface Descriptor:
            bLength                 9
            bDescriptorType         4
            bInterfaceNumber        8
            bAlternateSetting       0
            bNumEndpoints           3
            bInterfaceClass       255 Vendor Specific Class
            bInterfaceSubClass    255 Vendor Specific Subclass
            bInterfaceProtocol    255 Vendor Specific Protocol
            iInterface              0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x89  EP 9 IN
              bmAttributes            3
                Transfer Type            Interrupt
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0040  1x 64 bytes
              bInterval               5
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x8a  EP 10 IN
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
            Endpoint Descriptor:
              bLength                 7
              bDescriptorType         5
              bEndpointAddress     0x05  EP 5 OUT
              bmAttributes            2
                Transfer Type            Bulk
                Synch Type               None
                Usage Type               Data
              wMaxPacketSize     0x0200  1x 512 bytes
              bInterval               0
      Device Qualifier (for other device speed):
        bLength                10
        bDescriptorType         6
        bcdUSB               2.00
        bDeviceClass          239 Miscellaneous Device
        bDeviceSubClass         2 ?
        bDeviceProtocol         1 Interface Association
        bMaxPacketSize0        64
        bNumConfigurations      1
      Device Status:     0x0000
        (Bus Powered)
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGiacinto Cifelli <gciofono@gmail.com>
      Acked-by: default avatarBjørn Mork <bjorn@mork.no>
      Link: https://lore.kernel.org/r/20210120045650.10855-1-gciofono@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      7e0e63d0
  3. Jan 22, 2021
    • Jakub Kicinski's avatar
      Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec · 35c715c3
      Jakub Kicinski authored
      
      
      Steffen Klassert says:
      
      ====================
      pull request (net): ipsec 2021-01-21
      
      1) Fix a rare panic on SMP systems when packet reordering
         happens between anti replay check and update.
         From Shmulik Ladkani.
      
      2) Fix disable_xfrm sysctl when used on xfrm interfaces.
         From Eyal Birger.
      
      3) Fix a race in PF_KEY when the availability of crypto
         algorithms is set. From Cong Wang.
      
      4) Fix a return value override in the xfrm policy selftests.
         From Po-Hsu Lin.
      
      5) Fix an integer wraparound in xfrm_policy_addr_delta.
         From Visa Hankala.
      
      * 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec:
        xfrm: Fix wraparound in xfrm_policy_addr_delta()
        selftests: xfrm: fix test return value override issue in xfrm_policy.sh
        af_key: relax availability checks for skb size calculation
        xfrm: fix disable_xfrm sysctl when used on xfrm interfaces
        xfrm: Fix oops in xfrm_replay_advance_bmp
      ====================
      
      Link: https://lore.kernel.org/r/20210121121558.621339-1-steffen.klassert@secunet.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      35c715c3
  4. Jan 21, 2021
    • Marek Vasut's avatar
      net: dsa: microchip: Adjust reset release timing to match reference reset circuit · 1c45ba93
      Marek Vasut authored
      KSZ8794CNX datasheet section 8.0 RESET CIRCUIT describes recommended
      circuit for interfacing with CPU/FPGA reset consisting of 10k pullup
      resistor and 10uF capacitor to ground. This circuit takes ~100 ms to
      rise enough to release the reset.
      
      For maximum supply voltage VDDIO=3.3V VIH=2.0V R=10kR C=10uF that is
                          VDDIO - VIH
        t = R * C * -ln( ------------- ) = 10000*0.00001*-(-0.93)=0.093 s
                             VDDIO
      so we need ~95 ms for the reset to really de-assert, and then the
      original 100us for the switch itself to come out of reset. Simply
      msleep() for 100 ms which fits the constraint with a bit of extra
      space.
      
      Fixes: 5b797980
      
       ("net: dsa: microchip: Implement recommended reset timing")
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Cc: Michael Grzeschik <m.grzeschik@pengutronix.de>
      Reviewed-by: default avatarPaul Barker <pbarker@konsulko.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Link: https://lore.kernel.org/r/20210120030502.617185-1-marex@denx.de
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      1c45ba93
    • Marek Vasut's avatar
      net: dsa: microchip: ksz8795: Fix KSZ8794 port map again · c369d7fc
      Marek Vasut authored
      The KSZ8795 switch has 4 external ports {0,1,2,3} and 1 CPU port {4}, so
      does the KSZ8765. The KSZ8794 seems to be repackaged KSZ8795 with different
      ID and port 3 not routed out, however the port 3 registers are present in
      the silicon, so the KSZ8794 switch has 3 external ports {0,1,2} and 1 CPU
      port {4}. Currently the driver always uses the last port as CPU port, on
      KSZ8795/KSZ8765 that is port 4 and that is OK, but on KSZ8794 that is port
      3 and that is not OK, as it must also be port 4.
      
      This patch adjusts the driver such that it always registers a switch with
      5 ports total (4 external ports, 1 CPU port), always sets the CPU port to
      switch port 4, and then configures the external port mask according to
      the switch model -- 3 ports for KSZ8794 and 4 for KSZ8795/KSZ8765.
      
      Fixes: 68a1b676 ("net: dsa: microchip: ksz8795: remove superfluous port_cnt assignment")
      Fixes: 4ce2a984 ("net: dsa: microchip: ksz8795: use phy_port_cnt where possible")
      Fixes: 241ed719
      
       ("net: dsa: microchip: ksz8795: use port_cnt instead of TOTOAL_PORT_NUM")
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Cc: Michael Grzeschik <m.grzeschik@pengutronix.de>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/20210120001045.488506-1-marex@denx.de
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      c369d7fc
    • Linus Torvalds's avatar
      Merge tag 'net-5.11-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net · 75439bc4
      Linus Torvalds authored
      Pull networking fixes from Jakub Kicinski:
       "Networking fixes for 5.11-rc5, including fixes from bpf, wireless, and
        can trees.
      
        Current release - regressions:
      
         - nfc: nci: fix the wrong NCI_CORE_INIT parameters
      
        Current release - new code bugs:
      
         - bpf: allow empty module BTFs
      
        Previous releases - regressions:
      
         - bpf: fix signed_{sub,add32}_overflows type handling
      
         - tcp: do not mess with cloned skbs in tcp_add_backlog()
      
         - bpf: prevent double bpf_prog_put call from bpf_tracing_prog_attach
      
         - bpf: don't leak memory in bpf getsockopt when optlen == 0
      
         - tcp: fix potential use-after-free due to double kfree()
      
         - mac80211: fix encryption issues with WEP
      
         - devlink: use right genl user_ptr when handling port param get/set
      
         - ipv6: set multicast flag on the multicast route
      
         - tcp: fix TCP_USER_TIMEOUT with zero window
      
        Previous releases - always broken:
      
         - bpf: local storage helpers should check nullness of owner ptr passed
      
         - mac80211: fix incorrect strlen of .write in debugfs
      
         - cls_flower: call nla_ok() before nla_next()
      
         - skbuff: back tiny skbs with kmalloc() in __netdev_alloc_skb() too"
      
      * tag 'net-5.11-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (52 commits)
        net: systemport: free dev before on error path
        net: usb: cdc_ncm: don't spew notifications
        net: mscc: ocelot: Fix multicast to the CPU port
        tcp: Fix potential use-after-free due to double kfree()
        bpf: Fix signed_{sub,add32}_overflows type handling
        can: peak_usb: fix use after free bugs
        can: vxcan: vxcan_xmit: fix use after free bug
        can: dev: can_restart: fix use after free bug
        tcp: fix TCP socket rehash stats mis-accounting
        net: dsa: b53: fix an off by one in checking "vlan->vid"
        tcp: do not mess with cloned skbs in tcp_add_backlog()
        selftests: net: fib_tests: remove duplicate log test
        net: nfc: nci: fix the wrong NCI_CORE_INIT parameters
        sh_eth: Fix power down vs. is_opened flag ordering
        net: Disable NETIF_F_HW_TLS_RX when RXCSUM is disabled
        netfilter: rpfilter: mask ecn bits before fib lookup
        udp: mask TOS bits in udp_v4_early_demux()
        xsk: Clear pool even for inactive queues
        bpf: Fix helper bpf_map_peek_elem_proto pointing to wrong callback
        sh_eth: Make PHY access aware of Runtime PM to fix reboot crash
        ...
      75439bc4
    • Linus Torvalds's avatar
      Merge tag 'for-linus-5.11-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip · 2e4ceed6
      Linus Torvalds authored
      Pull xen fix from Juergen Gross:
       "A fix for build failure showing up in some configurations"
      
      * tag 'for-linus-5.11-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
        x86/xen: fix 'nopvspin' build error
      2e4ceed6
    • Tianjia Zhang's avatar
      X.509: Fix crash caused by NULL pointer · 7178a107
      Tianjia Zhang authored
      On the following call path, `sig->pkey_algo` is not assigned
      in asymmetric_key_verify_signature(), which causes runtime
      crash in public_key_verify_signature().
      
        keyctl_pkey_verify
          asymmetric_key_verify_signature
            verify_signature
              public_key_verify_signature
      
      This patch simply check this situation and fixes the crash
      caused by NULL pointer.
      
      Fixes: 21552563
      
       ("X.509: support OSCCA SM2-with-SM3 certificate verification")
      Reported-by: default avatarTobias Markus <tobias@markus-regensburg.de>
      Signed-off-by: default avatarTianjia Zhang <tianjia.zhang@linux.alibaba.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Reviewed-and-tested-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
      Tested-by: default avatarJoão Fonseca <jpedrofonseca@ua.pt>
      Acked-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      Cc: stable@vger.kernel.org # v5.10+
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7178a107
    • Takashi Iwai's avatar
      cachefiles: Drop superfluous readpages aops NULL check · db58465f
      Takashi Iwai authored
      After the recent actions to convert readpages aops to readahead, the
      NULL checks of readpages aops in cachefiles_read_or_alloc_page() may
      hit falsely.  More badly, it's an ASSERT() call, and this panics.
      
      Drop the superfluous NULL checks for fixing this regression.
      
      [DH: Note that cachefiles never actually used readpages, so this check was
       never actually necessary]
      
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=208883
      BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1175245
      Fixes: 9ae326a6
      
       ("CacheFiles: A cache that backs onto a mounted filesystem")
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      db58465f
    • Jakub Kicinski's avatar
      Merge tag 'linux-can-fixes-for-5.11-20210120' of... · 535d3159
      Jakub Kicinski authored
      
      Merge tag 'linux-can-fixes-for-5.11-20210120' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can
      
      Marc Kleine-Budde says:
      
      ====================
      linux-can-fixes-for-5.11-20210120
      
      All three patches are by Vincent Mailhol and fix a potential use after free bug
      in the CAN device infrastructure, the vxcan driver, and the peak_usk driver. In
      the TX-path the skb is used to read from after it was passed to the networking
      stack with netif_rx_ni().
      
      * tag 'linux-can-fixes-for-5.11-20210120' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can:
        can: peak_usb: fix use after free bugs
        can: vxcan: vxcan_xmit: fix use after free bug
        can: dev: can_restart: fix use after free bug
      ====================
      
      Link: https://lore.kernel.org/r/20210120125202.2187358-1-mkl@pengutronix.de
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      535d3159
    • Pan Bian's avatar
      net: systemport: free dev before on error path · 0c630a66
      Pan Bian authored
      On the error path, it should goto the error handling label to free
      allocated memory rather than directly return.
      
      Fixes: 31bc72d9
      
       ("net: systemport: fetch and use clock resources")
      Signed-off-by: default avatarPan Bian <bianpan2016@163.com>
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/20210120044423.1704-1-bianpan2016@163.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      0c630a66
    • Grant Grundler's avatar
      net: usb: cdc_ncm: don't spew notifications · de658a19
      Grant Grundler authored
      
      
      RTL8156 sends notifications about every 32ms.
      Only display/log notifications when something changes.
      
      This issue has been reported by others:
      	https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1832472
      	https://lkml.org/lkml/2020/8/27/1083
      
      ...
      [785962.779840] usb 1-1: new high-speed USB device number 5 using xhci_hcd
      [785962.929944] usb 1-1: New USB device found, idVendor=0bda, idProduct=8156, bcdDevice=30.00
      [785962.929949] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=6
      [785962.929952] usb 1-1: Product: USB 10/100/1G/2.5G LAN
      [785962.929954] usb 1-1: Manufacturer: Realtek
      [785962.929956] usb 1-1: SerialNumber: 000000001
      [785962.991755] usbcore: registered new interface driver cdc_ether
      [785963.017068] cdc_ncm 1-1:2.0: MAC-Address: 00:24:27:88:08:15
      [785963.017072] cdc_ncm 1-1:2.0: setting rx_max = 16384
      [785963.017169] cdc_ncm 1-1:2.0: setting tx_max = 16384
      [785963.017682] cdc_ncm 1-1:2.0 usb0: register 'cdc_ncm' at usb-0000:00:14.0-1, CDC NCM, 00:24:27:88:08:15
      [785963.019211] usbcore: registered new interface driver cdc_ncm
      [785963.023856] usbcore: registered new interface driver cdc_wdm
      [785963.025461] usbcore: registered new interface driver cdc_mbim
      [785963.038824] cdc_ncm 1-1:2.0 enx002427880815: renamed from usb0
      [785963.089586] cdc_ncm 1-1:2.0 enx002427880815: network connection: disconnected
      [785963.121673] cdc_ncm 1-1:2.0 enx002427880815: network connection: disconnected
      [785963.153682] cdc_ncm 1-1:2.0 enx002427880815: network connection: disconnected
      ...
      
      This is about 2KB per second and will overwrite all contents of a 1MB
      dmesg buffer in under 10 minutes rendering them useless for debugging
      many kernel problems.
      
      This is also an extra 180 MB/day in /var/logs (or 1GB per week) rendering
      the majority of those logs useless too.
      
      When the link is up (expected state), spew amount is >2x higher:
      ...
      [786139.600992] cdc_ncm 2-1:2.0 enx002427880815: network connection: connected
      [786139.632997] cdc_ncm 2-1:2.0 enx002427880815: 2500 mbit/s downlink 2500 mbit/s uplink
      [786139.665097] cdc_ncm 2-1:2.0 enx002427880815: network connection: connected
      [786139.697100] cdc_ncm 2-1:2.0 enx002427880815: 2500 mbit/s downlink 2500 mbit/s uplink
      [786139.729094] cdc_ncm 2-1:2.0 enx002427880815: network connection: connected
      [786139.761108] cdc_ncm 2-1:2.0 enx002427880815: 2500 mbit/s downlink 2500 mbit/s uplink
      ...
      
      Chrome OS cannot support RTL8156 until this is fixed.
      
      Signed-off-by: default avatarGrant Grundler <grundler@chromium.org>
      Reviewed-by: default avatarHayes Wang <hayeswang@realtek.com>
      Link: https://lore.kernel.org/r/20210120011208.3768105-1-grundler@chromium.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      de658a19
    • Alban Bedel's avatar
      net: mscc: ocelot: Fix multicast to the CPU port · 584b7cfc
      Alban Bedel authored
      Multicast entries in the MAC table use the high bits of the MAC
      address to encode the ports that should get the packets. But this port
      mask does not work for the CPU port, to receive these packets on the
      CPU port the MAC_CPU_COPY flag must be set.
      
      Because of this IPv6 was effectively not working because neighbor
      solicitations were never received. This was not apparent before commit
      9403c158
      
       (net: mscc: ocelot: support IPv4, IPv6 and plain Ethernet mdb
      entries) as the IPv6 entries were broken so all incoming IPv6
      multicast was then treated as unknown and flooded on all ports.
      
      To fix this problem rework the ocelot_mact_learn() to set the
      MAC_CPU_COPY flag when a multicast entry that target the CPU port is
      added. For this we have to read back the ports endcoded in the pseudo
      MAC address by the caller. It is not a very nice design but that avoid
      changing the callers and should make backporting easier.
      
      Signed-off-by: default avatarAlban Bedel <alban.bedel@aerq.com>
      Fixes: 9403c158
      
       ("net: mscc: ocelot: support IPv4, IPv6 and plain Ethernet mdb entries")
      Link: https://lore.kernel.org/r/20210119140638.203374-1-alban.bedel@aerq.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      584b7cfc
    • Kuniyuki Iwashima's avatar
      tcp: Fix potential use-after-free due to double kfree() · c89dffc7
      Kuniyuki Iwashima authored
      Receiving ACK with a valid SYN cookie, cookie_v4_check() allocates struct
      request_sock and then can allocate inet_rsk(req)->ireq_opt. After that,
      tcp_v4_syn_recv_sock() allocates struct sock and copies ireq_opt to
      inet_sk(sk)->inet_opt. Normally, tcp_v4_syn_recv_sock() inserts the full
      socket into ehash and sets NULL to ireq_opt. Otherwise,
      tcp_v4_syn_recv_sock() has to reset inet_opt by NULL and free the full
      socket.
      
      The commit 01770a16 ("tcp: fix race condition when creating child
      sockets from syncookies") added a new path, in which more than one cores
      create full sockets for the same SYN cookie. Currently, the core which
      loses the race frees the full socket without resetting inet_opt, resulting
      in that both sock_put() and reqsk_put() call kfree() for the same memory:
      
        sock_put
          sk_free
            __sk_free
              sk_destruct
                __sk_destruct
                  sk->sk_destruct/inet_sock_destruct
                    kfree(rcu_dereference_protected(inet->inet_opt, 1));
      
        reqsk_put
          reqsk_free
            __reqsk_free
              req->rsk_ops->destructor/tcp_v4_reqsk_destructor
                kfree(rcu_dereference_protected(inet_rsk(req)->ireq_opt, 1));
      
      Calling kmalloc() between the double kfree() can lead to use-after-free, so
      this patch fixes it by setting NULL to inet_opt before sock_put().
      
      As a side note, this kind of issue does not happen for IPv6. This is
      because tcp_v6_syn_recv_sock() clones both ipv6_opt and pktopts which
      correspond to ireq_opt in IPv4.
      
      Fixes: 01770a16
      
       ("tcp: fix race condition when creating child sockets from syncookies")
      CC: Ricardo Dias <rdias@singlestore.com>
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.co.jp>
      Reviewed-by: default avatarBenjamin Herrenschmidt <benh@amazon.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Link: https://lore.kernel.org/r/20210118055920.82516-1-kuniyu@amazon.co.jp
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      c89dffc7
    • Jakub Kicinski's avatar
      Merge https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf · b3741b43
      Jakub Kicinski authored
      
      
      Daniel Borkmann says:
      
      ====================
      pull-request: bpf 2021-01-20
      
      1) Fix wrong bpf_map_peek_elem_proto helper callback, from Mircea Cirjaliu.
      
      2) Fix signed_{sub,add32}_overflows type truncation, from Daniel Borkmann.
      
      3) Fix AF_XDP to also clear pools for inactive queues, from Maxim Mikityanskiy.
      
      * https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf:
        bpf: Fix signed_{sub,add32}_overflows type handling
        xsk: Clear pool even for inactive queues
        bpf: Fix helper bpf_map_peek_elem_proto pointing to wrong callback
      ====================
      
      Link: https://lore.kernel.org/r/20210120163439.8160-1-daniel@iogearbox.net
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      b3741b43
    • Daniel Borkmann's avatar
      bpf: Fix signed_{sub,add32}_overflows type handling · bc895e8b
      Daniel Borkmann authored
      Fix incorrect signed_{sub,add32}_overflows() input types (and a related buggy
      comment). It looks like this might have slipped in via copy/paste issue, also
      given prior to 3f50f132 ("bpf: Verifier, do explicit ALU32 bounds tracking")
      the signature of signed_sub_overflows() had s64 a and s64 b as its input args
      whereas now they are truncated to s32. Thus restore proper types. Also, the case
      of signed_add32_overflows() is not consistent to signed_sub32_overflows(). Both
      have s32 as inputs, therefore align the former.
      
      Fixes: 3f50f132
      
       ("bpf: Verifier, do explicit ALU32 bounds tracking")
      Reported-by: default avatarDe4dCr0w <sa516203@mail.ustc.edu.cn>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      bc895e8b
  5. Jan 20, 2021
    • Vincent Mailhol's avatar
      can: peak_usb: fix use after free bugs · 50aca891
      Vincent Mailhol authored
      After calling peak_usb_netif_rx_ni(skb), dereferencing skb is unsafe.
      Especially, the can_frame cf which aliases skb memory is accessed
      after the peak_usb_netif_rx_ni().
      
      Reordering the lines solves the issue.
      
      Fixes: 0a25e1f4
      
       ("can: peak_usb: add support for PEAK new CANFD USB adapters")
      Link: https://lore.kernel.org/r/20210120114137.200019-4-mailhol.vincent@wanadoo.fr
      Signed-off-by: default avatarVincent Mailhol <mailhol.vincent@wanadoo.fr>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      50aca891
    • Vincent Mailhol's avatar
      can: vxcan: vxcan_xmit: fix use after free bug · 75854cad
      Vincent Mailhol authored
      After calling netif_rx_ni(skb), dereferencing skb is unsafe.
      Especially, the canfd_frame cfd which aliases skb memory is accessed
      after the netif_rx_ni().
      
      Fixes: a8f820a3
      
       ("can: add Virtual CAN Tunnel driver (vxcan)")
      Link: https://lore.kernel.org/r/20210120114137.200019-3-mailhol.vincent@wanadoo.fr
      Signed-off-by: default avatarVincent Mailhol <mailhol.vincent@wanadoo.fr>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      75854cad
    • Vincent Mailhol's avatar
      can: dev: can_restart: fix use after free bug · 03f16c50
      Vincent Mailhol authored
      After calling netif_rx_ni(skb), dereferencing skb is unsafe.
      Especially, the can_frame cf which aliases skb memory is accessed
      after the netif_rx_ni() in:
            stats->rx_bytes += cf->len;
      
      Reordering the lines solves the issue.
      
      Fixes: 39549eef
      
       ("can: CAN Network device driver and Netlink interface")
      Link: https://lore.kernel.org/r/20210120114137.200019-2-mailhol.vincent@wanadoo.fr
      Signed-off-by: default avatarVincent Mailhol <mailhol.vincent@wanadoo.fr>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      03f16c50
    • Yuchung Cheng's avatar
      tcp: fix TCP socket rehash stats mis-accounting · 9c30ae83
      Yuchung Cheng authored
      The previous commit 32efcc06 ("tcp: export count for rehash attempts")
      would mis-account rehashing SNMP and socket stats:
      
        a. During handshake of an active open, only counts the first
           SYN timeout
      
        b. After handshake of passive and active open, stop updating
           after (roughly) TCP_RETRIES1 recurring RTOs
      
        c. After the socket aborts, over count timeout_rehash by 1
      
      This patch fixes this by checking the rehash result from sk_rethink_txhash.
      
      Fixes: 32efcc06
      
       ("tcp: export count for rehash attempts")
      Signed-off-by: default avatarYuchung Cheng <ycheng@google.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarNeal Cardwell <ncardwell@google.com>
      Link: https://lore.kernel.org/r/20210119192619.1848270-1-ycheng@google.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      9c30ae83
    • Dan Carpenter's avatar
      net: dsa: b53: fix an off by one in checking "vlan->vid" · 8e4052c3
      Dan Carpenter authored
      The > comparison should be >= to prevent accessing one element beyond
      the end of the dev->vlans[] array in the caller function, b53_vlan_add().
      The "dev->vlans" array is allocated in the b53_switch_init() function
      and it has "dev->num_vlans" elements.
      
      Fixes: a2482d2c
      
       ("net: dsa: b53: Plug in VLAN support")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/YAbxI97Dl/pmBy5V@mwanda
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      8e4052c3
    • Eric Dumazet's avatar
      tcp: do not mess with cloned skbs in tcp_add_backlog() · b160c285
      Eric Dumazet authored
      Heiner Kallweit reported that some skbs were sent with
      the following invalid GSO properties :
      - gso_size > 0
      - gso_type == 0
      
      This was triggerring a WARN_ON_ONCE() in rtl8169_tso_csum_v2.
      
      Juerg Haefliger was able to reproduce a similar issue using
      a lan78xx NIC and a workload mixing TCP incoming traffic
      and forwarded packets.
      
      The problem is that tcp_add_backlog() is writing
      over gso_segs and gso_size even if the incoming packet will not
      be coalesced to the backlog tail packet.
      
      While skb_try_coalesce() would bail out if tail packet is cloned,
      this overwriting would lead to corruptions of other packets
      cooked by lan78xx, sharing a common super-packet.
      
      The strategy used by lan78xx is to use a big skb, and split
      it into all received packets using skb_clone() to avoid copies.
      The drawback of this strategy is that all the small skb share a common
      struct skb_shared_info.
      
      This patch rewrites TCP gso_size/gso_segs handling to only
      happen on the tail skb, since skb_try_coalesce() made sure
      it was not cloned.
      
      Fixes: 4f693b55
      
       ("tcp: implement coalescing on backlog queue")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Bisected-by: default avatarJuerg Haefliger <juergh@canonical.com>
      Tested-by: default avatarJuerg Haefliger <juergh@canonical.com>
      Reported-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=209423
      Link: https://lore.kernel.org/r/20210119164900.766957-1-eric.dumazet@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      b160c285
    • Hangbin Liu's avatar
      selftests: net: fib_tests: remove duplicate log test · fd23d2dc
      Hangbin Liu authored
      
      
      The previous test added an address with a specified metric and check if
      correspond route was created. I somehow added two logs for the same
      test. Remove the duplicated one.
      
      Reported-by: default avatarAntoine Tenart <atenart@redhat.com>
      Fixes: 0d29169a
      
       ("selftests/net/fib_tests: update addr_metric_test for peer route testing")
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Link: https://lore.kernel.org/r/20210119025930.2810532-1-liuhangbin@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      fd23d2dc
    • Bongsu Jeon's avatar
      net: nfc: nci: fix the wrong NCI_CORE_INIT parameters · 4964e5a1
      Bongsu Jeon authored
      Fix the code because NCI_CORE_INIT_CMD includes two parameters in NCI2.0
      but there is no parameters in NCI1.x.
      
      Fixes: bcd684aa
      
       ("net/nfc/nci: Support NCI 2.x initial sequence")
      Signed-off-by: default avatarBongsu Jeon <bongsu.jeon@samsung.com>
      Link: https://lore.kernel.org/r/20210118205522.317087-1-bongsu.jeon@samsung.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      4964e5a1
    • Geert Uytterhoeven's avatar
      sh_eth: Fix power down vs. is_opened flag ordering · f6a2e94b
      Geert Uytterhoeven authored
      sh_eth_close() does a synchronous power down of the device before
      marking it closed.  Revert the order, to make sure the device is never
      marked opened while suspended.
      
      While at it, use pm_runtime_put() instead of pm_runtime_put_sync(), as
      there is no reason to do a synchronous power down.
      
      Fixes: 7fa2955f
      
       ("sh_eth: Fix sleeping function called from invalid context")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: default avatarSergei Shtylyov <sergei.shtylyov@gmail.com>
      Reviewed-by: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
      Link: https://lore.kernel.org/r/20210118150812.796791-1-geert+renesas@glider.be
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      f6a2e94b
    • Tariq Toukan's avatar
      net: Disable NETIF_F_HW_TLS_RX when RXCSUM is disabled · a3eb4e9d
      Tariq Toukan authored
      With NETIF_F_HW_TLS_RX packets are decrypted in HW. This cannot be
      logically done when RXCSUM offload is off.
      
      Fixes: 14136564
      
       ("net: Add TLS RX offload feature")
      Signed-off-by: default avatarTariq Toukan <tariqt@nvidia.com>
      Reviewed-by: default avatarBoris Pismenny <borisp@nvidia.com>
      Link: https://lore.kernel.org/r/20210117151538.9411-1-tariqt@nvidia.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      a3eb4e9d
    • Jakub Kicinski's avatar
      Merge branch 'ipv4-ensure-ecn-bits-don-t-influence-source-address-validation' · 2565ff4e
      Jakub Kicinski authored
      
      
      Guillaume Nault says:
      
      ====================
      ipv4: Ensure ECN bits don't influence source address validation
      
      Functions that end up calling fib_table_lookup() should clear the ECN
      bits from the TOS, otherwise ECT(0) and ECT(1) packets can be treated
      differently.
      
      Most functions already clear the ECN bits, but there are a few cases
      where this is not done. This series only fixes the ones related to
      source address validation.
      ====================
      
      Link: https://lore.kernel.org/r/cover.1610790904.git.gnault@redhat.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      2565ff4e
    • Guillaume Nault's avatar
      netfilter: rpfilter: mask ecn bits before fib lookup · 2e5a6266
      Guillaume Nault authored
      RT_TOS() only masks one of the two ECN bits. Therefore rpfilter_mt()
      treats Not-ECT or ECT(1) packets in a different way than those with
      ECT(0) or CE.
      
      Reproducer:
      
        Create two netns, connected with a veth:
        $ ip netns add ns0
        $ ip netns add ns1
        $ ip link add name veth01 netns ns0 type veth peer name veth10 netns ns1
        $ ip -netns ns0 link set dev veth01 up
        $ ip -netns ns1 link set dev veth10 up
        $ ip -netns ns0 address add 192.0.2.10/32 dev veth01
        $ ip -netns ns1 address add 192.0.2.11/32 dev veth10
      
        Add a route to ns1 in ns0:
        $ ip -netns ns0 route add 192.0.2.11/32 dev veth01
      
        In ns1, only packets with TOS 4 can be routed to ns0:
        $ ip -netns ns1 route add 192.0.2.10/32 tos 4 dev veth10
      
        Ping from ns0 to ns1 works regardless of the ECN bits, as long as TOS
        is 4:
        $ ip netns exec ns0 ping -Q 4 192.0.2.11   # TOS 4, Not-ECT
          ... 0% packet loss ...
        $ ip netns exec ns0 ping -Q 5 192.0.2.11   # TOS 4, ECT(1)
          ... 0% packet loss ...
        $ ip netns exec ns0 ping -Q 6 192.0.2.11   # TOS 4, ECT(0)
          ... 0% packet loss ...
        $ ip netns exec ns0 ping -Q 7 192.0.2.11   # TOS 4, CE
          ... 0% packet loss ...
      
        Now use iptable's rpfilter module in ns1:
        $ ip netns exec ns1 iptables-legacy -t raw -A PREROUTING -m rpfilter --invert -j DROP
      
        Not-ECT and ECT(1) packets still pass:
        $ ip netns exec ns0 ping -Q 4 192.0.2.11   # TOS 4, Not-ECT
          ... 0% packet loss ...
        $ ip netns exec ns0 ping -Q 5 192.0.2.11   # TOS 4, ECT(1)
          ... 0% packet loss ...
      
        But ECT(0) and ECN packets are dropped:
        $ ip netns exec ns0 ping -Q 6 192.0.2.11   # TOS 4, ECT(0)
          ... 100% packet loss ...
        $ ip netns exec ns0 ping -Q 7 192.0.2.11   # TOS 4, CE
          ... 100% packet loss ...
      
      After this patch, rpfilter doesn't drop ECT(0) and CE packets anymore.
      
      Fixes: 8f97339d
      
       ("netfilter: add ipv4 reverse path filter match")
      Signed-off-by: default avatarGuillaume Nault <gnault@redhat.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      2e5a6266
    • Guillaume Nault's avatar
      udp: mask TOS bits in udp_v4_early_demux() · 8d2b51b0
      Guillaume Nault authored
      udp_v4_early_demux() is the only function that calls
      ip_mc_validate_source() with a TOS that hasn't been masked with
      IPTOS_RT_MASK.
      
      This results in different behaviours for incoming multicast UDPv4
      packets, depending on if ip_mc_validate_source() is called from the
      early-demux path (udp_v4_early_demux) or from the regular input path
      (ip_route_input_noref).
      
      ECN would normally not be used with UDP multicast packets, so the
      practical consequences should be limited on that side. However,
      IPTOS_RT_MASK is used to also masks the TOS' high order bits, to align
      with the non-early-demux path behaviour.
      
      Reproducer:
      
        Setup two netns, connected with veth:
        $ ip netns add ns0
        $ ip netns add ns1
        $ ip -netns ns0 link set dev lo up
        $ ip -netns ns1 link set dev lo up
        $ ip link add name veth01 netns ns0 type veth peer name veth10 netns ns1
        $ ip -netns ns0 link set dev veth01 up
        $ ip -netns ns1 link set dev veth10 up
        $ ip -netns ns0 address add 192.0.2.10 peer 192.0.2.11/32 dev veth01
        $ ip -netns ns1 address add 192.0.2.11 peer 192.0.2.10/32 dev veth10
      
        In ns0, add route to multicast address 224.0.2.0/24 using source
        address 198.51.100.10:
        $ ip -netns ns0 address add 198.51.100.10/32 dev lo
        $ ip -netns ns0 route add 224.0.2.0/24 dev veth01 src 198.51.100.10
      
        In ns1, define route to 198.51.100.10, only for packets with TOS 4:
        $ ip -netns ns1 route add 198.51.100.10/32 tos 4 dev veth10
      
        Also activate rp_filter in ns1, so that incoming packets not matching
        the above route get dropped:
        $ ip netns exec ns1 sysctl -wq net.ipv4.conf.veth10.rp_filter=1
      
        Now try to receive packets on 224.0.2.11:
        $ ip netns exec ns1 socat UDP-RECVFROM:1111,ip-add-membership=224.0.2.11:veth10,ignoreeof -
      
        In ns0, send packet to 224.0.2.11 with TOS 4 and ECT(0) (that is,
        tos 6 for socat):
        $ echo test0 | ip netns exec ns0 socat - UDP-DATAGRAM:224.0.2.11:1111,bind=:1111,tos=6
      
        The "test0" message is properly received by socat in ns1, because
        early-demux has no cached dst to use, so source address validation
        is done by ip_route_input_mc(), which receives a TOS that has the
        ECN bits masked.
      
        Now send another packet to 224.0.2.11, still with TOS 4 and ECT(0):
        $ echo test1 | ip netns exec ns0 socat - UDP-DATAGRAM:224.0.2.11:1111,bind=:1111,tos=6
      
        The "test1" message isn't received by socat in ns1, because, now,
        early-demux has a cached dst to use and calls ip_mc_validate_source()
        immediately, without masking the ECN bits.
      
      Fixes: bc044e8d
      
       ("udp: perform source validation for mcast early demux")
      Signed-off-by: default avatarGuillaume Nault <gnault@redhat.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      8d2b51b0