* replace 'syscall' with 'upper layers', still mention that it's being exported via syscall errno * describe what happens in set_retval(-EPERM) + return 1 * describe what happens with bind's 'return 3'
Showing the changes to tools/include/uapi/linux (1 of 2 files). Show all
Unified · Split
| @@ -5085,17 +5085,29 @@ union bpf_attr { · 5084 unmodified lines | |||
| 5085 | * | 5085 | * |
| 5086 | * int bpf_get_retval(void) | 5086 | * int bpf_get_retval(void) |
| 5087 | * Description | 5087 | * Description |
| 5088 | * Get the syscall's return value that will be returned to userspace. | 5088 | * Get the BPF program's return value that will be returned to the upper layers. |
| 5089 | * | 5089 | * |
| 5090 | * This helper is currently supported by cgroup programs only. | 5090 | * This helper is currently supported by cgroup programs and only by the hooks |
| 5091 | * where BPF program's return value is returned to the userspace via errno. | ||
| 5091 | * Return | 5092 | * Return |
| 5092 | * The syscall's return value. | 5093 | * The BPF program's return value. |
| 5093 | * | 5094 | * |
| 5094 | * int bpf_set_retval(int retval) | 5095 | * int bpf_set_retval(int retval) |
| 5095 | * Description | 5096 | * Description |
| 5096 | * Set the syscall's return value that will be returned to userspace. | 5097 | * Set the BPF program's return value that will be returned to the upper layers. |
| 5098 | * | ||
| 5099 | * This helper is currently supported by cgroup programs and only by the hooks | ||
| 5100 | * where BPF program's return value is returned to the userspace via errno. | ||
| 5101 | * | ||
| 5102 | * Note that there is the following corner case where the program exports an error | ||
| 5103 | * via bpf_set_retval but signals success via 'return 1': | ||
| 5104 | * | ||
| 5105 | * bpf_set_retval(-EPERM); | ||
| 5106 | * return 1; | ||
| 5107 | * | ||
| 5108 | * In this case, the BPF program's return value will use helper's -EPERM. This | ||
| 5109 | * still holds true for cgroup/bind{4,6} which supports extra 'return 3' success case. | ||
| 5097 | * | 5110 | * |
| 5098 | * This helper is currently supported by cgroup programs only. | ||
| 5099 | * Return | 5111 | * Return |
| 5100 | * 0 on success, or a negative error in case of failure. | 5112 | * 0 on success, or a negative error in case of failure. |
| 5101 | * | 5113 | * |