OpenCloudOS-Kernel/include
YiFei Zhu b44123b4a3 bpf: Add cgroup helpers bpf_{get,set}_retval to get/set syscall return value
The helpers continue to use int for retval because all the hooks
are int-returning rather than long-returning. The return value of
bpf_set_retval is int for future-proofing, in case in the future
there may be errors trying to set the retval.

After the previous patch, if a program rejects a syscall by
returning 0, an -EPERM will be generated no matter if the retval
is already set to -err. This patch change it being forced only if
retval is not -err. This is because we want to support, for
example, invoking bpf_set_retval(-EINVAL) and return 0, and have
the syscall return value be -EINVAL not -EPERM.

For BPF_PROG_CGROUP_INET_EGRESS_RUN_ARRAY, the prior behavior is
that, if the return value is NET_XMIT_DROP, the packet is silently
dropped. We preserve this behavior for backward compatibility
reasons, so even if an errno is set, the errno does not return to
caller. However, setting a non-err to retval cannot propagate so
this is not allowed and we return a -EFAULT in that case.

Signed-off-by: YiFei Zhu <zhuyifei@google.com>
Reviewed-by: Stanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/r/b4013fd5d16bed0b01977c1fafdeae12e1de61fb.1639619851.git.zhuyifei@google.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2022-01-19 12:51:30 -08:00
..
acpi Power management updates for 5.17-rc1 2022-01-10 20:34:00 -08:00
asm-generic Networking changes for 5.17. 2022-01-10 19:06:09 -08:00
clocksource ARM: 2021-11-02 11:24:14 -07:00
crypto random: early initialization of ChaCha constants 2022-01-07 00:25:25 +01:00
drm Merge tag 'drm-msm-next-2021-12-26' of ssh://gitlab.freedesktop.org/drm/msm into drm-next 2021-12-29 14:02:44 +10:00
dt-bindings SoC: Add support for StarFive JH7100 RISC-V SoC 2022-01-10 08:32:37 -08:00
keys
kunit include/kunit/test.h: replace kernel.h with the necessary inclusions 2021-11-09 10:02:49 -08:00
kvm
linux bpf: Add cgroup helpers bpf_{get,set}_retval to get/set syscall return value 2022-01-19 12:51:30 -08:00
math-emu
media media: dmxdev: drop unneeded <linux/kernel.h> inclusion from other headers 2021-12-14 16:19:04 +01:00
memory memory: renesas-rpc-if: Add support for RZ/G2L 2021-11-16 12:09:11 +01:00
misc
net net/netfilter: Add unstable CT lookup helpers for XDP and TC-BPF 2022-01-18 14:26:42 -08:00
pcmcia
ras
rdma RDMA/netlink: Add __maybe_unused to static inline in C file 2021-11-16 13:13:08 -04:00
scsi SCSI misc on 20211112 2021-11-12 12:25:50 -08:00
soc Networking changes for 5.17. 2022-01-10 19:06:09 -08:00
sound ASoC: Fixes for v5.16 2021-11-25 14:35:24 +01:00
target
trace net: skb: use kfree_skb_reason() in __udp4_lib_rcv() 2022-01-09 16:30:35 -08:00
uapi bpf: Add cgroup helpers bpf_{get,set}_retval to get/set syscall return value 2022-01-19 12:51:30 -08:00
vdso
video
xen xen/console: harden hvc_xen against event channel storms 2021-12-16 08:24:08 +01:00