Skip to content
  1. May 18, 2022
    • Javier Martinez Canillas's avatar
      fbdev: simplefb: Cleanup fb_info in .fb_destroy rather than .remove · 02eef429
      Javier Martinez Canillas authored
      [ Upstream commit 666b90b3 ]
      
      The driver is calling framebuffer_release() in its .remove callback, but
      this will cause the struct fb_info to be freed too early. Since it could
      be that a reference is still hold to it if user-space opened the fbdev.
      
      This would lead to a use-after-free error if the framebuffer device was
      unregistered but later a user-space process tries to close the fbdev fd.
      
      To prevent this, move the framebuffer_release() call to fb_ops.fb_destroy
      instead of doing it in the driver's .remove callback.
      
      Strictly speaking, the code flow in the driver is still wrong because all
      the hardware cleanupd (i.e: iounmap) should be done in .remove while the
      software cleanup (i.e: releasing the framebuffer) should be done in the
      .fb_destroy handler. But this at least makes to match the behavior before
      commit 27599aac ("fbdev: Hot-unplug firmware fb devices on forced removal").
      
      Fixes: 27599aac
      
       ("fbdev: Hot-unplug firmware fb devices on forced removal")
      Suggested-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
      Reviewed-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
      Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220505220456.366090-1-javierm@redhat.com
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      02eef429
    • Vladimir Oltean's avatar
      net: mscc: ocelot: avoid corrupting hardware counters when moving VCAP filters · 4ebbf76d
      Vladimir Oltean authored
      [ Upstream commit 93a84170 ]
      
      Given the following order of operations:
      
      (1) we add filter A using tc-flower
      (2) we send a packet that matches it
      (3) we read the filter's statistics to find a hit count of 1
      (4) we add a second filter B with a higher preference than A, and A
          moves one position to the right to make room in the TCAM for it
      (5) we send another packet, and this matches the second filter B
      (6) we read the filter statistics again.
      
      When this happens, the hit count of filter A is 2 and of filter B is 1,
      despite a single packet having matched each filter.
      
      Furthermore, in an alternate history, reading the filter stats a second
      time between steps (3) and (4) makes the hit count of filter A remain at
      1 after step (6), as expected.
      
      The reason why this happens has to do with the filter->stats.pkts field,
      which is written to hardware through the call path below:
      
                     vcap_entry_set
                     /      |      \
                    /       |       \
                   /        |        \
                  /         |         \
      es0_entry_set   is1_entry_set   is2_entry_set
                  \         |         /
                   \        |        /
                    \       |       /
              vcap_data_set(data.counter, ...)
      
      The primary role of filter->stats.pkts is to transport the filter hit
      counters from the last readout all the way from vcap_entry_get() ->
      ocelot_vcap_filter_stats_update() -> ocelot_cls_flower_stats().
      The reason why vcap_entry_set() writes it to hardware is so that the
      counters (saturating and having a limited bit width) are cleared
      after each user space readout.
      
      The writing of filter->stats.pkts to hardware during the TCAM entry
      movement procedure is an unintentional consequence of the code design,
      because the hit count isn't up to date at this point.
      
      So at step (4), when filter A is moved by ocelot_vcap_filter_add() to
      make room for filter B, the hardware hit count is 0 (no packet matched
      on it in the meantime), but filter->stats.pkts is 1, because the last
      readout saw the earlier packet. The movement procedure programs the old
      hit count back to hardware, so this creates the impression to user space
      that more packets have been matched than they really were.
      
      The bug can be seen when running the gact_drop_and_ok_test() from the
      tc_actions.sh selftest.
      
      Fix the issue by reading back the hit count to tmp->stats.pkts before
      migrating the VCAP filter. Sure, this is a best-effort technique, since
      the packets that hit the rule between vcap_entry_get() and
      vcap_entry_set() won't be counted, but at least it allows the counters
      to be reliably used for selftests where the traffic is under control.
      
      The vcap_entry_get() name is a bit unintuitive, but it only reads back
      the counter portion of the TCAM entry, not the entire entry.
      
      The index from which we retrieve the counter is also a bit unintuitive
      (i - 1 during add, i + 1 during del), but this is the way in which TCAM
      entry movement works. The "entry index" isn't a stored integer for a
      TCAM filter, instead it is dynamically computed by
      ocelot_vcap_block_get_filter_index() based on the entry's position in
      the &block->rules list. That position (as well as block->count) is
      automatically updated by ocelot_vcap_filter_add_to_block() on add, and
      by ocelot_vcap_block_remove_filter() on del. So "i" is the new filter
      index, and "i - 1" or "i + 1" respectively are the old addresses of that
      TCAM entry (we only support installing/deleting one filter at a time).
      
      Fixes: b5962294
      
       ("net: mscc: ocelot: Add support for tcam")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4ebbf76d
    • Vladimir Oltean's avatar
      net: mscc: ocelot: restrict tc-trap actions to VCAP IS2 lookup 0 · e4a33862
      Vladimir Oltean authored
      [ Upstream commit 477d2b91 ]
      
      Once the CPU port was added to the destination port mask of a packet, it
      can never be cleared, so even packets marked as dropped by the MASK_MODE
      of a VCAP IS2 filter will still reach it. This is why we need the
      OCELOT_POLICER_DISCARD to "kill dropped packets dead" and make software
      stop seeing them.
      
      We disallow policer rules from being put on any other chain than the one
      for the first lookup, but we don't do this for "drop" rules, although we
      should. This change is merely ascertaining that the rules dont't
      (completely) work and letting the user know.
      
      The blamed commit is the one that introduced the multi-chain architecture
      in ocelot. Prior to that, we should have always offloaded the filters to
      VCAP IS2 lookup 0, where they did work.
      
      Fixes: 1397a2eb
      
       ("net: mscc: ocelot: create TCAM skeleton from tc filter chains")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e4a33862
    • Vladimir Oltean's avatar
      net: mscc: ocelot: fix VCAP IS2 filters matching on both lookups · ceffde8c
      Vladimir Oltean authored
      [ Upstream commit 6741e118 ]
      
      The VCAP IS2 TCAM is looked up twice per packet, and each filter can be
      configured to only match during the first, second lookup, or both, or
      none.
      
      The blamed commit wrote the code for making VCAP IS2 filters match only
      on the given lookup. But right below that code, there was another line
      that explicitly made the lookup a "don't care", and this is overwriting
      the lookup we've selected. So the code had no effect.
      
      Some of the more noticeable effects of having filters match on both
      lookups:
      
      - in "tc -s filter show dev swp0 ingress", we see each packet matching a
        VCAP IS2 filter counted twice. This throws off scripts such as
        tools/testing/selftests/net/forwarding/tc_actions.sh and makes them
        fail.
      
      - a "tc-drop" action offloaded to VCAP IS2 needs a policer as well,
        because once the CPU port becomes a member of the destination port
        mask of a packet, nothing removes it, not even a PERMIT/DENY mask mode
        with a port mask of 0. But VCAP IS2 rules with the POLICE_ENA bit in
        the action vector can only appear in the first lookup. What happens
        when a filter matches both lookups is that the action vector is
        combined, and this makes the POLICE_ENA bit ineffective, since the
        last lookup in which it has appeared is the second one. In other
        words, "tc-drop" actions do not drop packets for the CPU port, dropped
        packets are still seen by software unless there was an FDB entry that
        directed those packets to some other place different from the CPU.
      
      The last bit used to work, because in the initial commit b5962294
      ("net: mscc: ocelot: Add support for tcam"), we were writing the FIRST
      field of the VCAP IS2 half key with a 1, not with a "don't care".
      The change to "don't care" was made inadvertently by me in commit
      c1c3993e ("net: mscc: ocelot: generalize existing code for VCAP"),
      which I just realized, and which needs a separate fix from this one,
      for "stable" kernels that lack the commit blamed below.
      
      Fixes: 226e9cd8
      
       ("net: mscc: ocelot: only install TCAM entries into a specific lookup and PAG")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ceffde8c
    • Vladimir Oltean's avatar
      net: mscc: ocelot: fix last VCAP IS1/IS2 filter persisting in hardware when deleted · d242b66a
      Vladimir Oltean authored
      [ Upstream commit 16bbebd3 ]
      
      ocelot_vcap_filter_del() works by moving the next filters over the
      current one, and then deleting the last filter by calling vcap_entry_set()
      with a del_filter which was specially created by memsetting its memory
      to zeroes. vcap_entry_set() then programs this to the TCAM and action
      RAM via the cache registers.
      
      The problem is that vcap_entry_set() is a dispatch function which looks
      at del_filter->block_id. But since del_filter is zeroized memory, the
      block_id is 0, or otherwise said, VCAP_ES0. So practically, what we do
      is delete the entry at the same TCAM index from VCAP ES0 instead of IS1
      or IS2.
      
      The code was not always like this. vcap_entry_set() used to simply be
      is2_entry_set(), and then, the logic used to work.
      
      Restore the functionality by populating the block_id of the del_filter
      based on the VCAP block of the filter that we're deleting. This makes
      vcap_entry_set() know what to do.
      
      Fixes: 1397a2eb
      
       ("net: mscc: ocelot: create TCAM skeleton from tc filter chains")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d242b66a
    • Tariq Toukan's avatar
      net: Fix features skip in for_each_netdev_feature() · cc22bb20
      Tariq Toukan authored
      [ Upstream commit 85db6352 ]
      
      The find_next_netdev_feature() macro gets the "remaining length",
      not bit index.
      Passing "bit - 1" for the following iteration is wrong as it skips
      the adjacent bit. Pass "bit" instead.
      
      Fixes: 3b89ea9c
      
       ("net: Fix for_each_netdev_feature on Big endian")
      Signed-off-by: default avatarTariq Toukan <tariqt@nvidia.com>
      Reviewed-by: default avatarGal Pressman <gal@nvidia.com>
      Link: https://lore.kernel.org/r/20220504080914.1918-1-tariqt@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cc22bb20
    • Manikanta Pubbisetty's avatar
      mac80211: Reset MBSSID parameters upon connection · afc080e4
      Manikanta Pubbisetty authored
      [ Upstream commit 86af062f ]
      
      Currently MBSSID parameters in struct ieee80211_bss_conf
      are not reset upon connection. This could be problematic
      with some drivers in a scenario where the device first
      connects to a non-transmit BSS and then connects to a
      transmit BSS of a Multi BSS AP. The MBSSID parameters
      which are set after connecting to a non-transmit BSS will
      not be reset and the same parameters will be passed on to
      the driver during the subsequent connection to a transmit
      BSS of a Multi BSS AP.
      
      For example, firmware running on the ath11k device uses the
      Multi BSS data for tracking the beacon of a non-transmit BSS
      and reports the driver when there is a beacon miss. If we do
      not reset the MBSSID parameters during the subsequent
      connection to a transmit BSS, then the driver would have
      wrong MBSSID data and FW would be looking for an incorrect
      BSSID in the MBSSID beacon of a Multi BSS AP and reports
      beacon loss leading to an unstable connection.
      
      Reset the MBSSID parameters upon every connection to solve this
      problem.
      
      Fixes: 78ac51f8
      
       ("mac80211: support multi-bssid")
      Signed-off-by: default avatarManikanta Pubbisetty <quic_mpubbise@quicinc.com>
      Link: https://lore.kernel.org/r/20220428052744.27040-1-quic_mpubbise@quicinc.com
      
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      afc080e4
    • Camel Guo's avatar
      hwmon: (tmp401) Add OF device ID table · e346e603
      Camel Guo authored
      [ Upstream commit 3481551f ]
      
      This driver doesn't have of_match_table. This makes the kernel module
      tmp401.ko lack alias patterns (e.g: of:N*T*Cti,tmp411) to match DT node
      of the supported devices hence this kernel module will not be
      automatically loaded.
      
      After adding of_match_table to this driver, the folllowing alias will be
      added into tmp401.ko.
      $ modinfo drivers/hwmon/tmp401.ko
      filename: drivers/hwmon/tmp401.ko
      ......
      author:         Hans de Goede <hdegoede@redhat.com>
      alias:          of:N*T*Cti,tmp435C*
      alias:          of:N*T*Cti,tmp435
      alias:          of:N*T*Cti,tmp432C*
      alias:          of:N*T*Cti,tmp432
      alias:          of:N*T*Cti,tmp431C*
      alias:          of:N*T*Cti,tmp431
      alias:          of:N*T*Cti,tmp411C*
      alias:          of:N*T*Cti,tmp411
      alias:          of:N*T*Cti,tmp401C*
      alias:          of:N*T*Cti,tmp401
      ......
      
      Fixes: af503716
      
       ("i2c: core: report OF style module alias for devices registered via OF")
      Signed-off-by: default avatarCamel Guo <camel.guo@axis.com>
      Link: https://lore.kernel.org/r/20220503114333.456476-1-camel.guo@axis.com
      
      
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e346e603
    • Guenter Roeck's avatar
      iwlwifi: iwl-dbg: Use del_timer_sync() before freeing · e29b71fc
      Guenter Roeck authored
      [ Upstream commit 7635a1ad
      
       ]
      
      In Chrome OS, a large number of crashes is observed due to corrupted timer
      lists. Steven Rostedt pointed out that this usually happens when a timer
      is freed while still active, and that the problem is often triggered
      by code calling del_timer() instead of del_timer_sync() just before
      freeing.
      
      Steven also identified the iwlwifi driver as one of the possible culprits
      since it does exactly that.
      
      Reported-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Johannes Berg <johannes.berg@intel.com>
      Cc: Gregory Greenman <gregory.greenman@intel.com>
      Fixes: 60e8abd9
      
       ("iwlwifi: dbg_ini: add periodic trigger new API support")
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Acked-by: default avatarGregory Greenman <gregory.greenman@intel.com>
      Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # Linux v5.17.3-rc1 and Debian LLVM-14
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/20220411154210.1870008-1-linux@roeck-us.net
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e29b71fc
    • Sven Eckelmann's avatar
      batman-adv: Don't skb_split skbuffs with frag_list · 8f37aad7
      Sven Eckelmann authored
      [ Upstream commit a063f2fb
      
       ]
      
      The receiving interface might have used GRO to receive more fragments than
      MAX_SKB_FRAGS fragments. In this case, these will not be stored in
      skb_shinfo(skb)->frags but merged into the frag list.
      
      batman-adv relies on the function skb_split to split packets up into
      multiple smaller packets which are not larger than the MTU on the outgoing
      interface. But this function cannot handle frag_list entries and is only
      operating on skb_shinfo(skb)->frags. If it is still trying to split such an
      skb and xmit'ing it on an interface without support for NETIF_F_FRAGLIST,
      then validate_xmit_skb() will try to linearize it. But this fails due to
      inconsistent information. And __pskb_pull_tail will trigger a BUG_ON after
      skb_copy_bits() returns an error.
      
      In case of entries in frag_list, just linearize the skb before operating on
      it with skb_split().
      
      Reported-by: default avatarFelix Kaechele <felix@kaechele.ca>
      Fixes: c6c8fea2
      
       ("net: Add batman-adv meshing protocol")
      Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
      Tested-by: default avatarFelix Kaechele <felix@kaechele.ca>
      Signed-off-by: default avatarSimon Wunderlich <sw@simonwunderlich.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8f37aad7
  2. May 16, 2022
  3. May 12, 2022