Skip to content
Permalink
Oleksandr-Mazu…
Switch branches/tags

Commits on May 12, 2021

  1. net: core: devlink: add port_params_ops for devlink port parameters a…

    …ltering
    
    I'd like to discuss a possibility of handling devlink port parameters
    with devlink port pointer supplied.
    
    Current design makes it impossible to distinguish which port's parameter
    should get altered (set) or retrieved (get) whenever there's a single
    parameter registered within a few ports.
    
    This patch aims to show how this can be changed:
      - introduce structure port_params_ops that has callbacks for
        get/set/validate;
      - if devlink has registered port_params_ops, then upon every devlink
        port parameter get/set call invoke port parameters callback
    
    Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
    Suggested-by: Vadym Kochan <vadym.kochan@plvision.eu>
    --
    V2:
      1) devlink:
           - add commentary description over devlink_port_param_ops struct.
           - add port param ops 'set' usage.
           - remove WARN_ON upon registering devlink params in case of
             get/set not set.
      2) netdevsim:
           - dynamically allocate port params, as well as their values.
           - add base / max values for port params and devlink
             params enums to ease-out iteration over them.
           - separate devlink port params IDs and devlink param IDs.
           - add statically allocated devlink port params array.
    Oleksandr Mazur authored and intel-lab-lkp committed May 12, 2021

Commits on May 11, 2021

  1. net: ipa: memory region array is variable size

    IPA configuration data includes an array of memory region
    descriptors.  That was a fixed-size array at one time, but
    at some point we started defining it such that it was only
    as big as required for a given platform.  The actual number
    of entries in the array is recorded in the configuration data
    along with the array.
    
    A loop in ipa_mem_config() still assumes the array has entries
    for all defined memory region IDs.  As a result, this loop can
    go past the end of the actual array and attempt to write
    "canary" values based on nonsensical data.
    
    Fix this, by stashing the number of entries in the array, and
    using that rather than IPA_MEM_COUNT in the initialization loop
    found in ipa_mem_config().
    
    The only remaining use of IPA_MEM_COUNT is in a validation check
    to ensure configuration data doesn't have too many entries.
    That's fine for now.
    
    Fixes: 3128aae ("net: ipa: redefine struct ipa_mem_data")
    Signed-off-by: Alex Elder <elder@linaro.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    alexelder authored and davem330 committed May 11, 2021
  2. ionic: fix ptp support config breakage

    When IONIC=y and PTP_1588_CLOCK=m were set in the .config file
    the driver link failed with undefined references.
    
    We add the dependancy
    	depends on PTP_1588_CLOCK || !PTP_1588_CLOCK
    to clear this up.
    
    If PTP_1588_CLOCK=m, the depends limits IONIC to =m (or disabled).
    If PTP_1588_CLOCK is disabled, IONIC can be any of y/m/n.
    
    Fixes: 61db421 ("ionic: link in the new hw timestamp code")
    Reported-by: kernel test robot <lkp@intel.com>
    Cc: Jakub Kicinski <kuba@kernel.org>
    Cc: Randy Dunlap <rdunlap@infradead.org>
    Cc: Allen Hubbe <allenbh@pensando.io>
    Signed-off-by: Shannon Nelson <snelson@pensando.io>
    Acked-by: Randy Dunlap <rdunlap@infradead.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    emusln authored and davem330 committed May 11, 2021
  3. mptcp: fix data stream corruption

    Maxim reported several issues when forcing a TCP transparent proxy
    to use the MPTCP protocol for the inbound connections. He also
    provided a clean reproducer.
    
    The problem boils down to 'mptcp_frag_can_collapse_to()' assuming
    that only MPTCP will use the given page_frag.
    
    If others - e.g. the plain TCP protocol - allocate page fragments,
    we can end-up re-using already allocated memory for mptcp_data_frag.
    
    Fix the issue ensuring that the to-be-expanded data fragment is
    located at the current page frag end.
    
    v1 -> v2:
     - added missing fixes tag (Mat)
    
    Closes: multipath-tcp/mptcp_net-next#178
    Reported-and-tested-by: Maxim Galaganov <max@internet.ru>
    Fixes: 18b683b ("mptcp: queue data for mptcp level retransmission")
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Paolo Abeni authored and davem330 committed May 11, 2021
  4. Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf

    Daniel Borkmann says:
    
    ====================
    pull-request: bpf 2021-05-11
    
    The following pull-request contains BPF updates for your *net* tree.
    
    We've added 13 non-merge commits during the last 8 day(s) which contain
    a total of 21 files changed, 817 insertions(+), 382 deletions(-).
    
    The main changes are:
    
    1) Fix multiple ringbuf bugs in particular to prevent writable mmap of
       read-only pages, from Andrii Nakryiko & Thadeu Lima de Souza Cascardo.
    
    2) Fix verifier alu32 known-const subregister bound tracking for bitwise
       operations and/or/xor, from Daniel Borkmann.
    
    3) Reject trampoline attachment for functions with variable arguments,
       and also add a deny list of other forbidden functions, from Jiri Olsa.
    
    4) Fix nested bpf_bprintf_prepare() calls used by various helpers by
       switching to per-CPU buffers, from Florent Revest.
    
    5) Fix kernel compilation with BTF debug info on ppc64 due to pahole
       missing TCP-CC functions like cubictcp_init, from Martin KaFai Lau.
    
    6) Add a kconfig entry to provide an option to disallow unprivileged
       BPF by default, from Daniel Borkmann.
    
    7) Fix libbpf compilation for older libelf when GELF_ST_VISIBILITY()
       macro is not available, from Arnaldo Carvalho de Melo.
    
    8) Migrate test_tc_redirect to test_progs framework as prep work
       for upcoming skb_change_head() fix & selftest, from Jussi Maki.
    
    9) Fix a libbpf segfault in add_dummy_ksym_var() if BTF is not
       present, from Ian Rogers.
    
    10) Fix tx_only micro-benchmark in xdpsock BPF sample with proper frame
        size, from Magnus Karlsson.
    ====================
    
    Signed-off-by: David S. Miller <davem@davemloft.net>
    davem330 committed May 11, 2021
  5. Merge tag 'mac80211-for-net-2021-05-11' of git://git.kernel.org/pub/s…

    …cm/linux/kernel/git/jberg/mac80211
    
    Johannes Berg says:
    
    ====================
    pull-request: mac80211 2021-05-11
    
    So exciting times, for the first pull request for fixes I
    have a bunch of security things that have been under embargo
    for a while - see more details in the tag below, and at the
    patch posting message I linked to.
    
    I organized with Kalle to just have a single set of fixes
    for mac80211 and ath10k/ath11k, we don't know about any of
    the other vendors (the mac80211 + already released firmware
    is sufficient to fix iwlwifi.)
    
    Please pull and let me know if there's any problem.
    
    Several security issues in the 802.11 implementations were found by
    Mathy Vanhoef (New York University Abu Dhabi), and this contains the
    fixes developed for mac80211 and specifically Qualcomm drivers, I'm
    sending this together (as agreed with Kalle) to have just a single
    set of patches for now. We don't know about other vendors though.
    
    More details in the patch posting:
    https://lore.kernel.org/r/20210511180259.159598-1-johannes@sipsolutions.net
    ====================
    
    Signed-off-by: David S. Miller <davem@davemloft.net>
    davem330 committed May 11, 2021
  6. net: stmmac: Fix MAC WoL not working if PHY does not support WoL

    Both get and set WoL will check device_can_wakeup(), if MAC supports PMT, it
    will set device wakeup capability. After commit 1d8e5b0 ("net: stmmac:
    Support WOL with phy"), device wakeup capability will be overwrite in
    stmmac_init_phy() according to phy's Wol feature. If phy doesn't support WoL,
    then MAC will lose wakeup capability. To fix this issue, only overwrite device
    wakeup capability when MAC doesn't support PMT.
    
    For STMMAC now driver checks MAC's WoL capability if MAC supports PMT, if
    not support, driver will check PHY's WoL capability.
    
    Fixes: 1d8e5b0 ("net: stmmac: Support WOL with phy")
    Reviewed-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
    Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Joakim Zhang authored and davem330 committed May 11, 2021
  7. bpf: Limit static tcp-cc functions in the .BTF_ids list to x86

    During the discussion in [0]. It was pointed out that static functions
    in ppc64 is prefixed with ".". For example, the 'readelf -s vmlinux.ppc':
    
      89326: c000000001383280    24 NOTYPE  LOCAL  DEFAULT   31 cubictcp_init
      89327: c000000000c97c50   168 FUNC    LOCAL  DEFAULT    2 .cubictcp_init
    
    The one with FUNC type is ".cubictcp_init" instead of "cubictcp_init".
    The "." seems to be done by arch/powerpc/include/asm/ppc_asm.h.
    
    This caused that pahole cannot generate the BTF for these tcp-cc kernel
    functions because pahole only captures the FUNC type and "cubictcp_init"
    is not. It then failed the kernel compilation in ppc64.
    
    This behavior is only reported in ppc64 so far. I tried arm64, s390,
    and sparc64 and did not observe this "." prefix and NOTYPE behavior.
    
    Since the kfunc call is only supported in the x86_64 and x86_32 JIT,
    this patch limits those tcp-cc functions to x86 only to avoid unnecessary
    compilation issue in other ARCHs. In the future, we can examine if it
    is better to change all those functions from static to extern.
    
      [0] https://lore.kernel.org/bpf/4e051459-8532-7b61-c815-f3435767f8a0@kernel.org/
    
    Fixes: e78aea8 ("bpf: tcp: Put some tcp cong functions in allowlist for bpf-tcp-cc")
    Signed-off-by: Martin KaFai Lau <kafai@fb.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Cc: Michal Suchánek <msuchanek@suse.de>
    Cc: Jiri Slaby <jslaby@suse.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Link: https://lore.kernel.org/bpf/20210508005011.3863757-1-kafai@fb.com
    iamkafai authored and borkmann committed May 11, 2021
  8. selftests/bpf: Rewrite test_tc_redirect.sh as prog_tests/tc_redirect.c

    As discussed in [0], this ports test_tc_redirect.sh to the test_progs
    framework and removes the old test.
    
    This makes it more in line with rest of the tests and makes it possible
    to run this test case with vmtest.sh and under the bpf CI.
    
    The upcoming skb_change_head() helper fix in [0] is depending on it and
    extending the test case to redirect a packet from L3 device to veth.
    
      [0] https://lore.kernel.org/bpf/20210427135550.807355-1-joamaki@gmail.com
    
    Signed-off-by: Jussi Maki <joamaki@gmail.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Link: https://lore.kernel.org/bpf/20210505085925.783985-1-joamaki@gmail.com
    joamaki authored and borkmann committed May 11, 2021
  9. libbpf: Provide GELF_ST_VISIBILITY() define for older libelf

    Where that macro isn't available.
    
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Link: https://lore.kernel.org/bpf/YJaspEh0qZr4LYOc@kernel.org
    acmel authored and borkmann committed May 11, 2021
  10. bpf: Fix nested bpf_bprintf_prepare with more per-cpu buffers

    The bpf_seq_printf, bpf_trace_printk and bpf_snprintf helpers share one
    per-cpu buffer that they use to store temporary data (arguments to
    bprintf). They "get" that buffer with try_get_fmt_tmp_buf and "put" it
    by the end of their scope with bpf_bprintf_cleanup.
    
    If one of these helpers gets called within the scope of one of these
    helpers, for example: a first bpf program gets called, uses
    bpf_trace_printk which calls raw_spin_lock_irqsave which is traced by
    another bpf program that calls bpf_snprintf, then the second "get"
    fails. Essentially, these helpers are not re-entrant. They would return
    -EBUSY and print a warning message once.
    
    This patch triples the number of bprintf buffers to allow three levels
    of nesting. This is very similar to what was done for tracepoints in
    "9594dc3c7e7 bpf: fix nested bpf tracepoints with per-cpu data"
    
    Fixes: d9c9e4d ("bpf: Factorize bpf_trace_printk and bpf_seq_printf")
    Reported-by: syzbot+63122d0bc347f18c1884@syzkaller.appspotmail.com
    Signed-off-by: Florent Revest <revest@chromium.org>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/20210511081054.2125874-1-revest@chromium.org
    Florent Revest authored and Alexei Starovoitov committed May 11, 2021
  11. bpf: Add deny list of btf ids check for tracing programs

    The recursion check in __bpf_prog_enter and __bpf_prog_exit
    leaves some (not inlined) functions unprotected:
    
    In __bpf_prog_enter:
      - migrate_disable is called before prog->active is checked
    
    In __bpf_prog_exit:
      - migrate_enable,rcu_read_unlock_strict are called after
        prog->active is decreased
    
    When attaching trampoline to them we get panic like:
    
      traps: PANIC: double fault, error_code: 0x0
      double fault: 0000 [#1] SMP PTI
      RIP: 0010:__bpf_prog_enter+0x4/0x50
      ...
      Call Trace:
       <IRQ>
       bpf_trampoline_6442466513_0+0x18/0x1000
       migrate_disable+0x5/0x50
       __bpf_prog_enter+0x9/0x50
       bpf_trampoline_6442466513_0+0x18/0x1000
       migrate_disable+0x5/0x50
       __bpf_prog_enter+0x9/0x50
       bpf_trampoline_6442466513_0+0x18/0x1000
       migrate_disable+0x5/0x50
       __bpf_prog_enter+0x9/0x50
       bpf_trampoline_6442466513_0+0x18/0x1000
       migrate_disable+0x5/0x50
       ...
    
    Fixing this by adding deny list of btf ids for tracing
    programs and checking btf id during program verification.
    Adding above functions to this list.
    
    Suggested-by: Alexei Starovoitov <ast@kernel.org>
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/20210429114712.43783-1-jolsa@kernel.org
    olsajiri authored and Alexei Starovoitov committed May 11, 2021
  12. bpf: Add kconfig knob for disabling unpriv bpf by default

    Add a kconfig knob which allows for unprivileged bpf to be disabled by default.
    If set, the knob sets /proc/sys/kernel/unprivileged_bpf_disabled to value of 2.
    
    This still allows a transition of 2 -> {0,1} through an admin. Similarly,
    this also still keeps 1 -> {1} behavior intact, so that once set to permanently
    disabled, it cannot be undone aside from a reboot.
    
    We've also added extra2 with max of 2 for the procfs handler, so that an admin
    still has a chance to toggle between 0 <-> 2.
    
    Either way, as an additional alternative, applications can make use of CAP_BPF
    that we added a while ago.
    
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/74ec548079189e4e4dffaeb42b8987bb3c852eee.1620765074.git.daniel@iogearbox.net
    borkmann authored and Alexei Starovoitov committed May 11, 2021
  13. bpf, kconfig: Add consolidated menu entry for bpf with core options

    Right now, all core BPF related options are scattered in different Kconfig
    locations mainly due to historic reasons. Moving forward, lets add a proper
    subsystem entry under ...
    
      General setup  --->
        BPF subsystem  --->
    
    ... in order to have all knobs in a single location and thus ease BPF related
    configuration. Networking related bits such as sockmap are out of scope for
    the general setup and therefore better suited to remain in net/Kconfig.
    
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/f23f58765a4d59244ebd8037da7b6a6b2fb58446.1620765074.git.daniel@iogearbox.net
    borkmann authored and Alexei Starovoitov committed May 11, 2021
  14. ath11k: Drop multicast fragments

    Fragmentation is used only with unicast frames. Drop multicast fragments
    to avoid any undesired behavior.
    
    Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.4.0.1-01734-QCAHKSWPL_SILICONZ-1 v2
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Sriram R <srirrama@codeaurora.org>
    Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
    Link: https://lore.kernel.org/r/20210511200110.1d53bfd20a8b.Ibb63283051bb5e2c45951932c6e1f351d5a73dc3@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Sriram R authored and jmberg-intel committed May 11, 2021
  15. ath11k: Clear the fragment cache during key install

    Currently the fragment cache setup during peer assoc is
    cleared only during peer delete. In case a key reinstallation
    happens with the same peer, the same fragment cache with old
    fragments added before key installation could be clubbed
    with fragments received after. This might be exploited
    to mix fragments of different data resulting in a proper
    unintended reassembled packet to be passed up the stack.
    
    Hence flush the fragment cache on every key installation to prevent
    potential attacks (CVE-2020-24587).
    
    Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.4.0.1-01734-QCAHKSWPL_SILICONZ-1 v2
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Sriram R <srirrama@codeaurora.org>
    Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
    Link: https://lore.kernel.org/r/20210511200110.218dc777836f.I9af6fc76215a35936c4152552018afb5079c5d8c@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Sriram R authored and jmberg-intel committed May 11, 2021
  16. ath10k: Validate first subframe of A-MSDU before processing the list

    In certain scenarios a normal MSDU can be received as an A-MSDU when
    the A-MSDU present bit of a QoS header gets flipped during reception.
    Since this bit is unauthenticated, the hardware crypto engine can pass
    the frame to the driver without any error indication.
    
    This could result in processing unintended subframes collected in the
    A-MSDU list. Hence, validate A-MSDU list by checking if the first frame
    has a valid subframe header.
    
    Comparing the non-aggregated MSDU and an A-MSDU, the fields of the first
    subframe DA matches the LLC/SNAP header fields of a normal MSDU.
    In order to avoid processing such frames, add a validation to
    filter such A-MSDU frames where the first subframe header DA matches
    with the LLC/SNAP header pattern.
    
    Tested-on: QCA9984 hw1.0 PCI 10.4-3.10-00047
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Sriram R <srirrama@codeaurora.org>
    Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
    Link: https://lore.kernel.org/r/20210511200110.e6f5eb7b9847.I38a77ae26096862527a5eab73caebd7346af8b66@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Sriram R authored and jmberg-intel committed May 11, 2021
  17. ath10k: Fix TKIP Michael MIC verification for PCIe

    TKIP Michael MIC was not verified properly for PCIe cases since the
    validation steps in ieee80211_rx_h_michael_mic_verify() in mac80211 did
    not get fully executed due to unexpected flag values in
    ieee80211_rx_status.
    
    Fix this by setting the flags property to meet mac80211 expectations for
    performing Michael MIC validation there. This fixes CVE-2020-26141. It
    does the same as ath10k_htt_rx_proc_rx_ind_hl() for SDIO which passed
    MIC verification case. This applies only to QCA6174/QCA9377 PCIe.
    
    Tested-on: QCA6174 hw3.2 PCI WLAN.RM.4.4.1-00110-QCARMSWP-1
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Wen Gong <wgong@codeaurora.org>
    Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
    Link: https://lore.kernel.org/r/20210511200110.c3f1d42c6746.I795593fcaae941c471425b8c7d5f7bb185d29142@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Wen Gong authored and jmberg-intel committed May 11, 2021
  18. ath10k: drop MPDU which has discard flag set by firmware for SDIO

    When the discard flag is set by the firmware for an MPDU, it should be
    dropped. This allows a mitigation for CVE-2020-24588 to be implemented
    in the firmware.
    
    Tested-on: QCA6174 hw3.2 SDIO WLAN.RMH.4.4.1-00049
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Wen Gong <wgong@codeaurora.org>
    Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
    Link: https://lore.kernel.org/r/20210511200110.11968c725b5c.Idd166365ebea2771c0c0a38c78b5060750f90e17@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Wen Gong authored and jmberg-intel committed May 11, 2021
  19. ath10k: drop fragments with multicast DA for SDIO

    Fragmentation is not used with multicast frames. Discard unexpected
    fragments with multicast DA. This fixes CVE-2020-26145.
    
    Tested-on: QCA6174 hw3.2 SDIO WLAN.RMH.4.4.1-00049
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Wen Gong <wgong@codeaurora.org>
    Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
    Link: https://lore.kernel.org/r/20210511200110.9ca6ca7945a9.I1e18b514590af17c155bda86699bc3a971a8dcf4@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Wen Gong authored and jmberg-intel committed May 11, 2021
  20. ath10k: drop fragments with multicast DA for PCIe

    Fragmentation is not used with multicast frames. Discard unexpected
    fragments with multicast DA. This fixes CVE-2020-26145.
    
    Tested-on: QCA6174 hw3.2 PCI WLAN.RM.4.4.1-00110-QCARMSWP-1
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Wen Gong <wgong@codeaurora.org>
    Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
    Link: https://lore.kernel.org/r/20210511200110.5a0bd289bda8.Idd6ebea20038fb1cfee6de924aa595e5647c9eae@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Wen Gong authored and jmberg-intel committed May 11, 2021
  21. ath10k: add CCMP PN replay protection for fragmented frames for PCIe

    PN replay check for not fragmented frames is finished in the firmware,
    but this was not done for fragmented frames when ath10k is used with
    QCA6174/QCA6377 PCIe. mac80211 has the function
    ieee80211_rx_h_defragment() for PN replay check for fragmented frames,
    but this does not get checked with QCA6174 due to the
    ieee80211_has_protected() condition not matching the cleared Protected
    bit case.
    
    Validate the PN of received fragmented frames within ath10k when CCMP is
    used and drop the fragment if the PN is not correct (incremented by
    exactly one from the previous fragment). This applies only for
    QCA6174/QCA6377 PCIe.
    
    Tested-on: QCA6174 hw3.2 PCI WLAN.RM.4.4.1-00110-QCARMSWP-1
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Wen Gong <wgong@codeaurora.org>
    Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
    Link: https://lore.kernel.org/r/20210511200110.9ba2664866a4.I756e47b67e210dba69966d989c4711ffc02dc6bc@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Wen Gong authored and jmberg-intel committed May 11, 2021
  22. mac80211: extend protection against mixed key and fragment cache attacks

    For some chips/drivers, e.g., QCA6174 with ath10k, the decryption is
    done by the hardware, and the Protected bit in the Frame Control field
    is cleared in the lower level driver before the frame is passed to
    mac80211. In such cases, the condition for ieee80211_has_protected() is
    not met in ieee80211_rx_h_defragment() of mac80211 and the new security
    validation steps are not executed.
    
    Extend mac80211 to cover the case where the Protected bit has been
    cleared, but the frame is indicated as having been decrypted by the
    hardware. This extends protection against mixed key and fragment cache
    attack for additional drivers/chips. This fixes CVE-2020-24586 and
    CVE-2020-24587 for such cases.
    
    Tested-on: QCA6174 hw3.2 PCI WLAN.RM.4.4.1-00110-QCARMSWP-1
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Wen Gong <wgong@codeaurora.org>
    Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
    Link: https://lore.kernel.org/r/20210511200110.037aa5ca0390.I7bb888e2965a0db02a67075fcb5deb50eb7408aa@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Wen Gong authored and jmberg-intel committed May 11, 2021
  23. mac80211: do not accept/forward invalid EAPOL frames

    EAPOL frames are used for authentication and key management between the
    AP and each individual STA associated in the BSS. Those frames are not
    supposed to be sent by one associated STA to another associated STA
    (either unicast for broadcast/multicast).
    
    Similarly, in 802.11 they're supposed to be sent to the authenticator
    (AP) address.
    
    Since it is possible for unexpected EAPOL frames to result in misbehavior
    in supplicant implementations, it is better for the AP to not allow such
    cases to be forwarded to other clients either directly, or indirectly if
    the AP interface is part of a bridge.
    
    Accept EAPOL (control port) frames only if they're transmitted to the
    own address, or, due to interoperability concerns, to the PAE group
    address.
    
    Disable forwarding of EAPOL (or well, the configured control port
    protocol) frames back to wireless medium in all cases. Previously, these
    frames were accepted from fully authenticated and authorized stations
    and also from unauthenticated stations for one of the cases.
    
    Additionally, to avoid forwarding by the bridge, rewrite the PAE group
    address case to the local MAC address.
    
    Cc: stable@vger.kernel.org
    Co-developed-by: Jouni Malinen <jouni@codeaurora.org>
    Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
    Link: https://lore.kernel.org/r/20210511200110.cb327ed0cabe.Ib7dcffa2a31f0913d660de65ba3c8aca75b1d10f@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    jmberg-intel committed May 11, 2021
  24. mac80211: prevent attacks on TKIP/WEP as well

    Similar to the issues fixed in previous patches, TKIP and WEP
    should be protected even if for TKIP we have the Michael MIC
    protecting it, and WEP is broken anyway.
    
    However, this also somewhat protects potential other algorithms
    that drivers might implement.
    
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210511200110.430e8c202313.Ia37e4e5b6b3eaab1a5ae050e015f6c92859dbe27@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    jmberg-intel committed May 11, 2021
  25. mac80211: check defrag PN against current frame

    As pointed out by Mathy Vanhoef, we implement the RX PN check
    on fragmented frames incorrectly - we check against the last
    received PN prior to the new frame, rather than to the one in
    this frame itself.
    
    Prior patches addressed the security issue here, but in order
    to be able to reason better about the code, fix it to really
    compare against the current frame's PN, not the last stored
    one.
    
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210511200110.bfbc340ff071.Id0b690e581da7d03d76df90bb0e3fd55930bc8a0@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    jmberg-intel committed May 11, 2021
  26. mac80211: add fragment cache to sta_info

    Prior patches protected against fragmentation cache attacks
    by coloring keys, but this shows that it can lead to issues
    when multiple stations use the same sequence number. Add a
    fragment cache to struct sta_info (in addition to the one in
    the interface) to separate fragments for different stations
    properly.
    
    This then automatically clear most of the fragment cache when a
    station disconnects (or reassociates) from an AP, or when client
    interfaces disconnect from the network, etc.
    
    On the way, also fix the comment there since this brings us in line
    with the recommendation in 802.11-2016 ("An AP should support ...").
    Additionally, remove a useless condition (since there's no problem
    purging an already empty list).
    
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210511200110.fc35046b0d52.I1ef101e3784d13e8f6600d83de7ec9a3a45bcd52@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    jmberg-intel committed May 11, 2021
  27. mac80211: drop A-MSDUs on old ciphers

    With old ciphers (WEP and TKIP) we shouldn't be using A-MSDUs
    since A-MSDUs are only supported if we know that they are, and
    the only practical way for that is HT support which doesn't
    support old ciphers.
    
    However, we would normally accept them anyway. Since we check
    the MMIC before deaggregating A-MSDUs, and the A-MSDU bit in
    the QoS header is not protected in TKIP (or WEP), this enables
    attacks similar to CVE-2020-24588. To prevent that, drop A-MSDUs
    completely with old ciphers.
    
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210511200110.076543300172.I548e6e71f1ee9cad4b9a37bf212ae7db723587aa@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    jmberg-intel committed May 11, 2021
  28. cfg80211: mitigate A-MSDU aggregation attacks

    Mitigate A-MSDU injection attacks (CVE-2020-24588) by detecting if the
    destination address of a subframe equals an RFC1042 (i.e., LLC/SNAP)
    header, and if so dropping the complete A-MSDU frame. This mitigates
    known attacks, although new (unknown) aggregation-based attacks may
    remain possible.
    
    This defense works because in A-MSDU aggregation injection attacks, a
    normal encrypted Wi-Fi frame is turned into an A-MSDU frame. This means
    the first 6 bytes of the first A-MSDU subframe correspond to an RFC1042
    header. In other words, the destination MAC address of the first A-MSDU
    subframe contains the start of an RFC1042 header during an aggregation
    attack. We can detect this and thereby prevent this specific attack.
    For details, see Section 7.2 of "Fragment and Forge: Breaking Wi-Fi
    Through Frame Aggregation and Fragmentation".
    
    Note that for kernel 4.9 and above this patch depends on "mac80211:
    properly handle A-MSDUs that start with a rfc1042 header". Otherwise
    this patch has no impact and attacks will remain possible.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>
    Link: https://lore.kernel.org/r/20210511200110.25d93176ddaf.I9e265b597f2cd23eb44573f35b625947b386a9de@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    vanhoefm authored and jmberg-intel committed May 11, 2021
  29. mac80211: properly handle A-MSDUs that start with an RFC 1042 header

    Properly parse A-MSDUs whose first 6 bytes happen to equal a rfc1042
    header. This can occur in practice when the destination MAC address
    equals AA:AA:03:00:00:00. More importantly, this simplifies the next
    patch to mitigate A-MSDU injection attacks.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>
    Link: https://lore.kernel.org/r/20210511200110.0b2b886492f0.I23dd5d685fe16d3b0ec8106e8f01b59f499dffed@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    vanhoefm authored and jmberg-intel committed May 11, 2021
  30. mac80211: prevent mixed key and fragment cache attacks

    Simultaneously prevent mixed key attacks (CVE-2020-24587) and fragment
    cache attacks (CVE-2020-24586). This is accomplished by assigning a
    unique color to every key (per interface) and using this to track which
    key was used to decrypt a fragment. When reassembling frames, it is
    now checked whether all fragments were decrypted using the same key.
    
    To assure that fragment cache attacks are also prevented, the ID that is
    assigned to keys is unique even over (re)associations and (re)connects.
    This means fragments separated by a (re)association or (re)connect will
    not be reassembled. Because mac80211 now also prevents the reassembly of
    mixed encrypted and plaintext fragments, all cache attacks are prevented.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>
    Link: https://lore.kernel.org/r/20210511200110.3f8290e59823.I622a67769ed39257327a362cfc09c812320eb979@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    vanhoefm authored and jmberg-intel committed May 11, 2021
  31. mac80211: assure all fragments are encrypted

    Do not mix plaintext and encrypted fragments in protected Wi-Fi
    networks. This fixes CVE-2020-26147.
    
    Previously, an attacker was able to first forward a legitimate encrypted
    fragment towards a victim, followed by a plaintext fragment. The
    encrypted and plaintext fragment would then be reassembled. For further
    details see Section 6.3 and Appendix D in the paper "Fragment and Forge:
    Breaking Wi-Fi Through Frame Aggregation and Fragmentation".
    
    Because of this change there are now two equivalent conditions in the
    code to determine if a received fragment requires sequential PNs, so we
    also move this test to a separate function to make the code easier to
    maintain.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>
    Link: https://lore.kernel.org/r/20210511200110.30c4394bb835.I5acfdb552cc1d20c339c262315950b3eac491397@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    vanhoefm authored and jmberg-intel committed May 11, 2021
  32. bpf: Prevent writable memory-mapping of read-only ringbuf pages

    Only the very first page of BPF ringbuf that contains consumer position
    counter is supposed to be mapped as writeable by user-space. Producer
    position is read-only and can be modified only by the kernel code. BPF ringbuf
    data pages are read-only as well and are not meant to be modified by
    user-code to maintain integrity of per-record headers.
    
    This patch allows to map only consumer position page as writeable and
    everything else is restricted to be read-only. remap_vmalloc_range()
    internally adds VM_DONTEXPAND, so all the established memory mappings can't be
    extended, which prevents any future violations through mremap()'ing.
    
    Fixes: 457f443 ("bpf: Implement BPF ring buffer and verifier support for it")
    Reported-by: Ryota Shiga (Flatt Security)
    Reported-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Alexei Starovoitov <ast@kernel.org>
    anakryiko authored and borkmann committed May 11, 2021
  33. bpf, ringbuf: Deny reserve of buffers larger than ringbuf

    A BPF program might try to reserve a buffer larger than the ringbuf size.
    If the consumer pointer is way ahead of the producer, that would be
    successfully reserved, allowing the BPF program to read or write out of
    the ringbuf allocated area.
    
    Reported-by: Ryota Shiga (Flatt Security)
    Fixes: 457f443 ("bpf: Implement BPF ring buffer and verifier support for it")
    Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Andrii Nakryiko <andrii@kernel.org>
    Acked-by: Alexei Starovoitov <ast@kernel.org>
    Thadeu Lima de Souza Cascardo authored and borkmann committed May 11, 2021
  34. bpf: Fix alu32 const subreg bound tracking on bitwise operations

    Fix a bug in the verifier's scalar32_min_max_*() functions which leads to
    incorrect tracking of 32 bit bounds for the simulation of and/or/xor bitops.
    When both the src & dst subreg is a known constant, then the assumption is
    that scalar_min_max_*() will take care to update bounds correctly. However,
    this is not the case, for example, consider a register R2 which has a tnum
    of 0xffffffff00000000, meaning, lower 32 bits are known constant and in this
    case of value 0x00000001. R2 is then and'ed with a register R3 which is a
    64 bit known constant, here, 0x100000002.
    
    What can be seen in line '10:' is that 32 bit bounds reach an invalid state
    where {u,s}32_min_value > {u,s}32_max_value. The reason is scalar32_min_max_*()
    delegates 32 bit bounds updates to scalar_min_max_*(), however, that really
    only takes place when both the 64 bit src & dst register is a known constant.
    Given scalar32_min_max_*() is intended to be designed as closely as possible
    to scalar_min_max_*(), update the 32 bit bounds in this situation through
    __mark_reg32_known() which will set all {u,s}32_{min,max}_value to the correct
    constant, which is 0x00000000 after the fix (given 0x00000001 & 0x00000002 in
    32 bit space). This is possible given var32_off already holds the final value
    as dst_reg->var_off is updated before calling scalar32_min_max_*().
    
    Before fix, invalid tracking of R2:
    
      [...]
      9: R0_w=inv1337 R1=ctx(id=0,off=0,imm=0) R2_w=inv(id=0,smin_value=-9223372036854775807 (0x8000000000000001),smax_value=9223372032559808513 (0x7fffffff00000001),umin_value=1,umax_value=0xffffffff00000001,var_off=(0x1; 0xffffffff00000000),s32_min_value=1,s32_max_value=1,u32_min_value=1,u32_max_value=1) R3_w=inv4294967298 R10=fp0
      9: (5f) r2 &= r3
      10: R0_w=inv1337 R1=ctx(id=0,off=0,imm=0) R2_w=inv(id=0,smin_value=0,smax_value=4294967296 (0x100000000),umin_value=0,umax_value=0x100000000,var_off=(0x0; 0x100000000),s32_min_value=1,s32_max_value=0,u32_min_value=1,u32_max_value=0) R3_w=inv4294967298 R10=fp0
      [...]
    
    After fix, correct tracking of R2:
    
      [...]
      9: R0_w=inv1337 R1=ctx(id=0,off=0,imm=0) R2_w=inv(id=0,smin_value=-9223372036854775807 (0x8000000000000001),smax_value=9223372032559808513 (0x7fffffff00000001),umin_value=1,umax_value=0xffffffff00000001,var_off=(0x1; 0xffffffff00000000),s32_min_value=1,s32_max_value=1,u32_min_value=1,u32_max_value=1) R3_w=inv4294967298 R10=fp0
      9: (5f) r2 &= r3
      10: R0_w=inv1337 R1=ctx(id=0,off=0,imm=0) R2_w=inv(id=0,smin_value=0,smax_value=4294967296 (0x100000000),umin_value=0,umax_value=0x100000000,var_off=(0x0; 0x100000000),s32_min_value=0,s32_max_value=0,u32_min_value=0,u32_max_value=0) R3_w=inv4294967298 R10=fp0
      [...]
    
    Fixes: 3f50f13 ("bpf: Verifier, do explicit ALU32 bounds tracking")
    Fixes: 2921c90 ("bpf: Fix a verifier failure with xor")
    Reported-by: Manfred Paul (@_manfp)
    Reported-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Reviewed-by: John Fastabend <john.fastabend@gmail.com>
    Acked-by: Alexei Starovoitov <ast@kernel.org>
    borkmann committed May 11, 2021
Older