Skip to contentSkip to conversation

libbpf: fix BPF_LOG_BUF_SIZE off-by-one error

PATCH New [email protected] 1 participant 1 message Apr 19, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libbpf: fix BPF_LOG_BUF_SIZE off-by-one error

From: "McCabe, Robert J" <[email protected]>

The BPF_PROG_LOAD condition for kernel version <= 5.1 is

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

---
 tools/lib/bpf/bpf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/bpf.h +1 -1
index bc30783d1403..62d67caa7aea 100644
@@ -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);

--
2.17.1