lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Mon, 10 Oct 2022 22:37:32 +0800
From:   Rui Li <me@...ui.org>
To:     Martin KaFai Lau <martin.lau@...ux.dev>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Song Liu <song@...nel.org>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>,
        Stanislav Fomichev <sdf@...gle.com>,
        Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
        bpf@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] bpf: fix checkpatch POINTER_LOCATION, SPACING,
 ASSIGN_IN_IF error

This commit cleans up checkpatch errors as follows:
ERROR:POINTER_LOCATION: "foo* bar" should be "foo *bar"
ERROR:ASSIGN_IN_IF: do not use assignment in if condition
ERROR:SPACING: space required after that ',' (ctx:VxV)

There still are some false positive errors like spaces required.

Signed-off-by: Rui Li <me@...ui.org>
---
 kernel/bpf/arraymap.c | 10 ++++++----
 kernel/bpf/btf.c      |  2 +-
 kernel/bpf/core.c     |  8 +++++---
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index 832b2659e96e..271af4b934d4 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -154,7 +154,7 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr)
 	return &array->map;
 }
 
-static void *array_map_elem_ptr(struct bpf_array* array, u32 index)
+static void *array_map_elem_ptr(struct bpf_array *array, u32 index)
 {
 	return array->value + (u64)array->elem_size * index;
 }
@@ -814,9 +814,11 @@ int bpf_fd_array_map_lookup_elem(struct bpf_map *map, void *key, u32 *value)
 
 	rcu_read_lock();
 	elem = array_map_lookup_elem(map, key);
-	if (elem && (ptr = READ_ONCE(*elem)))
-		*value = map->ops->map_fd_sys_lookup_elem(ptr);
-	else
+	if (elem) {
+		ptr = READ_ONCE(*elem);
+		if (ptr)
+			*value = map->ops->map_fd_sys_lookup_elem(ptr);
+	} else
 		ret = -ENOENT;
 	rcu_read_unlock();
 
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index eba603cec2c5..a31e31951d60 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -5482,7 +5482,7 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type,
 
 		if (ctx_arg_info->offset == off) {
 			if (!ctx_arg_info->btf_id) {
-				bpf_log(log,"invalid btf_id for context argument offset %u\n", off);
+				bpf_log(log, "invalid btf_id for context argument offset %u\n", off);
 				return false;
 			}
 
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 711fd293b6de..3a63787598c5 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -467,9 +467,11 @@ struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off,
 	 * We need to probe here before we do any reallocation where
 	 * we afterwards may not fail anymore.
 	 */
-	if (insn_adj_cnt > cnt_max &&
-	    (err = bpf_adj_branches(prog, off, off + 1, off + len, true)))
-		return ERR_PTR(err);
+	if (insn_adj_cnt > cnt_max) {
+		err = bpf_adj_branches(prog, off, off + 1, off + len, true);
+		if (err)
+			return ERR_PTR(err);
+	}
 
 	/* Several new instructions need to be inserted. Make room
 	 * for them. Likely, there's no need for a new allocation as
-- 
2.30.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ