No functional changes. It will be used later on to copy prog array into a temporary kernel buffer. I'm also changing its return type to errno to be consistent with the rest of the similar helpers. Signed-off-by: Stanislav Fomichev <sdf@xxxxxxxxxx> --- include/linux/bpf.h | 2 ++ kernel/bpf/core.c | 14 ++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 456f33b9d205..b5a3d95d2657 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -1779,6 +1779,8 @@ void bpf_prog_array_free(struct bpf_prog_array *progs); void bpf_prog_array_free_sleepable(struct bpf_prog_array *progs); int bpf_prog_array_length(struct bpf_prog_array *progs); bool bpf_prog_array_is_empty(struct bpf_prog_array *array); +int bpf_prog_array_copy_core(struct bpf_prog_array *array, + u32 *prog_ids, u32 request_cnt); int bpf_prog_array_copy_to_user(struct bpf_prog_array *progs, __u32 __user *prog_ids, u32 cnt); diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 7421487422d4..5793d6df30c6 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -2306,9 +2306,8 @@ bool bpf_prog_array_is_empty(struct bpf_prog_array *array) return true; } -static bool bpf_prog_array_copy_core(struct bpf_prog_array *array, - u32 *prog_ids, - u32 request_cnt) +int bpf_prog_array_copy_core(struct bpf_prog_array *array, + u32 *prog_ids, u32 request_cnt) { struct bpf_prog_array_item *item; int i = 0; @@ -2323,14 +2322,14 @@ static bool bpf_prog_array_copy_core(struct bpf_prog_array *array, } } - return !!(item->prog); + return !!(item->prog) ? -ENOSPC : 0; } int bpf_prog_array_copy_to_user(struct bpf_prog_array *array, __u32 __user *prog_ids, u32 cnt) { unsigned long err = 0; - bool nospc; + int nospc; u32 *ids; /* users of this function are doing: @@ -2348,7 +2347,7 @@ int bpf_prog_array_copy_to_user(struct bpf_prog_array *array, if (err) return -EFAULT; if (nospc) - return -ENOSPC; + return nospc; return 0; } @@ -2506,8 +2505,7 @@ int bpf_prog_array_copy_info(struct bpf_prog_array *array, return 0; /* this function is called under trace/bpf_trace.c: bpf_event_mutex */ - return bpf_prog_array_copy_core(array, prog_ids, request_cnt) ? -ENOSPC - : 0; + return bpf_prog_array_copy_core(array, prog_ids, request_cnt); } void __bpf_free_used_maps(struct bpf_prog_aux *aux, -- 2.40.1.521.gf1e218fcd8-goog