diff mbox series

[bpf-next] libbpf: fix BPF_LOG_BUF_SIZE off-by-one error

Message ID 20190419164745.3122-1-robert.mccabe@rockwellcollins.com
State Changes Requested
Headers show
Series [bpf-next] libbpf: fix BPF_LOG_BUF_SIZE off-by-one error | expand

Commit Message

Robert McCabe April 19, 2019, 4:47 p.m. UTC
From: "McCabe, Robert J" <Robert.McCabe@rockwellcollins.com>

The BPF_PROG_LOAD condition for kernel version <= 5.1 is

   log->len_total > UINT_MAX >> 8 /* (16 * 1024 * 1024) - 1 */

Signed-off-by: rjmccabe3701 <robert.mccabe@rockwellcollins.com>
---
 tools/lib/bpf/bpf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.17.1

Comments

Alexei Starovoitov April 19, 2019, 7:32 p.m. UTC | #1
On Fri, Apr 19, 2019 at 11:47:45AM -0500, robert.mccabe@rockwellcollins.com wrote:
> From: "McCabe, Robert J" <Robert.McCabe@rockwellcollins.com>
> 
> The BPF_PROG_LOAD condition for kernel version <= 5.1 is
> 
>    log->len_total > UINT_MAX >> 8 /* (16 * 1024 * 1024) - 1 */
> 
> Signed-off-by: rjmccabe3701 <robert.mccabe@rockwellcollins.com>
> ---
>  tools/lib/bpf/bpf.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
> index bc30783d1403..62d67caa7aea 100644
> --- a/tools/lib/bpf/bpf.h
> +++ b/tools/lib/bpf/bpf.h
> @@ -92,7 +92,7 @@ struct bpf_load_program_attr {
>  #define MAPS_RELAX_COMPAT	0x01
> 
>  /* Recommend log buffer size */
> -#define BPF_LOG_BUF_SIZE (16 * 1024 * 1024) /* verifier maximum in kernels <= 5.1 */
> +#define BPF_LOG_BUF_SIZE ((16 * 1024 * 1024) - 1) /* verifier maximum in kernels <= 5.1 */

thanks. good catch.
please replace with (UINT32_MAX >> 8)

sending one patch was enough. no need to spam 5 times.
Robert McCabe April 19, 2019, 11:23 p.m. UTC | #2
> sending one patch was enough. no need to spam 5 times.

Gosh that's embarrassing.  I was having a difficult time sending the
patch (I'm new at patchwork-based development).
I'll submit a a new patch with your suggestion.
diff mbox series

Patch

diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
index bc30783d1403..62d67caa7aea 100644
--- a/tools/lib/bpf/bpf.h
+++ b/tools/lib/bpf/bpf.h
@@ -92,7 +92,7 @@  struct bpf_load_program_attr {
 #define MAPS_RELAX_COMPAT	0x01

 /* Recommend log buffer size */
-#define BPF_LOG_BUF_SIZE (16 * 1024 * 1024) /* verifier maximum in kernels <= 5.1 */
+#define BPF_LOG_BUF_SIZE ((16 * 1024 * 1024) - 1) /* verifier maximum in kernels <= 5.1 */
 LIBBPF_API int
 bpf_load_program_xattr(const struct bpf_load_program_attr *load_attr,
 		       char *log_buf, size_t log_buf_sz);