1. Aug 26, 2021
  2. Aug 25, 2021
  3. Aug 24, 2021
    • Yucong Sun's avatar
      selftests/bpf: Reduce flakyness in timer_mim · a6258837
      Yucong Sun authored
      
      
      This patch extends wait time in timer_mim. As observed in slow CI environment,
      it is possible to have interrupt/preemption long enough to cause the test to
      fail, almost 1 failure in 5 runs.
      
      Signed-off-by: default avatarYucong Sun <fallentree@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210823213629.3519641-1-fallentree@fb.com
      a6258837
    • Alexei Starovoitov's avatar
      Merge branch 'Refactor cgroup_bpf internals to use more specific attach_type' · 4ed589a2
      Alexei Starovoitov authored
      
      
      Dave Marchevsky says:
      
      ====================
      
      The cgroup_bpf struct has a few arrays (effective, progs, and flags) of
      size MAX_BPF_ATTACH_TYPE. These are meant to separate progs by their
      attach type, currently represented by the bpf_attach_type enum.
      
      There are some bpf_attach_type values which are not valid attach types
      for cgroup bpf programs. Programs with these attach types will never be
      handled by cgroup_bpf_{attach,detach} and thus will never be held in
      cgroup_bpf structs. Even if such programs did make it into their
      reserved slot in those arrays, they would never be executed.
      
      Accordingly we can migrate to a new internal cgroup_bpf-specific enum
      for these arrays, saving some bytes per cgroup and making it more
      obvious which BPF programs belong there. netns_bpf_attach_type is an
      existing example of this pattern, let's do similar for cgroup_bpf.
      
      v1->v2: Address Daniel's comments
      	* Reverse xmas tree ordering for def changes
      	* Helper macro to reduce to_cgroup_bpf_attach_type boilerplate
      		* checkpatch.pl complains: "ERROR: Macros with complex values should
      		be enclosed in parentheses". Found some existing macros (do 'git grep
      		"define case"') which get same complaint. Think it's fine to keep
      		as-is since it's immediately undef'd.
      	* Remove CG_BPF_ prefix from cgroup_bpf_attach_type
      		* Although I agree that the prefix is redundant, the de-prefixed
      		names feel a bit too 'general' given the internal use of the enum.
      		e.g. when someone sees CGROUP_INET6_BIND it's not obvious that it
      		should only be used in certain ways internally.
      		* Don't feel strongly about this, just my thoughts as a noob to the
      		internals.
      	* Rebase onto latest bpf-next/master
      		* No significant conflicts, some small boilerplate adjustments
      		needed to catch up to Andrii's "bpf: Refactor BPF_PROG_RUN_ARRAY
      		family of macros into functions" change
      ====================
      
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      4ed589a2
    • Dave Marchevsky's avatar
      bpf: Migrate cgroup_bpf to internal cgroup_bpf_attach_type enum · 6fc88c35
      Dave Marchevsky authored
      
      
      Add an enum (cgroup_bpf_attach_type) containing only valid cgroup_bpf
      attach types and a function to map bpf_attach_type values to the new
      enum. Inspired by netns_bpf_attach_type.
      
      Then, migrate cgroup_bpf to use cgroup_bpf_attach_type wherever
      possible.  Functionality is unchanged as attach_type_to_prog_type
      switches in bpf/syscall.c were preventing non-cgroup programs from
      making use of the invalid cgroup_bpf array slots.
      
      As a result struct cgroup_bpf uses 504 fewer bytes relative to when its
      arrays were sized using MAX_BPF_ATTACH_TYPE.
      
      bpf_cgroup_storage is notably not migrated as struct
      bpf_cgroup_storage_key is part of uapi and contains a bpf_attach_type
      member which is not meant to be opaque. Similarly, bpf_cgroup_link
      continues to report its bpf_attach_type member to userspace via fdinfo
      and bpf_link_info.
      
      To ease disambiguation, bpf_attach_type variables are renamed from
      'type' to 'atype' when changed to cgroup_bpf_attach_type.
      
      Signed-off-by: default avatarDave Marchevsky <davemarchevsky@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210819092420.1984861-2-davemarchevsky@fb.com
      6fc88c35
  4. Aug 23, 2021
    • Jiang Wang's avatar
      af_unix: Fix NULL pointer bug in unix_shutdown · d359902d
      Jiang Wang authored
      Commit 94531cfc ("af_unix: Add unix_stream_proto for sockmap")
      introduced a bug for af_unix SEQPACKET type. In unix_shutdown, the
      unhash function will call prot->unhash(), which is NULL for SEQPACKET.
      And kernel will panic. On ARM32, it will show following messages: (it
      likely affects x86 too).
      
      Fix the bug by checking the prot->unhash is NULL or not first.
      
      Kernel log:
      <--- cut here ---
       Unable to handle kernel NULL pointer dereference at virtual address
      00000000
       pgd = 2fba1ffb
       *pgd=00000000
       Internal error: Oops: 80000005 [#1] PREEMPT SMP THUMB2
       Modules linked in:
       CPU: 1 PID: 1999 Comm: falkon Tainted: G        W
      5.14.0-rc5-01175-g94531cfc-dirty #9240
       Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
       PC is at 0x0
       LR is at unix_shutdown+0x81/0x1a8
       pc : [<00000000>]    lr : [<c08f3311>]    psr: 600f0013
       sp : e45aff70  ip : e463a3c0  fp : beb54f04
       r10: 00000125  r9 : e45ae000  r8 : c4a56664
       r7 : 00000001  r6 : c4a56464  r5 : 00000001  r4 : c4a56400
       r3 : 00000000  r2 : c5a6b180  r1 : 00000000  r0 : c4a56400
       Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
       Control: 50c5387d  Table: 05aa804a  DAC: 00000051
       Register r0 information: slab PING start c4a56400 pointer offset 0
       Register r1 information: NULL pointer
       Register r2 information: slab task_struct start c5a6b180 pointer offset 0
       Register r3 information: NULL pointer
       Register r4 information: slab PING start c4a56400 pointer offset 0
       Register r5 information: non-paged memory
       Register r6 information: slab PING start c4a56400 pointer offset 100
       Register r7 information: non-paged memory
       Register r8 information: slab PING start c4a56400 pointer offset 612
       Register r9 information: non-slab/vmalloc memory
       Register r10 information: non-paged memory
       Register r11 information: non-paged memory
       Register r12 information: slab filp start e463a3c0 pointer offset 0
       Process falkon (pid: 1999, stack limit = 0x9ec48895)
       Stack: (0xe45aff70 to 0xe45b0000)
       ff60:                                     e45ae000 c5f26a00 00000000 00000125
       ff80: c0100264 c07f7fa3 beb54f04 fffffff7 00000001 e6f3fc0e b5e5e9ec beb54ec4
       ffa0: b5da0ccc c010024b b5e5e9ec beb54ec4 0000000f 00000000 00000000 beb54ebc
       ffc0: b5e5e9ec beb54ec4 b5da0ccc 00000125 beb54f58 00785238 beb5529c beb54f04
       ffe0: b5da1e24 beb54eac b301385c b62b6ee8 600f0030 0000000f 00000000 00000000
       [<c08f3311>] (unix_shutdown) from [<c07f7fa3>] (__sys_shutdown+0x2f/0x50)
       [<c07f7fa3>] (__sys_shutdown) from [<c010024b>]
      (__sys_trace_return+0x1/0x16)
       Exception stack(0xe45affa8 to 0xe45afff0)
      
      Fixes: 94531cfc
      
       ("af_unix: Add unix_stream_proto for sockmap")
      Reported-by: default avatarDmitry Osipenko <digetx@gmail.com>
      Signed-off-by: default avatarJiang Wang <jiang.wang@bytedance.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Tested-by: default avatarDmitry Osipenko <digetx@gmail.com>
      Acked-by: default avatarKuniyuki Iwashima <kuniyu@amazon.co.jp>
      Link: https://lore.kernel.org/bpf/20210821180738.1151155-1-jiang.wang@bytedance.com
      d359902d
  5. Aug 20, 2021