1. 12 Oct, 2023 6 commits
  2. 11 Oct, 2023 9 commits
  3. 10 Oct, 2023 11 commits
  4. 09 Oct, 2023 5 commits
  5. 08 Oct, 2023 3 commits
  6. 07 Oct, 2023 6 commits
    • Dinghao Liu's avatar
      ieee802154: ca8210: Fix a potential UAF in ca8210_probe · f990874b
      Dinghao Liu authored
      If of_clk_add_provider() fails in ca8210_register_ext_clock(),
      it calls clk_unregister() to release priv->clk and returns an
      error. However, the caller ca8210_probe() then calls ca8210_remove(),
      where priv->clk is freed again in ca8210_unregister_ext_clock(). In
      this case, a use-after-free may happen in the second time we call
      clk_unregister().
      
      Fix this by removing the first clk_unregister(). Also, priv->clk could
      be an error code on failure of clk_register_fixed_rate(). Use
      IS_ERR_OR_NULL to catch this case in ca8210_unregister_ext_clock().
      
      Fixes: ded845a7 ("ieee802154: Add CA8210 IEEE 802.15.4 device driver")
      Signed-off-by: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
      Message-ID: <20231007033049.22353-1-dinghao.liu@zju.edu.cn>
      Signed-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
      f990874b
    • Daniel Borkmann's avatar
      selftests/bpf: Make seen_tc* variable tests more robust · 37345b85
      Daniel Borkmann authored
      Martin reported that on his local dev machine the test_tc_chain_mixed() fails as
      "test_tc_chain_mixed:FAIL:seen_tc5 unexpected seen_tc5: actual 1 != expected 0"
      and others occasionally, too.
      
      However, when running in a more isolated setup (qemu in particular), it works fine
      for him. The reason is that there is a small race-window where seen_tc* could turn
      into true for various test cases when there is background traffic, e.g. after the
      asserts they often get reset. In such case when subsequent detach takes place,
      unrelated background traffic could have already flipped the bool to true beforehand.
      
      Add a small helper tc_skel_reset_all_seen() to reset all bools before we do the ping
      test. At this point, everything is set up as expected and therefore no race can occur.
      All tc_{opts,links} tests continue to pass after this change.
      Reported-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/r/20231006220655.1653-7-daniel@iogearbox.netSigned-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
      37345b85
    • Daniel Borkmann's avatar
      selftests/bpf: Test query on empty mprog and pass revision into attach · 685446b0
      Daniel Borkmann authored
      Add a new test case to query on an empty bpf_mprog and pass the revision
      directly into expected_revision for attachment to assert that this does
      succeed.
      
        ./test_progs -t tc_opts
        [    1.406778] tsc: Refined TSC clocksource calibration: 3407.990 MHz
        [    1.408863] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x311fcaf6eb0, max_idle_ns: 440795321766 ns
        [    1.412419] clocksource: Switched to clocksource tsc
        [    1.428671] bpf_testmod: loading out-of-tree module taints kernel.
        [    1.430260] bpf_testmod: module verification failed: signature and/or required key missing - tainting kernel
        #252     tc_opts_after:OK
        #253     tc_opts_append:OK
        #254     tc_opts_basic:OK
        #255     tc_opts_before:OK
        #256     tc_opts_chain_classic:OK
        #257     tc_opts_chain_mixed:OK
        #258     tc_opts_delete_empty:OK
        #259     tc_opts_demixed:OK
        #260     tc_opts_detach:OK
        #261     tc_opts_detach_after:OK
        #262     tc_opts_detach_before:OK
        #263     tc_opts_dev_cleanup:OK
        #264     tc_opts_invalid:OK
        #265     tc_opts_max:OK
        #266     tc_opts_mixed:OK
        #267     tc_opts_prepend:OK
        #268     tc_opts_query:OK
        #269     tc_opts_query_attach:OK     <--- (new test)
        #270     tc_opts_replace:OK
        #271     tc_opts_revision:OK
        Summary: 20/0 PASSED, 0 SKIPPED, 0 FAILED
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/r/20231006220655.1653-6-daniel@iogearbox.netSigned-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
      685446b0
    • Daniel Borkmann's avatar
      selftests/bpf: Adapt assert_mprog_count to always expect 0 count · b7736826
      Daniel Borkmann authored
      Simplify __assert_mprog_count() to remove the -ENOENT corner case as the
      bpf_prog_query() now returns 0 when no bpf_mprog is attached. This also
      allows to convert a few test cases from using raw __assert_mprog_count()
      over to plain assert_mprog_count() helper.
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/r/20231006220655.1653-5-daniel@iogearbox.netSigned-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
      b7736826
    • Daniel Borkmann's avatar
      selftests/bpf: Test bpf_mprog query API via libbpf and raw syscall · f9b08790
      Daniel Borkmann authored
      Add a new test case which performs double query of the bpf_mprog through
      libbpf API, but also via raw bpf(2) syscall. This is testing to gather
      first the count and then in a subsequent probe the full information with
      the program array without clearing passed structs in between.
      
        # ./vmtest.sh -- ./test_progs -t tc_opts
        [...]
        ./test_progs -t tc_opts
        [    1.398818] tsc: Refined TSC clocksource calibration: 3407.999 MHz
        [    1.400263] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x311fd336761, max_idle_ns: 440795243819 ns
        [    1.402734] clocksource: Switched to clocksource tsc
        [    1.426639] bpf_testmod: loading out-of-tree module taints kernel.
        [    1.428112] bpf_testmod: module verification failed: signature and/or required key missing - tainting kernel
        #252     tc_opts_after:OK
        #253     tc_opts_append:OK
        #254     tc_opts_basic:OK
        #255     tc_opts_before:OK
        #256     tc_opts_chain_classic:OK
        #257     tc_opts_chain_mixed:OK
        #258     tc_opts_delete_empty:OK
        #259     tc_opts_demixed:OK
        #260     tc_opts_detach:OK
        #261     tc_opts_detach_after:OK
        #262     tc_opts_detach_before:OK
        #263     tc_opts_dev_cleanup:OK
        #264     tc_opts_invalid:OK
        #265     tc_opts_max:OK
        #266     tc_opts_mixed:OK
        #267     tc_opts_prepend:OK
        #268     tc_opts_query:OK            <--- (new test)
        #269     tc_opts_replace:OK
        #270     tc_opts_revision:OK
        Summary: 19/0 PASSED, 0 SKIPPED, 0 FAILED
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/r/20231006220655.1653-4-daniel@iogearbox.netSigned-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
      f9b08790
    • Lorenz Bauer's avatar
      bpf: Refuse unused attributes in bpf_prog_{attach,detach} · ba62d611
      Lorenz Bauer authored
      The recently added tcx attachment extended the BPF UAPI for attaching and
      detaching by a couple of fields. Those fields are currently only supported
      for tcx, other types like cgroups and flow dissector silently ignore the
      new fields except for the new flags.
      
      This is problematic once we extend bpf_mprog to older attachment types, since
      it's hard to figure out whether the syscall really was successful if the
      kernel silently ignores non-zero values.
      
      Explicitly reject non-zero fields relevant to bpf_mprog for attachment types
      which don't use the latter yet.
      
      Fixes: e420bed0 ("bpf: Add fd-based tcx multi-prog infra with link support")
      Signed-off-by: default avatarLorenz Bauer <lmb@isovalent.com>
      Co-developed-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/r/20231006220655.1653-3-daniel@iogearbox.netSigned-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
      ba62d611