1. 19 Feb, 2020 11 commits
  2. 18 Feb, 2020 17 commits
  3. 17 Feb, 2020 12 commits
    • Horatiu Vultur's avatar
      net: mscc: fix in frame extraction · a8154104
      Horatiu Vultur authored
      Each extracted frame on Ocelot has an IFH. The frame and IFH are extracted
      by reading chuncks of 4 bytes from a register.
      
      In case the IFH and frames were read corretly it would try to read the next
      frame. In case there are no more frames in the queue, it checks if there
      were any previous errors and in that case clear the queue. But this check
      will always succeed also when there are no errors. Because when extracting
      the IFH the error is checked against 4(number of bytes read) and then the
      error is set only if the extraction of the frame failed. So in a happy case
      where there are no errors the err variable is still 4. So it could be
      a case where after the check that there are no more frames in the queue, a
      frame will arrive in the queue but because the error is not reseted, it
      would try to flush the queue. So the frame will be lost.
      
      The fix consist in resetting the error after reading the IFH.
      Signed-off-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
      Acked-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a8154104
    • Florian Westphal's avatar
      netfilter: conntrack: allow insertion of clashing entries · 6a757c07
      Florian Westphal authored
      This patch further relaxes the need to drop an skb due to a clash with
      an existing conntrack entry.
      
      Current clash resolution handles the case where the clash occurs between
      two identical entries (distinct nf_conn objects with same tuples), i.e.:
      
                          Original                        Reply
      existing: 10.2.3.4:42 -> 10.8.8.8:53      10.2.3.4:42 <- 10.0.0.6:5353
      clashing: 10.2.3.4:42 -> 10.8.8.8:53      10.2.3.4:42 <- 10.0.0.6:5353
      
      ... existing handling will discard the unconfirmed clashing entry and
      makes skb->_nfct point to the existing one.  The skb can then be
      processed normally just as if the clash would not have existed in the
      first place.
      
      For other clashes, the skb needs to be dropped.
      This frequently happens with DNS resolvers that send A and AAAA queries
      back-to-back when NAT rules are present that cause packets to get
      different DNAT transformations applied, for example:
      
      -m statistics --mode random ... -j DNAT --dnat-to 10.0.0.6:5353
      -m statistics --mode random ... -j DNAT --dnat-to 10.0.0.7:5353
      
      In this case the A or AAAA query is dropped which incurs a costly
      delay during name resolution.
      
      This patch also allows this collision type:
                             Original                   Reply
      existing: 10.2.3.4:42 -> 10.8.8.8:53      10.2.3.4:42 <- 10.0.0.6:5353
      clashing: 10.2.3.4:42 -> 10.8.8.8:53      10.2.3.4:42 <- 10.0.0.7:5353
      
      In this case, clash is in original direction -- the reply direction
      is still unique.
      
      The change makes it so that when the 2nd colliding packet is received,
      the clashing conntrack is tagged with new IPS_NAT_CLASH_BIT, gets a fixed
      1 second timeout and is inserted in the reply direction only.
      
      The entry is hidden from 'conntrack -L', it will time out quickly
      and it can be early dropped because it will never progress to the
      ASSURED state.
      
      To avoid special-casing the delete code path to special case
      the ORIGINAL hlist_nulls node, a new helper, "hlist_nulls_add_fake", is
      added so hlist_nulls_del() will work.
      
      Example:
      
            CPU A:                               CPU B:
      1.  10.2.3.4:42 -> 10.8.8.8:53 (A)
      2.                                         10.2.3.4:42 -> 10.8.8.8:53 (AAAA)
      3.  Apply DNAT, reply changed to 10.0.0.6
      4.                                         10.2.3.4:42 -> 10.8.8.8:53 (AAAA)
      5.                                         Apply DNAT, reply changed to 10.0.0.7
      6. confirm/commit to conntrack table, no collisions
      7.                                         commit clashing entry
      
      Reply comes in:
      
      10.2.3.4:42 <- 10.0.0.6:5353 (A)
       -> Finds a conntrack, DNAT is reversed & packet forwarded to 10.2.3.4:42
      10.2.3.4:42 <- 10.0.0.7:5353 (AAAA)
       -> Finds a conntrack, DNAT is reversed & packet forwarded to 10.2.3.4:42
          The conntrack entry is deleted from table, as it has the NAT_CLASH
          bit set.
      
      In case of a retransmit from ORIGINAL dir, all further packets will get
      the DNAT transformation to 10.0.0.6.
      
      I tried to come up with other solutions but they all have worse
      problems.
      
      Alternatives considered were:
      1.  Confirm ct entries at allocation time, not in postrouting.
       a. will cause uneccesarry work when the skb that creates the
          conntrack is dropped by ruleset.
       b. in case nat is applied, ct entry would need to be moved in
          the table, which requires another spinlock pair to be taken.
       c. breaks the 'unconfirmed entry is private to cpu' assumption:
          we would need to guard all nfct->ext allocation requests with
          ct->lock spinlock.
      
      2. Make the unconfirmed list a hash table instead of a pcpu list.
         Shares drawback c) of the first alternative.
      
      3. Document this is expected and force users to rearrange their
         ruleset (e.g. by using "-m cluster" instead of "-m statistics").
         nft has the 'jhash' expression which can be used instead of 'numgen'.
      
         Major drawback: doesn't fix what I consider a bug, not very realistic
         and I believe its reasonable to have the existing rulesets to 'just
         work'.
      
      4. Document this is expected and force users to steer problematic
         packets to the same CPU -- this would serialize the "allocate new
         conntrack entry/nat table evaluation/perform nat/confirm entry", so
         no race can occur.  Similar drawback to 3.
      
      Another advantage of this patch compared to 1) and 2) is that there are
      no changes to the hot path; things are handled in the udp tracker and
      the clash resolution path.
      
      Cc: rcu@vger.kernel.org
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Josh Triplett <josh@joshtriplett.org>
      Cc: Jozsef Kadlecsik <kadlec@netfilter.org>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      6a757c07
    • Paul Cercueil's avatar
      net: ethernet: dm9000: Handle -EPROBE_DEFER in dm9000_parse_dt() · 9a6a0dea
      Paul Cercueil authored
      The call to of_get_mac_address() can return -EPROBE_DEFER, for instance
      when the MAC address is read from a NVMEM driver that did not probe yet.
      
      Cc: H. Nikolaus Schaller <hns@goldelico.com>
      Cc: Mathieu Malaterre <malat@debian.org>
      Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9a6a0dea
    • Randy Dunlap's avatar
      skbuff.h: fix all kernel-doc warnings · d2f273f0
      Randy Dunlap authored
      Fix all kernel-doc warnings in <linux/skbuff.h>.
      Fixes these warnings:
      
      ../include/linux/skbuff.h:890: warning: Function parameter or member 'list' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member 'dev_scratch' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member 'ip_defrag_offset' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member 'skb_mstamp_ns' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member '__cloned_offset' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member 'head_frag' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member '__pkt_type_offset' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member 'encapsulation' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member 'encap_hdr_csum' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member 'csum_valid' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member '__pkt_vlan_present_offset' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member 'vlan_present' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member 'csum_complete_sw' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member 'csum_level' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member 'inner_protocol_type' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member 'remcsum_offload' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member 'sender_cpu' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member 'reserved_tailroom' not described in 'sk_buff'
      ../include/linux/skbuff.h:890: warning: Function parameter or member 'inner_ipproto' not described in 'sk_buff'
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d2f273f0
    • Randy Dunlap's avatar
      skbuff: remove stale bit mask comments · 8955b435
      Randy Dunlap authored
      Remove stale comments since this flag is no longer a bit mask
      but is a bit field.
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8955b435
    • Randy Dunlap's avatar
      net/sock.h: fix all kernel-doc warnings · 66256e0b
      Randy Dunlap authored
      Fix all kernel-doc warnings for <net/sock.h>.
      Fixes these warnings:
      
      ../include/net/sock.h:232: warning: Function parameter or member 'skc_addrpair' not described in 'sock_common'
      ../include/net/sock.h:232: warning: Function parameter or member 'skc_portpair' not described in 'sock_common'
      ../include/net/sock.h:232: warning: Function parameter or member 'skc_ipv6only' not described in 'sock_common'
      ../include/net/sock.h:232: warning: Function parameter or member 'skc_net_refcnt' not described in 'sock_common'
      ../include/net/sock.h:232: warning: Function parameter or member 'skc_v6_daddr' not described in 'sock_common'
      ../include/net/sock.h:232: warning: Function parameter or member 'skc_v6_rcv_saddr' not described in 'sock_common'
      ../include/net/sock.h:232: warning: Function parameter or member 'skc_cookie' not described in 'sock_common'
      ../include/net/sock.h:232: warning: Function parameter or member 'skc_listener' not described in 'sock_common'
      ../include/net/sock.h:232: warning: Function parameter or member 'skc_tw_dr' not described in 'sock_common'
      ../include/net/sock.h:232: warning: Function parameter or member 'skc_rcv_wnd' not described in 'sock_common'
      ../include/net/sock.h:232: warning: Function parameter or member 'skc_tw_rcv_nxt' not described in 'sock_common'
      
      ../include/net/sock.h:498: warning: Function parameter or member 'sk_rx_skb_cache' not described in 'sock'
      ../include/net/sock.h:498: warning: Function parameter or member 'sk_wq_raw' not described in 'sock'
      ../include/net/sock.h:498: warning: Function parameter or member 'tcp_rtx_queue' not described in 'sock'
      ../include/net/sock.h:498: warning: Function parameter or member 'sk_tx_skb_cache' not described in 'sock'
      ../include/net/sock.h:498: warning: Function parameter or member 'sk_route_forced_caps' not described in 'sock'
      ../include/net/sock.h:498: warning: Function parameter or member 'sk_txtime_report_errors' not described in 'sock'
      ../include/net/sock.h:498: warning: Function parameter or member 'sk_validate_xmit_skb' not described in 'sock'
      ../include/net/sock.h:498: warning: Function parameter or member 'sk_bpf_storage' not described in 'sock'
      
      ../include/net/sock.h:2024: warning: No description found for return value of 'sk_wmem_alloc_get'
      ../include/net/sock.h:2035: warning: No description found for return value of 'sk_rmem_alloc_get'
      ../include/net/sock.h:2046: warning: No description found for return value of 'sk_has_allocations'
      ../include/net/sock.h:2082: warning: No description found for return value of 'skwq_has_sleeper'
      ../include/net/sock.h:2244: warning: No description found for return value of 'sk_page_frag'
      ../include/net/sock.h:2444: warning: Function parameter or member 'tcp_rx_skb_cache_key' not described in 'DECLARE_STATIC_KEY_FALSE'
      ../include/net/sock.h:2444: warning: Excess function parameter 'sk' description in 'DECLARE_STATIC_KEY_FALSE'
      ../include/net/sock.h:2444: warning: Excess function parameter 'skb' description in 'DECLARE_STATIC_KEY_FALSE'
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      66256e0b
    • Marek Vasut's avatar
      net: ks8851-ml: Fix 16-bit IO operation · 58292104
      Marek Vasut authored
      The Micrel KSZ8851-16MLLI datasheet DS00002357B page 12 states that
      BE[3:0] signals are active high. This contradicts the measurements
      of the behavior of the actual chip, where these signals behave as
      active low. For example, to read the CIDER register, the bus must
      expose 0xc0c0 during the address phase, which means BE[3:0]=4'b1100.
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Lukas Wunner <lukas@wunner.de>
      Cc: Petr Stetiar <ynezz@true.cz>
      Cc: YueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      58292104
    • Marek Vasut's avatar
      net: ks8851-ml: Fix 16-bit data access · edacb098
      Marek Vasut authored
      The packet data written to and read from Micrel KSZ8851-16MLLI must be
      byte-swapped in 16-bit mode, add this byte-swapping.
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Lukas Wunner <lukas@wunner.de>
      Cc: Petr Stetiar <ynezz@true.cz>
      Cc: YueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      edacb098
    • Marek Vasut's avatar
      net: ks8851-ml: Remove 8-bit bus accessors · 69233bba
      Marek Vasut authored
      This driver is mixing 8-bit and 16-bit bus accessors for reasons unknown,
      however the speculation is that this was some sort of attempt to support
      the 8-bit bus mode.
      
      As per the KS8851-16MLL documentation, all two registers accessed via the
      8-bit accessors are internally 16-bit registers, so reading them using
      16-bit accessors is fine. The KS_CCR read can be converted to 16-bit read
      outright, as it is already a concatenation of two 8-bit reads of that
      register. The KS_RXQCR accesses are 8-bit only, however writing the top
      8 bits of the register is OK as well, since the driver caches the entire
      16-bit register value anyway.
      
      Finally, the driver is not used by any hardware in the kernel right now.
      The only hardware available to me is one with 16-bit bus, so I have no
      way to test the 8-bit bus mode, however it is unlikely this ever really
      worked anyway. If the 8-bit bus mode is ever required, it can be easily
      added by adjusting the 16-bit accessors to do 2 consecutive accesses,
      which is how this should have been done from the beginning.
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Lukas Wunner <lukas@wunner.de>
      Cc: Petr Stetiar <ynezz@true.cz>
      Cc: YueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      69233bba
    • Matthieu Baerts's avatar
      mptcp: select CRYPTO · 357b41ca
      Matthieu Baerts authored
      Without this modification and if CRYPTO is not selected, we have this
      warning:
      
        WARNING: unmet direct dependencies detected for CRYPTO_LIB_SHA256
          Depends on [n]: CRYPTO [=n]
          Selected by [y]:
          - MPTCP [=y] && NET [=y] && INET [=y]
      
      MPTCP selects CRYPTO_LIB_SHA256 which seems to depend on CRYPTO. CRYPTO
      is now selected to avoid this issue.
      
      Even though the config system prints that warning, it looks like
      sha256.c is compiled and linked even without CONFIG_CRYPTO. Since MPTCP
      will end up needing CONFIG_CRYPTO anyway in future commits -- currently
      in preparation for net-next -- we propose to add it now to fix the
      warning.
      
      The dependency in the config system comes from the fact that
      CRYPTO_LIB_SHA256 is defined in "lib/crypto/Kconfig" which is sourced
      from "crypto/Kconfig" only if CRYPTO is selected.
      
      Fixes: 65492c5a (mptcp: move from sha1 (v0) to sha256 (v1))
      Signed-off-by: default avatarMatthieu Baerts <matthieu.baerts@tessares.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      357b41ca
    • David S. Miller's avatar
      Merge branch 'bonding-fix-bonding-interface-bugs' · c230978f
      David S. Miller authored
      Taehee Yoo says:
      
      ====================
      bonding: fix bonding interface bugs
      
      This patchset fixes lockdep problem in bonding interface
      
      1. The first patch is to add missing netdev_update_lockdep_key().
      After bond_release(), netdev_update_lockdep_key() should be called.
      But both ioctl path and attribute path don't call
      netdev_update_lockdep_key().
      This patch adds missing netdev_update_lockdep_key().
      
      2. The second patch is to export netdev_next_lower_dev_rcu symbol.
      netdev_next_lower_dev_rcu() is useful to implement the function,
      which is to walk their all lower interfaces.
      This patch is actually a preparing patch for the third patch.
      
      3. The last patch is to fix lockdep waring in bond_get_stats().
      The stats_lock uses a dynamic lockdep key.
      So, after "nomaster" operation, updating the dynamic lockdep key
      routine is needed. but it doesn't
      So, lockdep warning occurs.
      
      Change log:
      v1 -> v2:
       - Update headline from "fix bonding interface bugs"
         to "bonding: fix bonding interface bugs"
       - Drop a patch("bonding: do not collect slave's stats")
       - Add new patches
         - ("net: export netdev_next_lower_dev_rcu()")
         - ("bonding: fix lockdep warning in bond_get_stats()")
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c230978f
    • Taehee Yoo's avatar
      bonding: fix lockdep warning in bond_get_stats() · b3e80d44
      Taehee Yoo authored
      In the "struct bonding", there is stats_lock.
      This lock protects "bond_stats" in the "struct bonding".
      bond_stats is updated in the bond_get_stats() and this function would be
      executed concurrently. So, the lock is needed.
      
      Bonding interfaces would be nested.
      So, either stats_lock should use dynamic lockdep class key or stats_lock
      should be used by spin_lock_nested(). In the current code, stats_lock is
      using a dynamic lockdep class key.
      But there is no updating stats_lock_key routine So, lockdep warning
      will occur.
      
      Test commands:
          ip link add bond0 type bond
          ip link add bond1 type bond
          ip link set bond0 master bond1
          ip link set bond0 nomaster
          ip link set bond1 master bond0
      
      Splat looks like:
      [   38.420603][  T957] 5.5.0+ #394 Not tainted
      [   38.421074][  T957] ------------------------------------------------------
      [   38.421837][  T957] ip/957 is trying to acquire lock:
      [   38.422399][  T957] ffff888063262cd8 (&bond->stats_lock_key#2){+.+.}, at: bond_get_stats+0x90/0x4d0 [bonding]
      [   38.423528][  T957]
      [   38.423528][  T957] but task is already holding lock:
      [   38.424526][  T957] ffff888065fd2cd8 (&bond->stats_lock_key){+.+.}, at: bond_get_stats+0x90/0x4d0 [bonding]
      [   38.426075][  T957]
      [   38.426075][  T957] which lock already depends on the new lock.
      [   38.426075][  T957]
      [   38.428536][  T957]
      [   38.428536][  T957] the existing dependency chain (in reverse order) is:
      [   38.429475][  T957]
      [   38.429475][  T957] -> #1 (&bond->stats_lock_key){+.+.}:
      [   38.430273][  T957]        _raw_spin_lock+0x30/0x70
      [   38.430812][  T957]        bond_get_stats+0x90/0x4d0 [bonding]
      [   38.431451][  T957]        dev_get_stats+0x1ec/0x270
      [   38.432088][  T957]        bond_get_stats+0x1a5/0x4d0 [bonding]
      [   38.432767][  T957]        dev_get_stats+0x1ec/0x270
      [   38.433322][  T957]        rtnl_fill_stats+0x44/0xbe0
      [   38.433866][  T957]        rtnl_fill_ifinfo+0xeb2/0x3720
      [   38.434474][  T957]        rtmsg_ifinfo_build_skb+0xca/0x170
      [   38.435081][  T957]        rtmsg_ifinfo_event.part.33+0x1b/0xb0
      [   38.436848][  T957]        rtnetlink_event+0xcd/0x120
      [   38.437455][  T957]        notifier_call_chain+0x90/0x160
      [   38.438067][  T957]        netdev_change_features+0x74/0xa0
      [   38.438708][  T957]        bond_compute_features.isra.45+0x4e6/0x6f0 [bonding]
      [   38.439522][  T957]        bond_enslave+0x3639/0x47b0 [bonding]
      [   38.440225][  T957]        do_setlink+0xaab/0x2ef0
      [   38.440786][  T957]        __rtnl_newlink+0x9c5/0x1270
      [   38.441463][  T957]        rtnl_newlink+0x65/0x90
      [   38.442075][  T957]        rtnetlink_rcv_msg+0x4a8/0x890
      [   38.442774][  T957]        netlink_rcv_skb+0x121/0x350
      [   38.443451][  T957]        netlink_unicast+0x42e/0x610
      [   38.444282][  T957]        netlink_sendmsg+0x65a/0xb90
      [   38.444992][  T957]        ____sys_sendmsg+0x5ce/0x7a0
      [   38.445679][  T957]        ___sys_sendmsg+0x10f/0x1b0
      [   38.446365][  T957]        __sys_sendmsg+0xc6/0x150
      [   38.447007][  T957]        do_syscall_64+0x99/0x4f0
      [   38.447668][  T957]        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      [   38.448538][  T957]
      [   38.448538][  T957] -> #0 (&bond->stats_lock_key#2){+.+.}:
      [   38.449554][  T957]        __lock_acquire+0x2d8d/0x3de0
      [   38.450148][  T957]        lock_acquire+0x164/0x3b0
      [   38.450711][  T957]        _raw_spin_lock+0x30/0x70
      [   38.451292][  T957]        bond_get_stats+0x90/0x4d0 [bonding]
      [   38.451950][  T957]        dev_get_stats+0x1ec/0x270
      [   38.452425][  T957]        bond_get_stats+0x1a5/0x4d0 [bonding]
      [   38.453362][  T957]        dev_get_stats+0x1ec/0x270
      [   38.453825][  T957]        rtnl_fill_stats+0x44/0xbe0
      [   38.454390][  T957]        rtnl_fill_ifinfo+0xeb2/0x3720
      [   38.456257][  T957]        rtmsg_ifinfo_build_skb+0xca/0x170
      [   38.456998][  T957]        rtmsg_ifinfo_event.part.33+0x1b/0xb0
      [   38.459351][  T957]        rtnetlink_event+0xcd/0x120
      [   38.460086][  T957]        notifier_call_chain+0x90/0x160
      [   38.460829][  T957]        netdev_change_features+0x74/0xa0
      [   38.461752][  T957]        bond_compute_features.isra.45+0x4e6/0x6f0 [bonding]
      [   38.462705][  T957]        bond_enslave+0x3639/0x47b0 [bonding]
      [   38.463476][  T957]        do_setlink+0xaab/0x2ef0
      [   38.464141][  T957]        __rtnl_newlink+0x9c5/0x1270
      [   38.464897][  T957]        rtnl_newlink+0x65/0x90
      [   38.465522][  T957]        rtnetlink_rcv_msg+0x4a8/0x890
      [   38.466215][  T957]        netlink_rcv_skb+0x121/0x350
      [   38.466895][  T957]        netlink_unicast+0x42e/0x610
      [   38.467583][  T957]        netlink_sendmsg+0x65a/0xb90
      [   38.468285][  T957]        ____sys_sendmsg+0x5ce/0x7a0
      [   38.469202][  T957]        ___sys_sendmsg+0x10f/0x1b0
      [   38.469884][  T957]        __sys_sendmsg+0xc6/0x150
      [   38.470587][  T957]        do_syscall_64+0x99/0x4f0
      [   38.471245][  T957]        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      [   38.472093][  T957]
      [   38.472093][  T957] other info that might help us debug this:
      [   38.472093][  T957]
      [   38.473438][  T957]  Possible unsafe locking scenario:
      [   38.473438][  T957]
      [   38.474898][  T957]        CPU0                    CPU1
      [   38.476234][  T957]        ----                    ----
      [   38.480171][  T957]   lock(&bond->stats_lock_key);
      [   38.480808][  T957]                                lock(&bond->stats_lock_key#2);
      [   38.481791][  T957]                                lock(&bond->stats_lock_key);
      [   38.482754][  T957]   lock(&bond->stats_lock_key#2);
      [   38.483416][  T957]
      [   38.483416][  T957]  *** DEADLOCK ***
      [   38.483416][  T957]
      [   38.484505][  T957] 3 locks held by ip/957:
      [   38.485048][  T957]  #0: ffffffffbccf6230 (rtnl_mutex){+.+.}, at: rtnetlink_rcv_msg+0x457/0x890
      [   38.486198][  T957]  #1: ffff888065fd2cd8 (&bond->stats_lock_key){+.+.}, at: bond_get_stats+0x90/0x4d0 [bonding]
      [   38.487625][  T957]  #2: ffffffffbc9254c0 (rcu_read_lock){....}, at: bond_get_stats+0x5/0x4d0 [bonding]
      [   38.488897][  T957]
      [   38.488897][  T957] stack backtrace:
      [   38.489646][  T957] CPU: 1 PID: 957 Comm: ip Not tainted 5.5.0+ #394
      [   38.490497][  T957] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
      [   38.492810][  T957] Call Trace:
      [   38.493219][  T957]  dump_stack+0x96/0xdb
      [   38.493709][  T957]  check_noncircular+0x371/0x450
      [   38.494344][  T957]  ? lookup_address+0x60/0x60
      [   38.494923][  T957]  ? print_circular_bug.isra.35+0x310/0x310
      [   38.495699][  T957]  ? hlock_class+0x130/0x130
      [   38.496334][  T957]  ? __lock_acquire+0x2d8d/0x3de0
      [   38.496979][  T957]  __lock_acquire+0x2d8d/0x3de0
      [   38.497607][  T957]  ? register_lock_class+0x14d0/0x14d0
      [   38.498333][  T957]  ? check_chain_key+0x236/0x5d0
      [   38.499003][  T957]  lock_acquire+0x164/0x3b0
      [   38.499800][  T957]  ? bond_get_stats+0x90/0x4d0 [bonding]
      [   38.500706][  T957]  _raw_spin_lock+0x30/0x70
      [   38.501435][  T957]  ? bond_get_stats+0x90/0x4d0 [bonding]
      [   38.502311][  T957]  bond_get_stats+0x90/0x4d0 [bonding]
      [ ... ]
      
      But, there is another problem.
      The dynamic lockdep class key is protected by RTNL, but bond_get_stats()
      would be called outside of RTNL.
      So, it would use an invalid dynamic lockdep class key.
      
      In order to fix this issue, stats_lock uses spin_lock_nested() instead of
      a dynamic lockdep key.
      The bond_get_stats() calls bond_get_lowest_level_rcu() to get the correct
      nest level value, which will be used by spin_lock_nested().
      The "dev->lower_level" indicates lower nest level value, but this value
      is invalid outside of RTNL.
      So, bond_get_lowest_level_rcu() returns valid lower nest level value in
      the RCU critical section.
      bond_get_lowest_level_rcu() will be work only when LOCKDEP is enabled.
      
      Fixes: 089bca2c ("bonding: use dynamic lockdep key instead of subclass")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b3e80d44