06 Apr, 2019

1 commit

  • [ Upstream commit 8e2f311a68494a6677c1724bdcb10bada21af37c ]

    Following command:
    iptables -D FORWARD -m physdev ...
    causes connectivity loss in some setups.

    Reason is that iptables userspace will probe kernel for the module revision
    of the physdev patch, and physdev has an artificial dependency on
    br_netfilter (xt_physdev use makes no sense unless a br_netfilter module
    is loaded).

    This causes the "phydev" module to be loaded, which in turn enables the
    "call-iptables" infrastructure.

    bridged packets might then get dropped by the iptables ruleset.

    The better fix would be to change the "call-iptables" defaults to 0 and
    enforce explicit setting to 1, but that breaks backwards compatibility.

    This does the next best thing: add a request_module call to checkentry.
    This was a stray '-D ... -m physdev' won't activate br_netfilter
    anymore.

    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Sasha Levin

    Florian Westphal
     

27 Mar, 2019

1 commit

  • commit d824548dae220820bdf69b2d1561b7c4b072783f upstream.

    They are however frequently triggered by syzkaller, so remove them.

    ebtables userspace should never trigger any of these, so there is little
    value in making them pr_debug (or ratelimited).

    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Florian Westphal
     

14 Mar, 2019

1 commit

  • [ Upstream commit 2035f3ff8eaa29cfb5c8e2160b0f6e85eeb21a95 ]

    Unlike ip(6)tables ebtables only counts user-defined chains.

    The effect is that a 32bit ebtables binary on a 64bit kernel can do
    'ebtables -N FOO' only after adding at least one rule, else the request
    fails with -EINVAL.

    This is a similar fix as done in
    3f1e53abff84 ("netfilter: ebtables: don't attempt to allocate 0-sized compat array").

    Fixes: 7d7d7e02111e9 ("netfilter: compat: reject huge allocation requests")
    Reported-by: Francesco Ruggeri
    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Sasha Levin

    Florian Westphal
     

27 Feb, 2019

2 commits

  • commit 278e2148c07559dd4ad8602f22366d61eb2ee7b7 upstream.

    This reverts commit 5a2de63fd1a5 ("bridge: do not add port to router list
    when receives query with source 0.0.0.0") and commit 0fe5119e267f ("net:
    bridge: remove ipv6 zero address check in mcast queries")

    The reason is RFC 4541 is not a standard but suggestive. Currently we
    will elect 0.0.0.0 as Querier if there is no ip address configured on
    bridge. If we do not add the port which recives query with source
    0.0.0.0 to router list, the IGMP reports will not be about to forward
    to Querier, IGMP data will also not be able to forward to dest.

    As Nikolay suggested, revert this change first and add a boolopt api
    to disable none-zero election in future if needed.

    Reported-by: Linus Lüssing
    Reported-by: Sebastian Gottschall
    Fixes: 5a2de63fd1a5 ("bridge: do not add port to router list when receives query with source 0.0.0.0")
    Fixes: 0fe5119e267f ("net: bridge: remove ipv6 zero address check in mcast queries")
    Signed-off-by: Hangbin Liu
    Acked-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Hangbin Liu
     
  • [ Upstream commit 710ae72877378e7cde611efd30fe90502a6e5b30 ]

    Externally learned entries can be added by a user or by a switch driver
    that is notifying the bridge driver about entries that were learned in
    hardware.

    In the first case, the entries are not marked with the 'added_by_user'
    flag, which causes switch drivers to ignore them and not offload them.

    The 'added_by_user' flag can be set on externally learned FDB entries
    based on the 'swdev_notify' parameter in br_fdb_external_learn_add(),
    which effectively means if the created / updated FDB entry was added by
    a user or not.

    Fixes: 816a3bed9549 ("switchdev: Add fdb.added_by_user to switchdev notifications")
    Signed-off-by: Ido Schimmel
    Reported-by: Alexander Petrovskiy
    Reviewed-by: Petr Machata
    Cc: Roopa Prabhu
    Cc: Nikolay Aleksandrov
    Cc: bridge@lists.linux-foundation.org
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Ido Schimmel
     

31 Jan, 2019

2 commits

  • [ Upstream commit 6c57f0458022298e4da1729c67bd33ce41c14e7a ]

    In certain cases, pskb_trim_rcsum() may change skb pointers.
    Reinitialize header pointers afterwards to avoid potential
    use-after-frees. Add a note in the documentation of
    pskb_trim_rcsum(). Found by KASAN.

    Signed-off-by: Ross Lagerwall
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Ross Lagerwall
     
  • [ Upstream commit 28c1382fa28f2e2d9d0d6f25ae879b5af2ecbd03 ]

    The skb header should be set to ethernet header before using
    is_skb_forwardable. Because the ethernet header length has been
    considered in is_skb_forwardable(including dev->hard_header_len
    length).

    To reproduce the issue:
    1, add 2 ports on linux bridge br using following commands:
    $ brctl addbr br
    $ brctl addif br eth0
    $ brctl addif br eth1
    2, the MTU of eth0 and eth1 is 1500
    3, send a packet(Data 1480, UDP 8, IP 20, Ethernet 14, VLAN 4)
    from eth0 to eth1

    So the expect result is packet larger than 1500 cannot pass through
    eth0 and eth1. But currently, the packet passes through success, it
    means eth1's MTU limit doesn't take effect.

    Fixes: f6367b4660dd ("bridge: use is_skb_forwardable in forward path")
    Cc: bridge@lists.linux-foundation.org
    Cc: Nkolay Aleksandrov
    Cc: Roopa Prabhu
    Cc: Stephen Hemminger
    Signed-off-by: Yunjian Wang
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Yunjian Wang
     

26 Jan, 2019

1 commit

  • [ Upstream commit 41d1c8839e5f8cb781cc635f12791decee8271b7 ]

    Matteo reported forwarding issues inside the linux bridge,
    if the enslaved interfaces use the fq qdisc.

    Similar to commit 8203e2d844d3 ("net: clear skb->tstamp in
    forwarding paths"), we need to clear the tstamp field in
    the bridge forwarding path.

    Fixes: 80b14dee2bea ("net: Add a new socket option for a future transmit time.")
    Fixes: fb420d5d91c1 ("tcp/fq: move back to CLOCK_MONOTONIC")
    Reported-and-tested-by: Matteo Croce
    Signed-off-by: Paolo Abeni
    Acked-by: Nikolay Aleksandrov
    Acked-by: Roopa Prabhu
    Reviewed-by: Eric Dumazet
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Paolo Abeni
     

23 Jan, 2019

2 commits

  • commit e2c8d550a973bb34fc28bc8d0ec996f84562fb8a upstream.

    The [ip,ip6,arp]_tables use x_tables_info internally and the underlying
    memory is already accounted to kmemcg. Do the same for ebtables. The
    syzbot, by using setsockopt(EBT_SO_SET_ENTRIES), was able to OOM the
    whole system from a restricted memcg, a potential DoS.

    By accounting the ebt_table_info, the memory used for ebt_table_info can
    be contained within the memcg of the allocating process. However the
    lifetime of ebt_table_info is independent of the allocating process and
    is tied to the network namespace. So, the oom-killer will not be able to
    relieve the memory pressure due to ebt_table_info memory. The memory for
    ebt_table_info is allocated through vmalloc. Currently vmalloc does not
    handle the oom-killed allocating process correctly and one large
    allocation can bypass memcg limit enforcement. So, with this patch,
    at least the small allocations will be contained. For large allocations,
    we need to fix vmalloc.

    Reported-by: syzbot+7713f3aa67be76b1552c@syzkaller.appspotmail.com
    Signed-off-by: Shakeel Butt
    Reviewed-by: Kirill Tkhai
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Shakeel Butt
     
  • [ Upstream commit 4c84edc11b76590859b1e45dd676074c59602dc4 ]

    When handling DNAT'ed packets on a bridge device, the neighbour cache entry
    from lookup was used without checking its state. It means that a cache entry
    in the NUD_STALE state will be used directly instead of entering the NUD_DELAY
    state to confirm the reachability of the neighbor.

    This problem becomes worse after commit 2724680bceee ("neigh: Keep neighbour
    cache entries if number of them is small enough."), since all neighbour cache
    entries in the NUD_STALE state will be kept in the neighbour table as long as
    the number of cache entries does not exceed the value specified in gc_thresh1.

    This commit validates the state of a neighbour cache entry before using
    the entry.

    Signed-off-by: JianJhen Chen
    Reviewed-by: JinLin Chen
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    JianJhen Chen
     

04 Nov, 2018

2 commits

  • commit 0fe5119e267f3e3d8ac206895f5922195ec55a8a upstream.

    Recently a check was added which prevents marking of routers with zero
    source address, but for IPv6 that cannot happen as the relevant RFCs
    actually forbid such packets:
    RFC 2710 (MLDv1):
    "To be valid, the Query message MUST
    come from a link-local IPv6 Source Address, be at least 24 octets
    long, and have a correct MLD checksum."

    Same goes for RFC 3810.

    And also it can be seen as a requirement in ipv6_mc_check_mld_query()
    which is used by the bridge to validate the message before processing
    it. Thus any queries with :: source address won't be processed anyway.
    So just remove the check for zero IPv6 source address from the query
    processing function.

    Fixes: 5a2de63fd1a5 ("bridge: do not add port to router list when receives query with source 0.0.0.0")
    Signed-off-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller
    Cc: Hangbin Liu
    Signed-off-by: Greg Kroah-Hartman

    Nikolay Aleksandrov
     
  • [ Upstream commit 5a2de63fd1a59c30c02526d427bc014b98adf508 ]

    Based on RFC 4541, 2.1.1. IGMP Forwarding Rules

    The switch supporting IGMP snooping must maintain a list of
    multicast routers and the ports on which they are attached. This
    list can be constructed in any combination of the following ways:

    a) This list should be built by the snooping switch sending
    Multicast Router Solicitation messages as described in IGMP
    Multicast Router Discovery [MRDISC]. It may also snoop
    Multicast Router Advertisement messages sent by and to other
    nodes.

    b) The arrival port for IGMP Queries (sent by multicast routers)
    where the source address is not 0.0.0.0.

    We should not add the port to router list when receives query with source
    0.0.0.0.

    Reported-by: Ying Xu
    Signed-off-by: Hangbin Liu
    Acked-by: Nikolay Aleksandrov
    Acked-by: Roopa Prabhu
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Hangbin Liu
     

21 Sep, 2018

1 commit

  • For starters, the bridge netfilter code registers operations that
    are invoked any time nh_hook is called. Specifically, ip_sabotage_in
    watches for nested calls for NF_INET_PRE_ROUTING when a bridge is in
    the stack.

    Packet wise, the bridge netfilter hook runs first. br_nf_pre_routing
    allocates nf_bridge, sets in_prerouting to 1 and calls NF_HOOK for
    NF_INET_PRE_ROUTING. It's finish function, br_nf_pre_routing_finish,
    then resets in_prerouting flag to 0 and the packet continues up the
    stack. The packet eventually makes it to the VRF driver and it invokes
    nf_hook for NF_INET_PRE_ROUTING in case any rules have been added against
    the vrf device.

    Because of the registered operations the call to nf_hook causes
    ip_sabotage_in to be invoked. That function sees the nf_bridge on the
    skb and that in_prerouting is not set. Thinking it is an invalid nested
    call it steals (drops) the packet.

    Update ip_sabotage_in to recognize that the bridge or one of its upper
    devices (e.g., vlan) can be enslaved to a VRF (L3 master device) and
    allow the packet to go through the nf_hook a second time.

    Fixes: 73e20b761acf ("net: vrf: Add support for PREROUTING rules on vrf device")
    Reported-by: D'Souza, Nelson
    Signed-off-by: David Ahern
    Signed-off-by: Pablo Neira Ayuso

    David Ahern
     

07 Aug, 2018

1 commit


04 Aug, 2018

1 commit


24 Jul, 2018

2 commits

  • This patch adds a new port attribute - IFLA_BRPORT_BACKUP_PORT, which
    allows to set a backup port to be used for known unicast traffic if the
    port has gone carrier down. The backup pointer is rcu protected and set
    only under RTNL, a counter is maintained so when deleting a port we know
    how many other ports reference it as a backup and we remove it from all.
    Also the pointer is in the first cache line which is hot at the time of
    the check and thus in the common case we only add one more test.
    The backup port will be used only for the non-flooding case since
    it's a part of the bridge and the flooded packets will be forwarded to it
    anyway. To remove the forwarding just send a 0/non-existing backup port.
    This is used to avoid numerous scalability problems when using MLAG most
    notably if we have thousands of fdbs one would need to change all of them
    on port carrier going down which takes too long and causes a storm of fdb
    notifications (and again when the port comes back up). In a Multi-chassis
    Link Aggregation setup usually hosts are connected to two different
    switches which act as a single logical switch. Those switches usually have
    a control and backup link between them called peerlink which might be used
    for communication in case a host loses connectivity to one of them.
    We need a fast way to failover in case a host port goes down and currently
    none of the solutions (like bond) cannot fulfill the requirements because
    the participating ports are actually the "master" devices and must have the
    same peerlink as their backup interface and at the same time all of them
    must participate in the bridge device. As Roopa noted it's normal practice
    in routing called fast re-route where a precalculated backup path is used
    when the main one is down.
    Another use case of this is with EVPN, having a single vxlan device which
    is backup of every port. Due to the nature of master devices it's not
    currently possible to use one device as a backup for many and still have
    all of them participate in the bridge (which is master itself).
    More detailed information about MLAG is available at the link below.
    https://docs.cumulusnetworks.com/display/DOCS/Multi-Chassis+Link+Aggregation+-+MLAG

    Further explanation and a diagram by Roopa:
    Two switches acting in a MLAG pair are connected by the peerlink
    interface which is a bridge port.

    the config on one of the switches looks like the below. The other
    switch also has a similar config.
    eth0 is connected to one port on the server. And the server is
    connected to both switches.

    br0 -- team0---eth0
    |
    -- switch-peerlink

    Signed-off-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller

    Nikolay Aleksandrov
     
  • This patch adds a new alternative store callback for port sysfs options
    which takes a raw value (buf) and can use it directly. It is needed for the
    backup port sysfs support since we have to pass the device by its name.

    Signed-off-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller

    Nikolay Aleksandrov
     

21 Jul, 2018

1 commit


16 Jul, 2018

1 commit


16 Jun, 2018

1 commit

  • Pull networking fixes from David Miller:

    1) Various netfilter fixlets from Pablo and the netfilter team.

    2) Fix regression in IPVS caused by lack of PMTU exceptions on local
    routes in ipv6, from Julian Anastasov.

    3) Check pskb_trim_rcsum for failure in DSA, from Zhouyang Jia.

    4) Don't crash on poll in TLS, from Daniel Borkmann.

    5) Revert SO_REUSE{ADDR,PORT} change, it regresses various things
    including Avahi mDNS. From Bart Van Assche.

    6) Missing of_node_put in qcom/emac driver, from Yue Haibing.

    7) We lack checking of the TCP checking in one special case during SYN
    receive, from Frank van der Linden.

    8) Fix module init error paths of mac80211 hwsim, from Johannes Berg.

    9) Handle 802.1ad properly in stmmac driver, from Elad Nachman.

    10) Must grab HW caps before doing quirk checks in stmmac driver, from
    Jose Abreu.

    * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (81 commits)
    net: stmmac: Run HWIF Quirks after getting HW caps
    neighbour: skip NTF_EXT_LEARNED entries during forced gc
    net: cxgb3: add error handling for sysfs_create_group
    tls: fix waitall behavior in tls_sw_recvmsg
    tls: fix use-after-free in tls_push_record
    l2tp: filter out non-PPP sessions in pppol2tp_tunnel_ioctl()
    l2tp: reject creation of non-PPP sessions on L2TPv2 tunnels
    mlxsw: spectrum_switchdev: Fix port_vlan refcounting
    mlxsw: spectrum_router: Align with new route replace logic
    mlxsw: spectrum_router: Allow appending to dev-only routes
    ipv6: Only emit append events for appended routes
    stmmac: added support for 802.1ad vlan stripping
    cfg80211: fix rcu in cfg80211_unregister_wdev
    mac80211: Move up init of TXQs
    mac80211_hwsim: fix module init error paths
    cfg80211: initialize sinfo in cfg80211_get_station
    nl80211: fix some kernel doc tag mistakes
    hv_netvsc: Fix the variable sizes in ipsecv2 and rsc offload
    rds: avoid unenecessary cong_update in loop transport
    l2tp: clean up stale tunnel or session in pppol2tp_connect's error path
    ...

    Linus Torvalds
     

13 Jun, 2018

2 commits

  • The vmalloc() function has no 2-factor argument form, so multiplication
    factors need to be wrapped in array_size(). This patch replaces cases of:

    vmalloc(a * b)

    with:
    vmalloc(array_size(a, b))

    as well as handling cases of:

    vmalloc(a * b * c)

    with:

    vmalloc(array3_size(a, b, c))

    This does, however, attempt to ignore constant size factors like:

    vmalloc(4 * 1024)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    vmalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    vmalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    vmalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    vmalloc(
    - sizeof(TYPE) * (COUNT_ID)
    + array_size(COUNT_ID, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT_ID
    + array_size(COUNT_ID, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * (COUNT_CONST)
    + array_size(COUNT_CONST, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT_CONST
    + array_size(COUNT_CONST, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT_ID)
    + array_size(COUNT_ID, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT_ID
    + array_size(COUNT_ID, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT_CONST)
    + array_size(COUNT_CONST, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT_CONST
    + array_size(COUNT_CONST, sizeof(THING))
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    vmalloc(
    - SIZE * COUNT
    + array_size(COUNT, SIZE)
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    vmalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    vmalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    vmalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    vmalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    vmalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    vmalloc(C1 * C2 * C3, ...)
    |
    vmalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants.
    @@
    expression E1, E2;
    constant C1, C2;
    @@

    (
    vmalloc(C1 * C2, ...)
    |
    vmalloc(
    - E1 * E2
    + array_size(E1, E2)
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     
  • The kzalloc() function has a 2-factor argument form, kcalloc(). This
    patch replaces cases of:

    kzalloc(a * b, gfp)

    with:
    kcalloc(a * b, gfp)

    as well as handling cases of:

    kzalloc(a * b * c, gfp)

    with:

    kzalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kzalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kzalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kzalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kzalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kzalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kzalloc
    + kcalloc
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kzalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kzalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kzalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kzalloc(sizeof(THING) * C2, ...)
    |
    kzalloc(sizeof(TYPE) * C2, ...)
    |
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(C1 * C2, ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

12 Jun, 2018

1 commit

  • Pablo Neira Ayuso says:

    ====================
    Netfilter/IPVS fixes for net

    The following patchset contains Netfilter/IPVS fixes for your net tree:

    1) Reject non-null terminated helper names from xt_CT, from Gao Feng.

    2) Fix KASAN splat due to out-of-bound access from commit phase, from
    Alexey Kodanev.

    3) Missing conntrack hook registration on IPVS FTP helper, from Julian
    Anastasov.

    4) Incorrect skbuff allocation size in bridge nft_reject, from Taehee Yoo.

    5) Fix inverted check on packet xmit to non-local addresses, also from
    Julian.

    6) Fix ebtables alignment compat problems, from Alin Nastac.

    7) Hook mask checks are not correct in xt_set, from Serhey Popovych.

    8) Fix timeout listing of element in ipsets, from Jozsef.

    9) Cap maximum timeout value in ipset, also from Jozsef.

    10) Don't allow family option for hash:mac sets, from Florent Fourcot.

    11) Restrict ebtables to work with NFPROTO_BRIDGE targets only, this
    Florian.

    12) Another bug reported by KASAN in the rbtree set backend, from
    Taehee Yoo.

    13) Missing __IPS_MAX_BIT update doesn't include IPS_OFFLOAD_BIT.
    From Gao Feng.

    14) Missing initialization of match/target in ebtables, from Florian
    Westphal.

    15) Remove useless nft_dup.h file in include path, from C. Labbe.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

09 Jun, 2018

1 commit

  • Callers of br_fdb_find() need to hold the hash lock, which
    br_fdb_find_port() doesn't do. However, since br_fdb_find_port() is not
    doing any actual FDB manipulation, the hash lock is not really needed at
    all. So convert to br_fdb_find_rcu(), surrounded by rcu_read_lock() /
    _unlock() pair.

    The device pointer copied from inside the FDB entry is then kept alive
    by the RTNL lock, which br_fdb_find_port() asserts.

    Fixes: 4d4fd36126d6 ("net: bridge: Publish bridge accessor functions")
    Signed-off-by: Petr Machata
    Acked-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller

    Petr Machata
     

08 Jun, 2018

1 commit

  • syzbot reports following splat:

    BUG: KMSAN: uninit-value in ebt_stp_mt_check+0x24b/0x450
    net/bridge/netfilter/ebt_stp.c:162
    ebt_stp_mt_check+0x24b/0x450 net/bridge/netfilter/ebt_stp.c:162
    xt_check_match+0x1438/0x1650 net/netfilter/x_tables.c:506
    ebt_check_match net/bridge/netfilter/ebtables.c:372 [inline]
    ebt_check_entry net/bridge/netfilter/ebtables.c:702 [inline]

    The uninitialised access is
    xt_mtchk_param->nft_compat

    ... which should be set to 0.
    Fix it by zeroing the struct beforehand, same for tgchk.

    ip(6)tables targetinfo uses c99-style initialiser, so no change
    needed there.

    Reported-by: syzbot+da4494182233c23a5fcf@syzkaller.appspotmail.com
    Fixes: 55917a21d0cc0 ("netfilter: x_tables: add context to know if extension runs from nft_compat")
    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso

    Florian Westphal
     

07 Jun, 2018

2 commits

  • Pull networking updates from David Miller:

    1) Add Maglev hashing scheduler to IPVS, from Inju Song.

    2) Lots of new TC subsystem tests from Roman Mashak.

    3) Add TCP zero copy receive and fix delayed acks and autotuning with
    SO_RCVLOWAT, from Eric Dumazet.

    4) Add XDP_REDIRECT support to mlx5 driver, from Jesper Dangaard
    Brouer.

    5) Add ttl inherit support to vxlan, from Hangbin Liu.

    6) Properly separate ipv6 routes into their logically independant
    components. fib6_info for the routing table, and fib6_nh for sets of
    nexthops, which thus can be shared. From David Ahern.

    7) Add bpf_xdp_adjust_tail helper, which can be used to generate ICMP
    messages from XDP programs. From Nikita V. Shirokov.

    8) Lots of long overdue cleanups to the r8169 driver, from Heiner
    Kallweit.

    9) Add BTF ("BPF Type Format"), from Martin KaFai Lau.

    10) Add traffic condition monitoring to iwlwifi, from Luca Coelho.

    11) Plumb extack down into fib_rules, from Roopa Prabhu.

    12) Add Flower classifier offload support to igb, from Vinicius Costa
    Gomes.

    13) Add UDP GSO support, from Willem de Bruijn.

    14) Add documentation for eBPF helpers, from Quentin Monnet.

    15) Add TLS tx offload to mlx5, from Ilya Lesokhin.

    16) Allow applications to be given the number of bytes available to read
    on a socket via a control message returned from recvmsg(), from
    Soheil Hassas Yeganeh.

    17) Add x86_32 eBPF JIT compiler, from Wang YanQing.

    18) Add AF_XDP sockets, with zerocopy support infrastructure as well.
    From Björn Töpel.

    19) Remove indirect load support from all of the BPF JITs and handle
    these operations in the verifier by translating them into native BPF
    instead. From Daniel Borkmann.

    20) Add GRO support to ipv6 gre tunnels, from Eran Ben Elisha.

    21) Allow XDP programs to do lookups in the main kernel routing tables
    for forwarding. From David Ahern.

    22) Allow drivers to store hardware state into an ELF section of kernel
    dump vmcore files, and use it in cxgb4. From Rahul Lakkireddy.

    23) Various RACK and loss detection improvements in TCP, from Yuchung
    Cheng.

    24) Add TCP SACK compression, from Eric Dumazet.

    25) Add User Mode Helper support and basic bpfilter infrastructure, from
    Alexei Starovoitov.

    26) Support ports and protocol values in RTM_GETROUTE, from Roopa
    Prabhu.

    27) Support bulking in ->ndo_xdp_xmit() API, from Jesper Dangaard
    Brouer.

    28) Add lots of forwarding selftests, from Petr Machata.

    29) Add generic network device failover driver, from Sridhar Samudrala.

    * ra.kernel.org:/pub/scm/linux/kernel/git/davem/net-next: (1959 commits)
    strparser: Add __strp_unpause and use it in ktls.
    rxrpc: Fix terminal retransmission connection ID to include the channel
    net: hns3: Optimize PF CMDQ interrupt switching process
    net: hns3: Fix for VF mailbox receiving unknown message
    net: hns3: Fix for VF mailbox cannot receiving PF response
    bnx2x: use the right constant
    Revert "net: sched: cls: Fix offloading when ingress dev is vxlan"
    net: dsa: b53: Fix for brcm tag issue in Cygnus SoC
    enic: fix UDP rss bits
    netdev-FAQ: clarify DaveM's position for stable backports
    rtnetlink: validate attributes in do_setlink()
    mlxsw: Add extack messages for port_{un, }split failures
    netdevsim: Add extack error message for devlink reload
    devlink: Add extack to reload and port_{un, }split operations
    net: metrics: add proper netlink validation
    ipmr: fix error path when ipmr_new_table fails
    ip6mr: only set ip6mr_table from setsockopt when ip6mr_new_table succeeds
    net: hns3: remove unused hclgevf_cfg_func_mta_filter
    netfilter: provide udp*_lib_lookup for nf_tproxy
    qed*: Utilize FW 8.37.2.0
    ...

    Linus Torvalds
     
  • Pull audit updates from Paul Moore:
    "Another reasonable chunk of audit changes for v4.18, thirteen patches
    in total.

    The thirteen patches can mostly be broken down into one of four
    categories: general bug fixes, accessor functions for audit state
    stored in the task_struct, negative filter matches on executable
    names, and extending the (relatively) new seccomp logging knobs to the
    audit subsystem.

    The main driver for the accessor functions from Richard are the
    changes we're working on to associate audit events with containers,
    but I think they have some standalone value too so I figured it would
    be good to get them in now.

    The seccomp/audit patches from Tyler apply the seccomp logging
    improvements from a few releases ago to audit's seccomp logging;
    starting with this patchset the changes in
    /proc/sys/kernel/seccomp/actions_logged should apply to both the
    standard kernel logging and audit.

    As usual, everything passes the audit-testsuite and it happens to
    merge cleanly with your tree"

    [ Heh, except it had trivial merge conflicts with the SELinux tree that
    also came in from Paul - Linus ]

    * tag 'audit-pr-20180605' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit:
    audit: Fix wrong task in comparison of session ID
    audit: use existing session info function
    audit: normalize loginuid read access
    audit: use new audit_context access funciton for seccomp_actions_logged
    audit: use inline function to set audit context
    audit: use inline function to get audit context
    audit: convert sessionid unset to a macro
    seccomp: Don't special case audited processes when logging
    seccomp: Audit attempts to modify the actions_logged sysctl
    seccomp: Configurable separator for the actions_logged string
    seccomp: Separate read and write code for actions_logged sysctl
    audit: allow not equal op for audit by executable
    audit: add syscall information to FEATURE_CHANGE records

    Linus Torvalds
     

06 Jun, 2018

1 commit

  • the ebtables evaluation loop expects targets to return
    positive values (jumps), or negative values (absolute verdicts).

    This is completely different from what xtables does.
    In xtables, targets are expected to return the standard netfilter
    verdicts, i.e. NF_DROP, NF_ACCEPT, etc.

    ebtables will consider these as jumps.

    Therefore reject any target found due to unspec fallback.
    v2: also reject watchers. ebtables ignores their return value, so
    a target that assumes skb ownership (and returns NF_STOLEN) causes
    use-after-free.

    The only watchers in the 'ebtables' front-end are log and nflog;
    both have AF_BRIDGE specific wrappers on kernel side.

    Reported-by: syzbot+2b43f681169a2a0d306a@syzkaller.appspotmail.com
    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso

    Florian Westphal
     

05 Jun, 2018

2 commits


03 Jun, 2018

1 commit


01 Jun, 2018

3 commits

  • A driver might need to react to changes in settings of brentry VLANs.
    Therefore send switchdev port notifications for these as well. Reuse
    SWITCHDEV_OBJ_ID_PORT_VLAN for this purpose. Listeners should use
    netif_is_bridge_master() on orig_dev to determine whether the
    notification is about a bridge port or a bridge.

    Signed-off-by: Petr Machata
    Reviewed-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller

    Petr Machata
     
  • Extract the code that deals with adding a preexisting VLAN to bridge CPU
    port to a separate function. A follow-up patch introduces a need to roll
    back operations in this block due to an error, and this split will make
    the error-handling code clearer.

    Signed-off-by: Petr Machata
    Reviewed-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller

    Petr Machata
     
  • A call to switchdev_port_obj_add() or switchdev_port_obj_del() involves
    initializing a struct switchdev_obj_port_vlan, a piece of code that
    repeats on each call site almost verbatim. While in the current codebase
    there is just one duplicated add call, the follow-up patches add more of
    both add and del calls.

    Thus to remove the duplication, extract the repetition into named
    functions and reuse.

    Signed-off-by: Petr Machata
    Reviewed-by: Vivien Didelot
    Reviewed-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller

    Petr Machata
     

26 May, 2018

1 commit

  • This patch adds support for a new port flag - BR_ISOLATED. If it is set
    then isolated ports cannot communicate between each other, but they can
    still communicate with non-isolated ports. The same can be achieved via
    ACLs but they can't scale with large number of ports and also the
    complexity of the rules grows. This feature can be used to achieve
    isolated vlan functionality (similar to pvlan) as well, though currently
    it will be port-wide (for all vlans on the port). The new test in
    should_deliver uses data that is already cache hot and the new boolean
    is used to avoid an additional source port test in should_deliver.

    Signed-off-by: Nikolay Aleksandrov
    Reviewed-by: Toshiaki Makita
    Signed-off-by: David S. Miller

    Nikolay Aleksandrov
     

22 May, 2018

1 commit

  • S390 bpf_jit.S is removed in net-next and had changes in 'net',
    since that code isn't used any more take the removal.

    TLS data structures split the TX and RX components in 'net-next',
    put the new struct members from the bug fix in 'net' into the RX
    part.

    The 'net-next' tree had some reworking of how the ERSPAN code works in
    the GRE tunneling code, overlapping with a one-line headroom
    calculation fix in 'net'.

    Overlapping changes in __sock_map_ctx_update_elem(), keep the bits
    that read the prog members via READ_ONCE() into local variables
    before using them.

    Signed-off-by: David S. Miller

    David S. Miller
     

17 May, 2018

1 commit

  • strlcpy() can't be safely used on a user-space provided string,
    as it can try to read beyond the buffer's end, if the latter is
    not NULL terminated.

    Leveraging the above, syzbot has been able to trigger the following
    splat:

    BUG: KASAN: stack-out-of-bounds in strlcpy include/linux/string.h:300
    [inline]
    BUG: KASAN: stack-out-of-bounds in compat_mtw_from_user
    net/bridge/netfilter/ebtables.c:1957 [inline]
    BUG: KASAN: stack-out-of-bounds in ebt_size_mwt
    net/bridge/netfilter/ebtables.c:2059 [inline]
    BUG: KASAN: stack-out-of-bounds in size_entry_mwt
    net/bridge/netfilter/ebtables.c:2155 [inline]
    BUG: KASAN: stack-out-of-bounds in compat_copy_entries+0x96c/0x14a0
    net/bridge/netfilter/ebtables.c:2194
    Write of size 33 at addr ffff8801b0abf888 by task syz-executor0/4504

    CPU: 0 PID: 4504 Comm: syz-executor0 Not tainted 4.17.0-rc2+ #40
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
    Google 01/01/2011
    Call Trace:
    __dump_stack lib/dump_stack.c:77 [inline]
    dump_stack+0x1b9/0x294 lib/dump_stack.c:113
    print_address_description+0x6c/0x20b mm/kasan/report.c:256
    kasan_report_error mm/kasan/report.c:354 [inline]
    kasan_report.cold.7+0x242/0x2fe mm/kasan/report.c:412
    check_memory_region_inline mm/kasan/kasan.c:260 [inline]
    check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267
    memcpy+0x37/0x50 mm/kasan/kasan.c:303
    strlcpy include/linux/string.h:300 [inline]
    compat_mtw_from_user net/bridge/netfilter/ebtables.c:1957 [inline]
    ebt_size_mwt net/bridge/netfilter/ebtables.c:2059 [inline]
    size_entry_mwt net/bridge/netfilter/ebtables.c:2155 [inline]
    compat_copy_entries+0x96c/0x14a0 net/bridge/netfilter/ebtables.c:2194
    compat_do_replace+0x483/0x900 net/bridge/netfilter/ebtables.c:2285
    compat_do_ebt_set_ctl+0x2ac/0x324 net/bridge/netfilter/ebtables.c:2367
    compat_nf_sockopt net/netfilter/nf_sockopt.c:144 [inline]
    compat_nf_setsockopt+0x9b/0x140 net/netfilter/nf_sockopt.c:156
    compat_ip_setsockopt+0xff/0x140 net/ipv4/ip_sockglue.c:1279
    inet_csk_compat_setsockopt+0x97/0x120 net/ipv4/inet_connection_sock.c:1041
    compat_tcp_setsockopt+0x49/0x80 net/ipv4/tcp.c:2901
    compat_sock_common_setsockopt+0xb4/0x150 net/core/sock.c:3050
    __compat_sys_setsockopt+0x1ab/0x7c0 net/compat.c:403
    __do_compat_sys_setsockopt net/compat.c:416 [inline]
    __se_compat_sys_setsockopt net/compat.c:413 [inline]
    __ia32_compat_sys_setsockopt+0xbd/0x150 net/compat.c:413
    do_syscall_32_irqs_on arch/x86/entry/common.c:323 [inline]
    do_fast_syscall_32+0x345/0xf9b arch/x86/entry/common.c:394
    entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139
    RIP: 0023:0xf7fb3cb9
    RSP: 002b:00000000fff0c26c EFLAGS: 00000282 ORIG_RAX: 000000000000016e
    RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000000000
    RDX: 0000000000000080 RSI: 0000000020000300 RDI: 00000000000005f4
    RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
    R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000

    The buggy address belongs to the page:
    page:ffffea0006c2afc0 count:0 mapcount:0 mapping:0000000000000000 index:0x0
    flags: 0x2fffc0000000000()
    raw: 02fffc0000000000 0000000000000000 0000000000000000 00000000ffffffff
    raw: 0000000000000000 ffffea0006c20101 0000000000000000 0000000000000000
    page dumped because: kasan: bad access detected

    Fix the issue replacing the unsafe function with strscpy() and
    taking care of possible errors.

    Fixes: 81e675c227ec ("netfilter: ebtables: add CONFIG_COMPAT support")
    Reported-and-tested-by: syzbot+4e42a04e0bc33cb6c087@syzkaller.appspotmail.com
    Signed-off-by: Paolo Abeni
    Signed-off-by: Pablo Neira Ayuso

    Paolo Abeni
     

15 May, 2018

1 commit

  • Recognizing that the audit context is an internal audit value, use an
    access function to retrieve the audit context pointer for the task
    rather than reaching directly into the task struct to get it.

    Signed-off-by: Richard Guy Briggs
    [PM: merge fuzz in auditsc.c and selinuxfs.c, checkpatch.pl fixes]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

14 May, 2018

1 commit

  • Pablo Neira Ayuso says:

    ====================
    Netfilter/IPVS fixes for net

    The following patchset contains Netfilter/IPVS fixes for your net tree,
    they are:

    1) Fix handling of simultaneous open TCP connection in conntrack,
    from Jozsef Kadlecsik.

    2) Insufficient sanitify check of xtables extension names, from
    Florian Westphal.

    3) Skip unnecessary synchronize_rcu() call when transaction log
    is already empty, from Florian Westphal.

    4) Incorrect destination mac validation in ebt_stp, from Stephen
    Hemminger.

    5) xtables module reference counter leak in nft_compat, from
    Florian Westphal.

    6) Incorrect connection reference counting logic in IPVS
    one-packet scheduler, from Julian Anastasov.

    7) Wrong stats for 32-bits CPU in IPVS, also from Julian.

    8) Calm down sparse error in netfilter core, also from Florian.

    9) Use nla_strlcpy to fix compilation warning in nfnetlink_acct
    and nfnetlink_cthelper, again from Florian.

    10) Missing module alias in icmp and icmp6 xtables extensions,
    from Florian Westphal.

    11) Base chain statistics in nf_tables may be unset/null, from Florian.

    12) Fix handling of large matchinfo size in nft_compat, this includes
    one preparation for before this fix. From Florian.

    13) Fix bogus EBUSY error when deleting chains due to incorrect reference
    counting from the preparation phase of the two-phase commit protocol.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

11 May, 2018

1 commit

  • Mirroring offload in mlxsw needs to check that a given VLAN is allowed
    to ingress the bridge device. br_vlan_get_info() is the function that is
    used for this, however currently it only supports bridge port devices.
    Extend it to support bridge masters as well.

    Signed-off-by: Petr Machata
    Signed-off-by: Ido Schimmel
    Acked-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller

    Petr Machata