lkml.org 
[lkml]   [2023]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v1] bpf: Add length check for SK_DIAG_BPF_STORAGE_REQ_MAP_FD parsing
On Sun, 23 Jul 2023 15:54:52 +0800 Lin Ma wrote:
> diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c
> index d4172534dfa8..6f1afbb394a6 100644
> --- a/net/core/bpf_sk_storage.c
> +++ b/net/core/bpf_sk_storage.c
> @@ -511,6 +511,11 @@ bpf_sk_storage_diag_alloc(const struct nlattr *nla_stgs)
> if (nla_type(nla) != SK_DIAG_BPF_STORAGE_REQ_MAP_FD)
> continue;
>
> + if (nla_len(nla) < sizeof(map_fd)) {
> + err = -EINVAL;
> + goto err_free;
> + }

You can move this check earlier, when the attributes are getting
counted. That way we can avoid the alloc/free on error.

\
 
 \ /
  Last update: 2023-07-25 00:15    [W:0.055 / U:0.540 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site