kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf: Fix an error code in check_btf_func()
@ 2020-06-03 17:55 Dan Carpenter
  2020-06-03 17:57 ` Alexei Starovoitov
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2020-06-03 17:55 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song,
	Andrii Nakryiko, John Fastabend, KP Singh, bpf, kernel-janitors

This code returns success if kcalloc() but it should return -ENOMEM.

Fixes: 8c1b6e69dcc1 ("bpf: Compare BTF types of functions arguments with actual types")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 kernel/bpf/verifier.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 5c7bbaac81ef9..25363f134bf0c 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -7581,8 +7581,10 @@ static int check_btf_func(struct bpf_verifier_env *env,
 	if (!krecord)
 		return -ENOMEM;
 	info_aux = kcalloc(nfuncs, sizeof(*info_aux), GFP_KERNEL | __GFP_NOWARN);
-	if (!info_aux)
+	if (!info_aux) {
+		ret = -ENOMEM;
 		goto err_free;
+	}
 
 	for (i = 0; i < nfuncs; i++) {
 		ret = bpf_check_uarg_tail_zero(urecord, krec_size, urec_size);
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH bpf-next] bpf: Fix an error code in check_btf_func()
  2020-06-03 17:55 [PATCH bpf-next] bpf: Fix an error code in check_btf_func() Dan Carpenter
@ 2020-06-03 17:57 ` Alexei Starovoitov
  2020-06-04  8:54   ` [PATCH v2 " Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Alexei Starovoitov @ 2020-06-03 17:57 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, John Fastabend, KP Singh, bpf,
	kernel-janitors

On Wed, Jun 3, 2020 at 10:55 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> This code returns success if kcalloc() but it should return -ENOMEM.
>
> Fixes: 8c1b6e69dcc1 ("bpf: Compare BTF types of functions arguments with actual types")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  kernel/bpf/verifier.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 5c7bbaac81ef9..25363f134bf0c 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -7581,8 +7581,10 @@ static int check_btf_func(struct bpf_verifier_env *env,
>         if (!krecord)
>                 return -ENOMEM;
>         info_aux = kcalloc(nfuncs, sizeof(*info_aux), GFP_KERNEL | __GFP_NOWARN);
> -       if (!info_aux)
> +       if (!info_aux) {
> +               ret = -ENOMEM;
>                 goto err_free;
> +       }

Thanks for the fix.
I think it's better to do 'int ret = -ENOMEM;' instead.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 bpf-next] bpf: Fix an error code in check_btf_func()
  2020-06-03 17:57 ` Alexei Starovoitov
@ 2020-06-04  8:54   ` Dan Carpenter
  2020-06-04 18:37     ` Song Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2020-06-04  8:54 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song,
	Andrii Nakryiko, John Fastabend, KP Singh, bpf, kernel-janitors

This code returns success if the "info_aux" allocation fails but it
should return -ENOMEM.

Fixes: 8c1b6e69dcc1 ("bpf: Compare BTF types of functions arguments with actual types")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: style change

 kernel/bpf/verifier.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 5c7bbaac81ef9..34cde841ab681 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -7552,7 +7552,7 @@ static int check_btf_func(struct bpf_verifier_env *env,
 	const struct btf *btf;
 	void __user *urecord;
 	u32 prev_offset = 0;
-	int ret = 0;
+	int ret = -ENOMEM;
 
 	nfuncs = attr->func_info_cnt;
 	if (!nfuncs)
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 bpf-next] bpf: Fix an error code in check_btf_func()
  2020-06-04  8:54   ` [PATCH v2 " Dan Carpenter
@ 2020-06-04 18:37     ` Song Liu
  2020-06-04 21:43       ` Daniel Borkmann
  0 siblings, 1 reply; 5+ messages in thread
From: Song Liu @ 2020-06-04 18:37 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, John Fastabend, KP Singh, bpf,
	kernel-janitors

On Thu, Jun 4, 2020 at 1:55 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> This code returns success if the "info_aux" allocation fails but it
> should return -ENOMEM.
>
> Fixes: 8c1b6e69dcc1 ("bpf: Compare BTF types of functions arguments with actual types")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Acked-by: Song Liu <songliubraving@fb.com>

> ---
> v2: style change
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 bpf-next] bpf: Fix an error code in check_btf_func()
  2020-06-04 18:37     ` Song Liu
@ 2020-06-04 21:43       ` Daniel Borkmann
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Borkmann @ 2020-06-04 21:43 UTC (permalink / raw)
  To: Song Liu, Dan Carpenter
  Cc: Alexei Starovoitov, Martin KaFai Lau, Song Liu, Yonghong Song,
	Andrii Nakryiko, John Fastabend, KP Singh, bpf, kernel-janitors

On 6/4/20 8:37 PM, Song Liu wrote:
> On Thu, Jun 4, 2020 at 1:55 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>>
>> This code returns success if the "info_aux" allocation fails but it
>> should return -ENOMEM.
>>
>> Fixes: 8c1b6e69dcc1 ("bpf: Compare BTF types of functions arguments with actual types")
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> Acked-by: Song Liu <songliubraving@fb.com>

Applied, thanks (my personal style preference would have been v1, but fair enough).

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-04 21:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 17:55 [PATCH bpf-next] bpf: Fix an error code in check_btf_func() Dan Carpenter
2020-06-03 17:57 ` Alexei Starovoitov
2020-06-04  8:54   ` [PATCH v2 " Dan Carpenter
2020-06-04 18:37     ` Song Liu
2020-06-04 21:43       ` Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).