linux/Documentation
Alexei Starovoitov 20c09d92fa bpf: Introduce kptr_rcu.
The life time of certain kernel structures like 'struct cgroup' is protected by RCU.
Hence it's safe to dereference them directly from __kptr tagged pointers in bpf maps.
The resulting pointer is MEM_RCU and can be passed to kfuncs that expect KF_RCU.
Derefrence of other kptr-s returns PTR_UNTRUSTED.

For example:
struct map_value {
   struct cgroup __kptr *cgrp;
};

SEC("tp_btf/cgroup_mkdir")
int BPF_PROG(test_cgrp_get_ancestors, struct cgroup *cgrp_arg, const char *path)
{
  struct cgroup *cg, *cg2;

  cg = bpf_cgroup_acquire(cgrp_arg); // cg is PTR_TRUSTED and ref_obj_id > 0
  bpf_kptr_xchg(&v->cgrp, cg);

  cg2 = v->cgrp; // This is new feature introduced by this patch.
  // cg2 is PTR_MAYBE_NULL | MEM_RCU.
  // When cg2 != NULL, it's a valid cgroup, but its percpu_ref could be zero

  if (cg2)
    bpf_cgroup_ancestor(cg2, level); // safe to do.
}

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Tejun Heo <tj@kernel.org>
Acked-by: David Vernet <void@manifault.com>
Link: https://lore.kernel.org/bpf/20230303041446.3630-4-alexei.starovoitov@gmail.com
2023-03-03 17:42:20 +01:00
..
ABI Networking changes for 6.3. 2023-02-21 18:24:12 -08:00
accel doc: add documentation for accel subsystem 2022-11-22 13:14:52 +02:00
accounting
admin-guide Networking changes for 6.3. 2023-02-21 18:24:12 -08:00
arc
arm ARM: s3c: remove all s3c24xx support 2023-01-16 09:26:05 +01:00
arm64 arm64 updates for 6.3: 2023-02-21 15:27:48 -08:00
block block: stub out and deprecated the capability attribute on the gendisk 2023-02-06 08:44:55 -07:00
bpf bpf: Introduce kptr_rcu. 2023-03-03 17:42:20 +01:00
cdrom
core-api Documentation: core-api: packing: correct spelling 2023-02-15 21:40:54 -08:00
cpu-freq cpufreq: Remove CVS version control contents from documentation 2022-12-06 12:24:51 +01:00
crypto crypto: doc - use correct function name 2022-11-04 17:35:44 +08:00
dev-tools linux-kselftest-kunit-next-6.2-rc1 2022-12-12 16:42:57 -08:00
devicetree Networking changes for 6.3. 2023-02-21 18:24:12 -08:00
doc-guide Merge branch 'alabaster-rb' into docs-mw 2022-10-18 16:29:50 -06:00
driver-api platform-drivers-x86 for v6.3-1 2023-02-21 17:32:50 -08:00
fault-injection debugfs: fix error when writing negative value to atomic_t debugfs file 2022-11-30 16:13:16 -08:00
fb docs/fb: Document current named modes 2022-11-15 10:07:40 +01:00
features m68k: Add kernel seccomp support 2023-01-30 16:40:15 +01:00
filesystems fsverity updates for 6.3 2023-02-20 12:33:41 -08:00
firmware_class
firmware-guide Documentation: firmware-guide: gpio-properties: Clarify Explicit and Implicit 2023-02-14 15:50:09 +01:00
fpga
gpu drm/amdgpu: add GART, GPUVM, and GTT to glossary 2022-12-02 10:05:33 -05:00
hid
hwmon hwmon: (aquacomputer_d5next) Add support for Quadro flow sensor pulses 2022-12-04 16:45:03 -08:00
i2c
ia64 docs: ia64: Fix a typo ("identify mappings") 2022-11-09 14:03:51 -07:00
iio
images
infiniband
input Merge branch 'next' into for-linus 2022-10-09 22:30:23 -07:00
isdn Documentation: isdn: correct spelling 2023-02-10 16:28:13 -08:00
kbuild docs: kbuild: remove mention to dropped $(objtree) feature 2023-01-09 07:34:37 +09:00
kernel-hacking docs: locking: Discourage from calling disable_irq() in atomic 2023-01-11 19:45:26 +01:00
leds
litmus-tests
livepatch
locking
loongarch This was a not-too-busy cycle for documentation; highlights include: 2022-12-12 17:18:50 -08:00
m68k
maintainer docs, nvme: add a feature and quirk policy document 2022-12-28 05:37:12 -10:00
mhi
mips
misc-devices
mm MM patches for 6.2-rc1. 2022-12-13 19:29:45 -08:00
netlabel
netlink netlink-specs: add rx-push to ethtool family 2023-02-14 20:49:27 -08:00
networking sfc: add devlink info support for ef100 2023-02-16 12:03:12 +01:00
nios2
nvdimm
nvme docs, nvme: add a feature and quirk policy document 2022-12-28 05:37:12 -10:00
openrisc
parisc
PCI cxl for 6.2 2022-12-12 13:55:31 -08:00
pcmcia
peci
power Power management updates for 6.3-rc1 2023-02-21 12:13:58 -08:00
powerpc docs: powerpc: add POWER9 and POWER10 to CPU families 2022-11-24 23:31:47 +11:00
process docs: netdev: convert to a non-FAQ document 2022-12-28 10:06:06 +00:00
RCU doc: Fix htmldocs build warnings of stallwarn.rst 2023-01-05 11:27:56 -08:00
riscv RISC-V Patches for the 6.2 Merge Window, Part 1 2022-12-14 15:23:49 -08:00
rust
s390 Documentation: s390: correct spelling 2023-02-10 10:55:30 +01:00
scheduler sched/documentation: Document the util clamp feature 2023-01-05 12:08:34 +01:00
scsi scsi: core: Change the return type of .eh_timed_out() 2022-10-22 03:25:59 +00:00
security KEYS: encrypted: fix key instantiation with user-provided data 2022-10-19 13:01:23 -04:00
sh
sound
sparc
sphinx docs: Fix the docs build with Sphinx 6.0 2023-01-06 13:04:00 -07:00
sphinx-static docs: Don't wire font sizes for HTML output 2022-11-01 15:59:40 -06:00
spi
staging docs: put atomic*.txt and memory-barriers.txt into the core-api book 2022-09-29 12:55:06 -06:00
target
timers Documentation: Replace del_timer/del_timer_sync() 2022-11-24 15:09:11 +01:00
tools Documentation/rv: Add verification/rv man pages 2022-12-09 18:06:24 -05:00
trace Trace probes updates for 6.2: 2022-12-21 18:57:24 -08:00
translations docs: locking: Discourage from calling disable_irq() in atomic 2023-01-11 19:45:26 +01:00
usb Documentation: USB: correct possessive "its" usage 2022-11-21 14:33:23 -07:00
userspace-api Networking changes for 6.3. 2023-02-21 18:24:12 -08:00
virt KVM/arm64 fixes for 6.2, take #3 2023-02-04 08:57:43 -05:00
w1
watchdog
x86 - Add support for a new AMD feature called slow memory bandwidth 2023-02-21 08:38:45 -08:00
xtensa
.gitignore
arch.rst
atomic_bitops.txt
atomic_t.txt
Changes
CodingStyle
conf.py bpf: Document usage of the new __bpf_kfunc macro 2023-02-02 00:25:14 +01:00
docutils.conf
dontdiff
index.rst Rust introduction for v6.1-rc1 2022-10-03 16:39:37 -07:00
Kconfig
Makefile doc: add texinfodocs and infodocs targets 2022-11-21 14:13:57 -07:00
memory-barriers.txt docs/memory-barriers.txt: Add a missed closing parenthesis 2022-10-18 15:14:52 -07:00
SubmittingPatches
subsystem-apis.rst doc: add documentation for accel subsystem 2022-11-22 13:14:52 +02:00