1. 13 5月, 2021 1 次提交
  2. 12 5月, 2021 31 次提交
  3. 11 5月, 2021 8 次提交
    • A
      bpf: Prevent writable memory-mapping of read-only ringbuf pages · 04ea3086
      Andrii Nakryiko 提交于
      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: 457f4436 ("bpf: Implement BPF ring buffer and verifier support for it")
      Reported-by: Ryota Shiga (Flatt Security)
      Reported-by: NThadeu Lima de Souza Cascardo <cascardo@canonical.com>
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      04ea3086
    • T
      bpf, ringbuf: Deny reserve of buffers larger than ringbuf · 4b81cceb
      Thadeu Lima de Souza Cascardo 提交于
      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: 457f4436 ("bpf: Implement BPF ring buffer and verifier support for it")
      Signed-off-by: NThadeu Lima de Souza Cascardo <cascardo@canonical.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NAndrii Nakryiko <andrii@kernel.org>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      4b81cceb
    • D
      bpf: Fix alu32 const subreg bound tracking on bitwise operations · 049c4e13
      Daniel Borkmann 提交于
      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: 3f50f132 ("bpf: Verifier, do explicit ALU32 bounds tracking")
      Fixes: 2921c90d ("bpf: Fix a verifier failure with xor")
      Reported-by: Manfred Paul (@_manfp)
      Reported-by: NThadeu Lima de Souza Cascardo <cascardo@canonical.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: NJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      049c4e13
    • M
      net: dsa: felix: re-enable TAS guard band mode · 297c4de6
      Michael Walle 提交于
      Commit 316bcffe ("net: dsa: felix: disable always guard band bit for
      TAS config") disabled the guard band and broke 802.3Qbv compliance.
      
      There are two issues here:
       (1) Without the guard band the end of the scheduling window could be
           overrun by a frame in transit.
       (2) Frames that don't fit into a configured window will still be sent.
      
      The reason for both issues is that the switch will schedule the _start_
      of a frame transmission inside the predefined window without taking the
      length of the frame into account. Thus, we'll need the guard band which
      will close the gate early, so that a complete frame can still be sent.
      Revert the commit and add a note.
      
      For a lengthy discussion see [1].
      
      [1] https://lore.kernel.org/netdev/c7618025da6723418c56a54fe4683bd7@walle.cc/
      
      Fixes: 316bcffe ("net: dsa: felix: disable always guard band bit for TAS config")
      Signed-off-by: NMichael Walle <michael@walle.cc>
      Reviewed-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      297c4de6
    • H
      tipc: make node link identity publish thread safe · 3058e01d
      Hoang Le 提交于
      The using of the node address and node link identity are not thread safe,
      meaning that two publications may be published the same values, as result
      one of them will get failure because of already existing in the name table.
      To avoid this we have to use the node address and node link identity values
      from inside the node item's write lock protection.
      
      Fixes: 50a3499a ("tipc: simplify signature of tipc_namtbl_publish()")
      Acked-by: NJon Maloy <jmaloy@redhat.com>
      Signed-off-by: NHoang Le <hoang.h.le@dektech.com.au>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3058e01d
    • V
      net: dsa: fix error code getting shifted with 4 in dsa_slave_get_sset_count · b94cbc90
      Vladimir Oltean 提交于
      DSA implements a bunch of 'standardized' ethtool statistics counters,
      namely tx_packets, tx_bytes, rx_packets, rx_bytes. So whatever the
      hardware driver returns in .get_sset_count(), we need to add 4 to that.
      
      That is ok, except that .get_sset_count() can return a negative error
      code, for example:
      
      b53_get_sset_count
      -> phy_ethtool_get_sset_count
         -> return -EIO
      
      -EIO is -5, and with 4 added to it, it becomes -1, aka -EPERM. One can
      imagine that certain error codes may even become positive, although
      based on code inspection I did not see instances of that.
      
      Check the error code first, if it is negative return it as-is.
      
      Based on a similar patch for dsa_master_get_strings from Dan Carpenter:
      https://patchwork.kernel.org/project/netdevbpf/patch/YJaSe3RPgn7gKxZv@mwanda/
      
      Fixes: 91da11f8 ("net: Distributed Switch Architecture protocol support")
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b94cbc90
    • V
      net/mlx4: Fix EEPROM dump support · db825fee
      Vladyslav Tarasiuk 提交于
      Fix SFP and QSFP* EEPROM queries by setting i2c_address, offset and page
      number correctly. For SFP set the following params:
      - I2C address for offsets 0-255 is 0x50. For 256-511 - 0x51.
      - Page number is zero.
      - Offset is 0-255.
      
      At the same time, QSFP* parameters are different:
      - I2C address is always 0x50.
      - Page number is not limited to zero.
      - Offset is 0-255 for page zero and 128-255 for others.
      
      To set parameters accordingly to cable used, implement function to query
      module ID and implement respective helper functions to set parameters
      correctly.
      
      Fixes: 135dd959 ("net/mlx4_en: ethtool, Remove unsupported SFP EEPROM high pages query")
      Signed-off-by: NVladyslav Tarasiuk <vladyslavt@nvidia.com>
      Signed-off-by: NTariq Toukan <tariqt@nvidia.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      db825fee
    • D
      net: dsa: fix a crash if ->get_sset_count() fails · a269333f
      Dan Carpenter 提交于
      If ds->ops->get_sset_count() fails then it "count" is a negative error
      code such as -EOPNOTSUPP.  Because "i" is an unsigned int, the negative
      error code is type promoted to a very high value and the loop will
      corrupt memory until the system crashes.
      
      Fix this by checking for error codes and changing the type of "i" to
      just int.
      
      Fixes: badf3ada ("net: dsa: Provide CPU port statistics to master netdev")
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a269333f