10 Oct, 2020

2 commits

  • Add a new attribute NLMSGERR_ATTR_POLICY to the extended ACK
    to advertise the policy, e.g. if an attribute was out of range,
    you'll know the range that's permissible.

    Add new NL_SET_ERR_MSG_ATTR_POL() and NL_SET_ERR_MSG_ATTR_POL()
    macros to set this, since realistically it's only useful to do
    this when the bad attribute (offset) is also returned.

    Use it in lib/nlattr.c which practically does all the policy
    validation.

    v2:
    - add and use netlink_policy_dump_attr_size_estimate()
    v3:
    - remove redundant break
    v4:
    - really remove redundant break ... sorry

    Reviewed-by: Jakub Kicinski
    Signed-off-by: Johannes Berg
    Signed-off-by: Jakub Kicinski

    Johannes Berg
     
  • Refactor the per-attribute policy writing into a new
    helper function, to be used later for dumping out the
    policy of a rejected attribute.

    v2:
    - fix some indentation
    v3:
    - change variable order in netlink_policy_dump_write()

    Reviewed-by: Jakub Kicinski
    Signed-off-by: Johannes Berg
    Signed-off-by: Jakub Kicinski

    Johannes Berg
     

06 Oct, 2020

1 commit

  • We don't have good validation policy for existing unsigned int attrs
    which serve as flags (for new ones we could use NLA_BITFIELD32).
    With increased use of policy dumping having the validation be
    expressed as part of the policy is important. Add validation
    policy in form of a mask of supported/valid bits.

    Support u64 in the uAPI to be future-proof, but really for now
    the embedded mask member can only hold 32 bits, so anything with
    bit 32+ set will always fail validation.

    Signed-off-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Jakub Kicinski
     

04 Oct, 2020

5 commits

  • Right now CTRL_CMD_GETPOLICY can only dump the family-wide
    policy. Support dumping policy of a specific op.

    v3:
    - rebase after per-op policy export and handle that
    v2:
    - make cmd U32, just in case.
    v1:
    - don't echo op in the output in a naive way, this should
    make it cleaner to extend the output format for dumping
    policies for all the commands at once in the future.

    Signed-off-by: Jakub Kicinski
    Link: https://lore.kernel.org/r/20201001225933.1373426-11-kuba@kernel.org
    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • Add support for per-op policy dumping. The data is pretty much
    as before, except that now the assumption that the policy with
    index 0 is "the" policy no longer holds - you now need to look
    at the new CTRL_ATTR_OP_POLICY attribute which is a nested attr
    (indexed by op) containing attributes for do and dump policies.

    When a single op is requested, the CTRL_ATTR_OP_POLICY will be
    added in the same way, since do and dump policies may differ.

    v2:
    - conditionally advertise per-command policies only if there
    actually is a policy being used for the do/dump and it's
    present at all

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • We'll need this later for the per-op policy index dump.

    Reviewed-by: Jakub Kicinski
    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • Rework the policy dump code a bit to support adding multiple
    policies to a single dump, in order to e.g. support per-op
    policies in generic netlink.

    v2:
    - move kernel-doc to implementation [Jakub]
    - squash the first patch to not flip-flop on the prototype
    [Jakub]
    - merge netlink_policy_dump_get_policy_idx() with the old
    get_policy_idx() we already had
    - rebase without Jakub's patch to have per-op dump

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • The maxtype is really an integral part of the policy, and while we
    haven't gotten into a situation yet where this happens, it seems
    that some developer might eventually have two places pointing to
    identical policies, with different maxattr to exclude some attrs
    in one of the places.

    Even if not, it's really the right thing to compare both since the
    two data items fundamentally belong together.

    v2:
    - also do the proper comparison in get_policy_idx()

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     

03 Oct, 2020

8 commits

  • In preparation for adding a new attribute to CTRL_CMD_GETPOLICY
    split the policies for getpolicy and getfamily apart.

    This will cause a slight user-visible change in that dumping
    the policies will switch from per family to per op, but
    supposedly sniffer-type applications (which are the main use
    case for policy dumping thus far) should support both, anyway.

    Signed-off-by: Jakub Kicinski
    Reviewed-by: Johannes Berg
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • Attributes are already parsed based on the policy specified
    in the family and ready-to-use in info->attrs. No need to
    call genlmsg_parse() again.

    Signed-off-by: Jakub Kicinski
    Reviewed-by: Johannes Berg
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • Add policy to the struct genl_ops structure, this time
    with maxattr, so it can be used properly.

    Propagate .policy and .maxattr from the family
    in genl_get_cmd() if needed, this way the rest of the
    code does not have to worry if the policy is per op
    or global.

    Signed-off-by: Jakub Kicinski
    Reviewed-by: Johannes Berg
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • The structure of ctrl_dumppolicy() is clearly split into
    init and dumping. Move the init to a .start callback
    for clarity, it's a more idiomatic netlink dump code structure.

    Signed-off-by: Jakub Kicinski
    Reviewed-by: Johannes Berg
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • Whenever netlink dump uses more than 2 cb->args[] entries
    code gets hard to read. We're about to add more state to
    ctrl_dumppolicy() so create a structure.

    Since the structure is typed and clearly named we can remove
    the local fam_id variable and use ctx->fam_id directly.

    v3:
    - rebase onto explicit free fix
    v1:
    - s/nl_policy_dump/netlink_policy_dump_state/
    - forward declare struct netlink_policy_dump_state,
    and move from passing unsigned long to actual pointer type
    - add build bug on
    - u16 fam_id
    - s/args/ctx/

    Signed-off-by: Jakub Kicinski
    Reviewed-by: Johannes Berg
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • We want to add maxattr and policy back to genl_ops, to enable
    dumping per command policy to user space. This, however, would
    cause bloat for all the families with global policies. Introduce
    smaller version of ops (half the size of genl_ops). Translate
    these smaller ops into a full blown struct before use in the
    core.

    v1:
    - use struct assignment
    - put a full copy of the op in struct genl_dumpit_info
    - s/light/small/

    Signed-off-by: Jakub Kicinski
    Reviewed-by: Johannes Berg
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • Steffen Klassert says:

    ====================
    pull request (net-next): ipsec-next 2020-10-02

    1) Add a full xfrm compatible layer for 32-bit applications on
    64-bit kernels. From Dmitry Safonov.

    Please pull or let me know if there are problems.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     
  • [ Upstream commit a95bc734e60449e7b073ff7ff70c35083b290ae9 ]

    If userspace doesn't complete the policy dump, we leak the
    allocated state. Fix this.

    Fixes: d07dcf9aadd6 ("netlink: add infrastructure to expose policies to userspace")
    Signed-off-by: Johannes Berg
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Johannes Berg
     

24 Sep, 2020

1 commit

  • Modules those use netlink may supply a 2nd skb, (via frag_list)
    that contains an alternative data set meant for applications
    using 32bit compatibility mode.

    In such a case, netlink_recvmsg will use this 2nd skb instead of the
    original one.

    Without this patch, such compat applications will retrieve
    all netlink dump data, but will then get an unexpected EOF.

    Cc: Johannes Berg
    Signed-off-by: Florian Westphal
    Signed-off-by: Dmitry Safonov
    Reviewed-by: Johannes Berg
    Signed-off-by: Steffen Klassert

    Dmitry Safonov
     

18 Sep, 2020

1 commit


05 Sep, 2020

1 commit

  • We got slightly different patches removing a double word
    in a comment in net/ipv4/raw.c - picked the version from net.

    Simple conflict in drivers/net/ethernet/ibm/ibmvnic.c. Use cached
    values instead of VNIC login response buffer (following what
    commit 507ebe6444a4 ("ibmvnic: Fix use-after-free of VNIC login
    response buffer") did).

    Signed-off-by: Jakub Kicinski

    Jakub Kicinski
     

04 Sep, 2020

1 commit

  • Pull networking fixes from David Miller:

    1) Use netif_rx_ni() when necessary in batman-adv stack, from Jussi
    Kivilinna.

    2) Fix loss of RTT samples in rxrpc, from David Howells.

    3) Memory leak in hns_nic_dev_probe(), from Dignhao Liu.

    4) ravb module cannot be unloaded, fix from Yuusuke Ashizuka.

    5) We disable BH for too lokng in sctp_get_port_local(), add a
    cond_resched() here as well, from Xin Long.

    6) Fix memory leak in st95hf_in_send_cmd, from Dinghao Liu.

    7) Out of bound access in bpf_raw_tp_link_fill_link_info(), from
    Yonghong Song.

    8) Missing of_node_put() in mt7530 DSA driver, from Sumera
    Priyadarsini.

    9) Fix crash in bnxt_fw_reset_task(), from Michael Chan.

    10) Fix geneve tunnel checksumming bug in hns3, from Yi Li.

    11) Memory leak in rxkad_verify_response, from Dinghao Liu.

    12) In tipc, don't use smp_processor_id() in preemptible context. From
    Tuong Lien.

    13) Fix signedness issue in mlx4 memory allocation, from Shung-Hsi Yu.

    14) Missing clk_disable_prepare() in gemini driver, from Dan Carpenter.

    15) Fix ABI mismatch between driver and firmware in nfp, from Louis
    Peens.

    * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (110 commits)
    net/smc: fix sock refcounting in case of termination
    net/smc: reset sndbuf_desc if freed
    net/smc: set rx_off for SMCR explicitly
    net/smc: fix toleration of fake add_link messages
    tg3: Fix soft lockup when tg3_reset_task() fails.
    doc: net: dsa: Fix typo in config code sample
    net: dp83867: Fix WoL SecureOn password
    nfp: flower: fix ABI mismatch between driver and firmware
    tipc: fix shutdown() of connectionless socket
    ipv6: Fix sysctl max for fib_multipath_hash_policy
    drivers/net/wan/hdlc: Change the default of hard_header_len to 0
    net: gemini: Fix another missing clk_disable_unprepare() in probe
    net: bcmgenet: fix mask check in bcmgenet_validate_flow()
    amd-xgbe: Add support for new port mode
    net: usb: dm9601: Add USB ID of Keenetic Plus DSL
    vhost: fix typo in error message
    net: ethernet: mlx4: Fix memory allocation in mlx4_buddy_init()
    pktgen: fix error message with wrong function name
    net: ethernet: ti: am65-cpsw: fix rmii 100Mbit link mode
    cxgb4: fix thermal zone device registration
    ...

    Linus Torvalds
     

01 Sep, 2020

1 commit

  • In the policy export for binary attributes I erroneously used
    a != NLA_VALIDATE_NONE comparison instead of checking for the
    two possible values, which meant that if a validation function
    pointer ended up aliasing the min/max as negatives, we'd hit
    a warning in nla_get_range_unsigned().

    Fix this to correctly check for only the two types that should
    be handled here, i.e. range with or without warn-too-long.

    Reported-by: syzbot+353df1490da781637624@syzkaller.appspotmail.com
    Fixes: 8aa26c575fb3 ("netlink: make NLA_BINARY validation more flexible")
    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     

28 Aug, 2020

1 commit

  • The data races were reported by KCSAN:
    BUG: KCSAN: data-race in netlink_recvmsg / skb_queue_tail

    write (marked) to 0xffff8c0986e5a8c8 of 8 bytes by interrupt on cpu 3:
    skb_queue_tail+0xcc/0x120
    __netlink_sendskb+0x55/0x80
    netlink_broadcast_filtered+0x465/0x7e0
    nlmsg_notify+0x8f/0x120
    rtnl_notify+0x8e/0xb0
    __neigh_notify+0xf2/0x120
    neigh_update+0x927/0xde0
    arp_process+0x8a3/0xf50
    arp_rcv+0x27c/0x3b0
    __netif_receive_skb_core+0x181c/0x1840
    __netif_receive_skb+0x38/0xf0
    netif_receive_skb_internal+0x77/0x1c0
    napi_gro_receive+0x1bd/0x1f0
    e1000_clean_rx_irq+0x538/0xb20 [e1000]
    e1000_clean+0x5e4/0x1340 [e1000]
    net_rx_action+0x310/0x9d0
    __do_softirq+0xe8/0x308
    irq_exit+0x109/0x110
    do_IRQ+0x7f/0xe0
    ret_from_intr+0x0/0x1d
    0xffffffffffffffff

    read to 0xffff8c0986e5a8c8 of 8 bytes by task 1463 on cpu 0:
    netlink_recvmsg+0x40b/0x820
    sock_recvmsg+0xc9/0xd0
    ___sys_recvmsg+0x1a4/0x3b0
    __sys_recvmsg+0x86/0x120
    __x64_sys_recvmsg+0x52/0x70
    do_syscall_64+0xb5/0x360
    entry_SYSCALL_64_after_hwframe+0x65/0xca
    0xffffffffffffffff

    Since the write is under sk_receive_queue->lock but the read
    is done as lockless. so fix it by using skb_queue_empty_lockless()
    instead of skb_queue_empty() for the read in netlink_rcv_wake()

    Signed-off-by: zhudi
    Signed-off-by: David S. Miller

    zhudi
     

25 Aug, 2020

1 commit


24 Aug, 2020

2 commits


20 Aug, 2020

1 commit

  • Evidently, when I did this previously, we didn't have more than
    10 policies and didn't run into the reallocation path, because
    it's missing a memset() for the unused policies. Fix that.

    Fixes: d07dcf9aadd6 ("netlink: add infrastructure to expose policies to userspace")
    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     

19 Aug, 2020

1 commit

  • Add range validation for NLA_BINARY, allowing validation of any
    combination of combination minimum or maximum lengths, using the
    existing NLA_POLICY_RANGE()/NLA_POLICY_FULL_RANGE() macros, just
    like for integers where the value is checked.

    Also make NLA_POLICY_EXACT_LEN(), NLA_POLICY_EXACT_LEN_WARN()
    and NLA_POLICY_MIN_LEN() special cases of this, removing the old
    types NLA_EXACT_LEN and NLA_MIN_LEN.

    This allows us to save some code where both minimum and maximum
    lengths are requires, currently the policy only allows maximum
    (NLA_BINARY), minimum (NLA_MIN_LEN) or exact (NLA_EXACT_LEN), so
    a range of lengths cannot be accepted and must be checked by the
    code that consumes the attributes later.

    Also, this allows advertising the correct ranges in the policy
    export to userspace. Here, NLA_MIN_LEN and NLA_EXACT_LEN already
    were special cases of NLA_BINARY with min and min/max length
    respectively.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     

07 Aug, 2020

1 commit

  • Pull thermal updates from Daniel Lezcano:

    - Add support to enable/disable the thermal zones resulting on core
    code and drivers cleanup (Andrzej Pietrasiewicz)

    - Add generic netlink support for userspace notifications: events,
    temperature and discovery commands (Daniel Lezcano)

    - Fix redundant initialization for a ret variable (Colin Ian King)

    - Remove the clock cooling code as it is used nowhere (Amit Kucheria)

    - Add the rcar_gen3_thermal's r8a774e1 support (Marian-Cristian
    Rotariu)

    - Replace all references to thermal.txt in the documentation to the
    corresponding yaml files (Amit Kucheria)

    - Add maintainer entry for the IPA (Lukasz Luba)

    - Add support for MSM8939 for the tsens (Shawn Guo)

    - Update power allocator and devfreq cooling to SPDX licensing (Lukasz
    Luba)

    - Add Cannon Lake Low Power PCH support (Sumeet Pawnikar)

    - Add tsensor support for V2 mediatek thermal system (Henry Yen)

    - Fix thermal zone lookup by ID for the core code (Thierry Reding)

    * tag 'thermal-v5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux: (40 commits)
    thermal: intel: intel_pch_thermal: Add Cannon Lake Low Power PCH support
    thermal: mediatek: Add tsensor support for V2 thermal system
    thermal: mediatek: Prepare to add support for other platforms
    thermal: Update power allocator and devfreq cooling to SPDX licensing
    MAINTAINERS: update entry to thermal governors file name prefixing
    thermal: core: Add thermal zone enable/disable notification
    thermal: qcom: tsens-v0_1: Add support for MSM8939
    dt-bindings: tsens: qcom: Document MSM8939 compatible
    thermal: core: Fix thermal zone lookup by ID
    thermal: int340x: processor_thermal: fix: update Jasper Lake PCI id
    thermal: imx8mm: Support module autoloading
    thermal: ti-soc-thermal: Fix reversed condition in ti_thermal_expose_sensor()
    MAINTAINERS: Add maintenance information for IPA
    thermal: rcar_gen3_thermal: Do not shadow thcode variable
    dt-bindings: thermal: Get rid of thermal.txt and replace references
    thermal: core: Move initialization after core initcall
    thermal: netlink: Improve the initcall ordering
    net: genetlink: Move initialization to core_initcall
    thermal: rcar_gen3_thermal: Add r8a774e1 support
    thermal/drivers/clock_cooling: Remove clock_cooling code
    ...

    Linus Torvalds
     

26 Jul, 2020

1 commit

  • There is no functionality change for this patch.
    Struct bpf_iter_reg is used to register a bpf_iter target,
    which includes information for both prog_load, link_create
    and seq_file creation.

    This patch puts fields related seq_file creation into
    a different structure. This will be useful for map
    elements iterator where one iterator covers different
    map types and different map types may have different
    seq_ops, init/fini private_data function and
    private_data size.

    Signed-off-by: Yonghong Song
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20200723184109.590030-1-yhs@fb.com

    Yonghong Song
     

25 Jul, 2020

1 commit

  • Rework the remaining setsockopt code to pass a sockptr_t instead of a
    plain user pointer. This removes the last remaining set_fs(KERNEL_DS)
    outside of architecture specific code.

    Signed-off-by: Christoph Hellwig
    Acked-by: Stefan Schmidt [ieee802154]
    Acked-by: Matthieu Baerts
    Signed-off-by: David S. Miller

    Christoph Hellwig
     

22 Jul, 2020

1 commit

  • One additional field btf_id is added to struct
    bpf_ctx_arg_aux to store the precomputed btf_ids.
    The btf_id is computed at build time with
    BTF_ID_LIST or BTF_ID_LIST_GLOBAL macro definitions.
    All existing bpf iterators are changed to used
    pre-compute btf_ids.

    Signed-off-by: Yonghong Song
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20200720163403.1393551-1-yhs@fb.com

    Yonghong Song
     

21 Jul, 2020

1 commit

  • The generic netlink is initialized far after the netlink protocol
    itself at subsys_initcall. The devlink is initialized at the same
    level, but after, as shown by a disassembly of the vmlinux:

    [ ... ]
    374 ffff8000115f22c0 :
    375 ffff8000115f22c4 :
    [ ... ]

    The function devlink_init() calls genl_register_family() before the
    generic netlink subsystem is initialized.

    As the generic netlink initcall level is set since 2005, it seems that
    was not a problem, but now we have the thermal framework initialized
    at the core_initcall level which creates the generic netlink family
    and sends a notification which leads to a subtle memory corruption
    only detectable when the CONFIG_INIT_ON_ALLOC_DEFAULT_ON option is set
    with the earlycon at init time.

    The thermal framework needs to be initialized early in order to begin
    the mitigation as soon as possible. Moving it to postcore_initcall is
    acceptable.

    This patch changes the initialization level for the generic netlink
    family to the core_initcall and comes after the netlink protocol
    initialization.

    Signed-off-by: Daniel Lezcano
    Acked-by: David S. Miller
    Tested-by: Marek Szyprowski
    Reviewed-by: Amit Kucheria
    Link: https://lore.kernel.org/r/20200715074120.8768-1-daniel.lezcano@linaro.org

    Daniel Lezcano
     

02 Jul, 2020

1 commit

  • A potential deadlock can occur during registering or unregistering a
    new generic netlink family between the main nl_table_lock and the
    cb_lock where each thread wants the lock held by the other, as
    demonstrated below.

    1) Thread 1 is performing a netlink_bind() operation on a socket. As part
    of this call, it will call netlink_lock_table(), incrementing the
    nl_table_users count to 1.
    2) Thread 2 is registering (or unregistering) a genl_family via the
    genl_(un)register_family() API. The cb_lock semaphore will be taken for
    writing.
    3) Thread 1 will call genl_bind() as part of the bind operation to handle
    subscribing to GENL multicast groups at the request of the user. It will
    attempt to take the cb_lock semaphore for reading, but it will fail and
    be scheduled away, waiting for Thread 2 to finish the write.
    4) Thread 2 will call netlink_table_grab() during the (un)registration
    call. However, as Thread 1 has incremented nl_table_users, it will not
    be able to proceed, and both threads will be stuck waiting for the
    other.

    genl_bind() is a noop, unless a genl_family implements the mcast_bind()
    function to handle setting up family-specific multicast operations. Since
    no one in-tree uses this functionality as Cong pointed out, simply removing
    the genl_bind() function will remove the possibility for deadlock, as there
    is no attempt by Thread 1 above to take the cb_lock semaphore.

    Fixes: c380d9a7afff ("genetlink: pass multicast bind/unbind to families")
    Suggested-by: Cong Wang
    Acked-by: Johannes Berg
    Reported-by: kernel test robot
    Signed-off-by: Sean Tranchetti
    Signed-off-by: David S. Miller

    Sean Tranchetti
     

30 Jun, 2020

1 commit

  • genl_family_rcv_msg_attrs_parse() reuses the global family->attrbuf
    when family->parallel_ops is false. However, family->attrbuf is not
    protected by any lock on the genl_family_rcv_msg_doit() code path.

    This leads to several different consequences, one of them is UAF,
    like the following:

    genl_family_rcv_msg_doit(): genl_start():
    genl_family_rcv_msg_attrs_parse()
    attrbuf = family->attrbuf
    __nlmsg_parse(attrbuf);
    genl_family_rcv_msg_attrs_parse()
    attrbuf = family->attrbuf
    __nlmsg_parse(attrbuf);
    info->attrs = attrs;
    cb->data = info;

    netlink_unicast_kernel():
    consume_skb()
    genl_lock_dumpit():
    genl_dumpit_info(cb)->attrs

    Note family->attrbuf is an array of pointers to the skb data, once
    the skb is freed, any dereference of family->attrbuf will be a UAF.

    Maybe we could serialize the family->attrbuf with genl_mutex too, but
    that would make the locking more complicated. Instead, we can just get
    rid of family->attrbuf and always allocate attrbuf from heap like the
    family->parallel_ops==true code path. This may add some performance
    overhead but comparing with taking the global genl_mutex, it still
    looks better.

    Fixes: 75cdbdd08900 ("net: ieee802154: have genetlink code to parse the attrs during dumpit")
    Fixes: 057af7071344 ("net: tipc: have genetlink code to parse the attrs during dumpit")
    Reported-and-tested-by: syzbot+3039ddf6d7b13daf3787@syzkaller.appspotmail.com
    Reported-and-tested-by: syzbot+80cad1e3cb4c41cde6ff@syzkaller.appspotmail.com
    Reported-and-tested-by: syzbot+736bcbcb11b60d0c0792@syzkaller.appspotmail.com
    Reported-and-tested-by: syzbot+520f8704db2b68091d44@syzkaller.appspotmail.com
    Reported-and-tested-by: syzbot+c96e4dfb32f8987fdeed@syzkaller.appspotmail.com
    Cc: Jiri Pirko
    Signed-off-by: Cong Wang
    Signed-off-by: David S. Miller

    Cong Wang
     

14 Jun, 2020

2 commits

  • Pull networking fixes from David Miller:

    1) Fix cfg80211 deadlock, from Johannes Berg.

    2) RXRPC fails to send norigications, from David Howells.

    3) MPTCP RM_ADDR parsing has an off by one pointer error, fix from
    Geliang Tang.

    4) Fix crash when using MSG_PEEK with sockmap, from Anny Hu.

    5) The ucc_geth driver needs __netdev_watchdog_up exported, from
    Valentin Longchamp.

    6) Fix hashtable memory leak in dccp, from Wang Hai.

    7) Fix how nexthops are marked as FDB nexthops, from David Ahern.

    8) Fix mptcp races between shutdown and recvmsg, from Paolo Abeni.

    9) Fix crashes in tipc_disc_rcv(), from Tuong Lien.

    10) Fix link speed reporting in iavf driver, from Brett Creeley.

    11) When a channel is used for XSK and then reused again later for XSK,
    we forget to clear out the relevant data structures in mlx5 which
    causes all kinds of problems. Fix from Maxim Mikityanskiy.

    12) Fix memory leak in genetlink, from Cong Wang.

    13) Disallow sockmap attachments to UDP sockets, it simply won't work.
    From Lorenz Bauer.

    * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (83 commits)
    net: ethernet: ti: ale: fix allmulti for nu type ale
    net: ethernet: ti: am65-cpsw-nuss: fix ale parameters init
    net: atm: Remove the error message according to the atomic context
    bpf: Undo internal BPF_PROBE_MEM in BPF insns dump
    libbpf: Support pre-initializing .bss global variables
    tools/bpftool: Fix skeleton codegen
    bpf: Fix memlock accounting for sock_hash
    bpf: sockmap: Don't attach programs to UDP sockets
    bpf: tcp: Recv() should return 0 when the peer socket is closed
    ibmvnic: Flush existing work items before device removal
    genetlink: clean up family attributes allocations
    net: ipa: header pad field only valid for AP->modem endpoint
    net: ipa: program upper nibbles of sequencer type
    net: ipa: fix modem LAN RX endpoint id
    net: ipa: program metadata mask differently
    ionic: add pcie_print_link_status
    rxrpc: Fix race between incoming ACK parser and retransmitter
    net/mlx5: E-Switch, Fix some error pointer dereferences
    net/mlx5: Don't fail driver on failure to create debugfs
    net/mlx5e: CT: Fix ipv6 nat header rewrite actions
    ...

    Linus Torvalds
     
  • Since commit 84af7a6194e4 ("checkpatch: kconfig: prefer 'help' over
    '---help---'"), the number of '---help---' has been gradually
    decreasing, but there are still more than 2400 instances.

    This commit finishes the conversion. While I touched the lines,
    I also fixed the indentation.

    There are a variety of indentation styles found.

    a) 4 spaces + '---help---'
    b) 7 spaces + '---help---'
    c) 8 spaces + '---help---'
    d) 1 space + 1 tab + '---help---'
    e) 1 tab + '---help---' (correct indentation)
    f) 1 tab + 1 space + '---help---'
    g) 1 tab + 2 spaces + '---help---'

    In order to convert all of them to 1 tab + 'help', I ran the
    following commend:

    $ find . -name 'Kconfig*' | xargs sed -i 's/^[[:space:]]*---help---/\thelp/'

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

13 Jun, 2020

1 commit

  • genl_family_rcv_msg_attrs_parse() and genl_family_rcv_msg_attrs_free()
    take a boolean parameter to determine whether allocate/free the family
    attrs. This is unnecessary as we can just check family->parallel_ops.
    More importantly, callers would not need to worry about pairing these
    parameters correctly after this patch.

    And this fixes a memory leak, as after commit c36f05559104
    ("genetlink: fix memory leaks in genl_family_rcv_msg_dumpit()")
    we call genl_family_rcv_msg_attrs_parse() for both parallel and
    non-parallel cases.

    Fixes: c36f05559104 ("genetlink: fix memory leaks in genl_family_rcv_msg_dumpit()")
    Reported-by: Ido Schimmel
    Signed-off-by: Cong Wang
    Reviewed-by: Ido Schimmel
    Tested-by: Ido Schimmel
    Signed-off-by: David S. Miller

    Cong Wang
     

05 Jun, 2020

1 commit

  • There are two kinds of memory leaks in genl_family_rcv_msg_dumpit():

    1. Before we call ops->start(), whenever an error happens, we forget
    to free the memory allocated in genl_family_rcv_msg_dumpit().

    2. When ops->start() fails, the 'info' has been already installed on
    the per socket control block, so we should not free it here. More
    importantly, nlk->cb_running is still false at this point, so
    netlink_sock_destruct() cannot free it either.

    The first kind of memory leaks is easier to resolve, but the second
    one requires some deeper thoughts.

    After reviewing how netfilter handles this, the most elegant solution
    I find is just to use a similar way to allocate the memory, that is,
    moving memory allocations from caller into ops->start(). With this,
    we can solve both kinds of memory leaks: for 1), no memory allocation
    happens before ops->start(); for 2), ops->start() handles its own
    failures and 'info' is installed to the socket control block only
    when success. The only ugliness here is we have to pass all local
    variables on stack via a struct, but this is not hard to understand.

    Alternatively, we can introduce a ops->free() to solve this too,
    but it is overkill as only genetlink has this problem so far.

    Fixes: 1927f41a22a0 ("net: genetlink: introduce dump info struct to be available during dumpit op")
    Reported-by: syzbot+21f04f481f449c8db840@syzkaller.appspotmail.com
    Cc: "Jason A. Donenfeld"
    Cc: Florian Westphal
    Cc: Pablo Neira Ayuso
    Cc: Jiri Pirko
    Cc: YueHaibing
    Cc: Shaochun Chen
    Signed-off-by: Cong Wang
    Signed-off-by: David S. Miller

    Cong Wang
     

14 May, 2020

2 commits

  • Commit b121b341e598 ("bpf: Add PTR_TO_BTF_ID_OR_NULL
    support") adds a field btf_id_or_null_non0_off to
    bpf_prog->aux structure to indicate that the
    first ctx argument is PTR_TO_BTF_ID reg_type and
    all others are PTR_TO_BTF_ID_OR_NULL.
    This approach does not really scale if we have
    other different reg types in the future, e.g.,
    a pointer to a buffer.

    This patch enables bpf_iter targets registering ctx argument
    reg types which may be different from the default one.
    For example, for pointers to structures, the default reg_type
    is PTR_TO_BTF_ID for tracing program. The target can register
    a particular pointer type as PTR_TO_BTF_ID_OR_NULL which can
    be used by the verifier to enforce accesses.

    Signed-off-by: Yonghong Song
    Signed-off-by: Alexei Starovoitov
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20200513180221.2949882-1-yhs@fb.com

    Yonghong Song
     
  • Currently bpf_iter_reg_target takes parameters from target
    and allocates memory to save them. This is really not
    necessary, esp. in the future we may grow information
    passed from targets to bpf_iter manager.

    The patch refactors the code so target reg_info
    becomes static and bpf_iter manager can just take
    a reference to it.

    Signed-off-by: Yonghong Song
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20200513180219.2949605-1-yhs@fb.com

    Yonghong Song