From: Jakub Kicinski <kuba@kernel.org>
To: Lin Ma <linma@zju.edu.cn>
Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
ast@kernel.org, martin.lau@kernel.org, yhs@fb.com,
andrii@kernel.org, void@manifault.com, houtao1@huawei.com,
laoar.shao@gmail.com, inwardvessel@gmail.com, kuniyu@amazon.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org
Subject: Re: [PATCH v1] bpf: Add length check for SK_DIAG_BPF_STORAGE_REQ_MAP_FD parsing
Date: Mon, 24 Jul 2023 15:15:07 -0700 [thread overview]
Message-ID: <20230724151507.6b725396@kernel.org> (raw)
In-Reply-To: <20230723075452.3711158-1-linma@zju.edu.cn>
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.
next prev parent reply other threads:[~2023-07-24 22:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-23 7:54 [PATCH v1] bpf: Add length check for SK_DIAG_BPF_STORAGE_REQ_MAP_FD parsing Lin Ma
2023-07-24 22:15 ` Jakub Kicinski [this message]
2023-07-25 0:12 ` Lin Ma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230724151507.6b725396@kernel.org \
--to=kuba@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=houtao1@huawei.com \
--cc=inwardvessel@gmail.com \
--cc=kuniyu@amazon.com \
--cc=laoar.shao@gmail.com \
--cc=linma@zju.edu.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=void@manifault.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.