1. 15 Apr, 2020 9 commits
    • Vladimir Oltean's avatar
      net: mscc: ocelot: fix untagged packet drops when enslaving to vlan aware bridge · 87b0f983
      Vladimir Oltean authored
      To rehash a previous explanation given in commit 1c44ce56 ("net:
      mscc: ocelot: fix vlan_filtering when enslaving to bridge before link is
      up"), the switch driver operates the in a mode where a single VLAN can
      be transmitted as untagged on a particular egress port. That is the
      "native VLAN on trunk port" use case.
      
      The configuration for this native VLAN is driven in 2 ways:
       - Set the egress port rewriter to strip the VLAN tag for the native
         VID (as it is egress-untagged, after all).
       - Configure the ingress port to drop untagged and priority-tagged
         traffic, if there is no native VLAN. The intention of this setting is
         that a trunk port with no native VLAN should not accept untagged
         traffic.
      
      Since both of the above configurations for the native VLAN should only
      be done if VLAN awareness is requested, they are actually done from the
      ocelot_port_vlan_filtering function, after the basic procedure of
      toggling the VLAN awareness flag of the port.
      
      But there's a problem with that simplistic approach: we are trying to
      juggle with 2 independent variables from a single function:
       - Native VLAN of the port - its value is held in port->vid.
       - VLAN awareness state of the port - currently there are some issues
         here, more on that later*.
      The actual problem can be seen when enslaving the switch ports to a VLAN
      filtering bridge:
       0. The driver configures a pvid of zero for each port, when in
          standalone mode. While the bridge configures a default_pvid of 1 for
          each port that gets added as a slave to it.
       1. The bridge calls ocelot_port_vlan_filtering with vlan_aware=true.
          The VLAN-filtering-dependent portion of the native VLAN
          configuration is done, considering that the native VLAN is 0.
       2. The bridge calls ocelot_vlan_add with vid=1, pvid=true,
          untagged=true. The native VLAN changes to 1 (change which gets
          propagated to hardware).
       3. ??? - nobody calls ocelot_port_vlan_filtering again, to reapply the
          VLAN-filtering-dependent portion of the native VLAN configuration,
          for the new native VLAN of 1. One can notice that after toggling "ip
          link set dev br0 type bridge vlan_filtering 0 && ip link set dev br0
          type bridge vlan_filtering 1", the new native VLAN finally makes it
          through and untagged traffic finally starts flowing again. But
          obviously that shouldn't be needed.
      
      So it is clear that 2 independent variables need to both re-trigger the
      native VLAN configuration. So we introduce the second variable as
      ocelot_port->vlan_aware.
      
      *Actually both the DSA Felix driver and the Ocelot driver already had
      each its own variable:
       - Ocelot: ocelot_port_private->vlan_aware
       - Felix: dsa_port->vlan_filtering
      but the common Ocelot library needs to work with a single, common,
      variable, so there is some refactoring done to move the vlan_aware
      property from the private structure into the common ocelot_port
      structure.
      
      Fixes: 97bb69e1 ("net: mscc: ocelot: break apart ocelot_vlan_port_apply")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      87b0f983
    • David S. Miller's avatar
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf · 78b87711
      David S. Miller authored
      Daniel Borkmann says:
      
      ====================
      pull-request: bpf 2020-04-15
      
      The following pull-request contains BPF updates for your *net* tree.
      
      We've added 10 non-merge commits during the last 3 day(s) which contain
      a total of 11 files changed, 238 insertions(+), 95 deletions(-).
      
      The main changes are:
      
      1) Fix offset overflow for BPF_MEM BPF_DW insn mapping on arm32 JIT,
         from Luke Nelson and Xi Wang.
      
      2) Prevent mprotect() to make frozen & mmap()'ed BPF map writeable
         again, from Andrii Nakryiko and Jann Horn.
      
      3) Fix type of old_fd in bpf_xdp_set_link_opts to int in libbpf and add
         selftests, from Toke Høiland-Jørgensen.
      
      4) Fix AF_XDP to check that headroom cannot be larger than the available
         space in the chunk, from Magnus Karlsson.
      
      5) Fix reset of XDP prog when expected_fd is set, from David Ahern.
      
      6) Fix a segfault in bpftool's struct_ops command when BTF is not
         available, from Daniel T. Lee.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      78b87711
    • David S. Miller's avatar
      Merge tag 'mac80211-for-net-2020-04-15' of... · 6058ee09
      David S. Miller authored
      Merge tag 'mac80211-for-net-2020-04-15' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211
      
      Johannes Berg says:
      
      ====================
      A couple of fixes:
       * FTM responder policy netlink validation fix
         (but the only user validates again later)
       * kernel-doc fixes
       * a fix for a race in mac80211 radio registration vs. userspace
       * a mesh channel switch fix
       * a fix for a syzbot reported kasprintf() issue
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6058ee09
    • Toke Høiland-Jørgensen's avatar
      selftests/bpf: Check for correct program attach/detach in xdp_attach test · c6c11152
      Toke Høiland-Jørgensen authored
      David Ahern noticed that there was a bug in the EXPECTED_FD code so
      programs did not get detached properly when that parameter was supplied.
      This case was not included in the xdp_attach tests; so let's add it to be
      sure that such a bug does not sneak back in down.
      
      Fixes: 87854a0b ("selftests/bpf: Add tests for attaching XDP programs")
      Reported-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20200414145025.182163-2-toke@redhat.com
      c6c11152
    • Toke Høiland-Jørgensen's avatar
      libbpf: Fix type of old_fd in bpf_xdp_set_link_opts · 49b452c3
      Toke Høiland-Jørgensen authored
      The 'old_fd' parameter used for atomic replacement of XDP programs is
      supposed to be an FD, but was left as a u32 from an earlier iteration of
      the patch that added it. It was converted to an int when read, so things
      worked correctly even with negative values, but better change the
      definition to correctly reflect the intention.
      
      Fixes: bd5ca3ef ("libbpf: Add function to set link XDP fd while specifying old program")
      Reported-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarDavid Ahern <dsahern@gmail.com>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20200414145025.182163-1-toke@redhat.com
      49b452c3
    • Andrii Nakryiko's avatar
      libbpf: Always specify expected_attach_type on program load if supported · 25498a19
      Andrii Nakryiko authored
      For some types of BPF programs that utilize expected_attach_type, libbpf won't
      set load_attr.expected_attach_type, even if expected_attach_type is known from
      section definition. This was done to preserve backwards compatibility with old
      kernels that didn't recognize expected_attach_type attribute yet (which was
      added in 5e43f899 ("bpf: Check attach type at prog load time"). But this
      is problematic for some BPF programs that utilize newer features that require
      kernel to know specific expected_attach_type (e.g., extended set of return
      codes for cgroup_skb/egress programs).
      
      This patch makes libbpf specify expected_attach_type by default, but also
      detect support for this field in kernel and not set it during program load.
      This allows to have a good metadata for bpf_program
      (e.g., bpf_program__get_extected_attach_type()), but still work with old
      kernels (for cases where it can work at all).
      
      Additionally, due to expected_attach_type being always set for recognized
      program types, bpf_program__attach_cgroup doesn't have to do extra checks to
      determine correct attach type, so remove that additional logic.
      
      Also adjust section_names selftest to account for this change.
      
      More detailed discussion can be found in [0].
      
        [0] https://lore.kernel.org/bpf/20200412003604.GA15986@rdna-mbp.dhcp.thefacebook.com/
      
      Fixes: 5cf1e914 ("bpf: cgroup inet skb programs can return 0 to 3")
      Fixes: 5e43f899 ("bpf: Check attach type at prog load time")
      Reported-by: default avatarAndrey Ignatov <rdna@fb.com>
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Acked-by: default avatarAndrey Ignatov <rdna@fb.com>
      Link: https://lore.kernel.org/bpf/20200414182645.1368174-1-andriin@fb.com
      25498a19
    • Magnus Karlsson's avatar
      xsk: Add missing check on user supplied headroom size · 99e3a236
      Magnus Karlsson authored
      Add a check that the headroom cannot be larger than the available
      space in the chunk. In the current code, a malicious user can set the
      headroom to a value larger than the chunk size minus the fixed XDP
      headroom. That way packets with a length larger than the supported
      size in the umem could get accepted and result in an out-of-bounds
      write.
      
      Fixes: c0c77d8f ("xsk: add user memory registration support sockopt")
      Reported-by: default avatarBui Quang Minh <minhquangbui99@gmail.com>
      Signed-off-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=207225
      Link: https://lore.kernel.org/bpf/1586849715-23490-1-git-send-email-magnus.karlsson@intel.com
      99e3a236
    • Tamizh chelvam's avatar
      mac80211: fix channel switch trigger from unknown mesh peer · 93e2d04a
      Tamizh chelvam authored
      Previously mesh channel switch happens if beacon contains
      CSA IE without checking the mesh peer info. Due to that
      channel switch happens even if the beacon is not from
      its own mesh peer. Fixing that by checking if the CSA
      originated from the same mesh network before proceeding
      for channel switch.
      Signed-off-by: default avatarTamizh chelvam <tamizhr@codeaurora.org>
      Link: https://lore.kernel.org/r/1585403604-29274-1-git-send-email-tamizhr@codeaurora.orgSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      93e2d04a
    • Sumit Garg's avatar
      mac80211: fix race in ieee80211_register_hw() · 52e04b4c
      Sumit Garg authored
      A race condition leading to a kernel crash is observed during invocation
      of ieee80211_register_hw() on a dragonboard410c device having wcn36xx
      driver built as a loadable module along with a wifi manager in user-space
      waiting for a wifi device (wlanX) to be active.
      
      Sequence diagram for a particular kernel crash scenario:
      
          user-space  ieee80211_register_hw()  ieee80211_tasklet_handler()
          ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
             |                    |                 |
             |<---phy0----wiphy_register()          |
             |-----iwd if_add---->|                 |
             |                    |<---IRQ----(RX packet)
             |              Kernel crash            |
             |              due to unallocated      |
             |              workqueue.              |
             |                    |                 |
             |       alloc_ordered_workqueue()      |
             |                    |                 |
             |              Misc wiphy init.        |
             |                    |                 |
             |            ieee80211_if_add()        |
             |                    |                 |
      
      As evident from above sequence diagram, this race condition isn't specific
      to a particular wifi driver but rather the initialization sequence in
      ieee80211_register_hw() needs to be fixed. So re-order the initialization
      sequence and the updated sequence diagram would look like:
      
          user-space  ieee80211_register_hw()  ieee80211_tasklet_handler()
          ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
             |                    |                 |
             |       alloc_ordered_workqueue()      |
             |                    |                 |
             |              Misc wiphy init.        |
             |                    |                 |
             |<---phy0----wiphy_register()          |
             |-----iwd if_add---->|                 |
             |                    |<---IRQ----(RX packet)
             |                    |                 |
             |            ieee80211_if_add()        |
             |                    |                 |
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSumit Garg <sumit.garg@linaro.org>
      Link: https://lore.kernel.org/r/1586254255-28713-1-git-send-email-sumit.garg@linaro.org
      [Johannes: fix rtnl imbalances]
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      52e04b4c
  2. 14 Apr, 2020 24 commits
  3. 13 Apr, 2020 3 commits
  4. 12 Apr, 2020 3 commits
  5. 11 Apr, 2020 1 commit
    • Clemens Gruber's avatar
      net: phy: marvell: Fix pause frame negotiation · 3b72f84f
      Clemens Gruber authored
      The negotiation of flow control / pause frame modes was broken since
      commit fcf1f59a ("net: phy: marvell: rearrange to use
      genphy_read_lpa()") moved the setting of phydev->duplex below the
      phy_resolve_aneg_pause call. Due to a check of DUPLEX_FULL in that
      function, phydev->pause was no longer set.
      
      Fix it by moving the parsing of the status variable before the blocks
      dealing with the pause frames.
      
      As the Marvell 88E1510 datasheet does not specify the timing between the
      link status and the "Speed and Duplex Resolved" bit, we have to force
      the link down as long as the resolved bit is not set, to avoid reporting
      link up before we even have valid Speed/Duplex.
      
      Tested with a Marvell 88E1510 (RGMII to Copper/1000Base-T)
      
      Fixes: fcf1f59a ("net: phy: marvell: rearrange to use genphy_read_lpa()")
      Signed-off-by: default avatarClemens Gruber <clemens.gruber@pqgruber.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      3b72f84f