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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 26 Mar 2023 09:21:59 +0000
From:   Yafang Shao <laoar.shao@...il.com>
To:     ast@...nel.org, daniel@...earbox.net, andrii@...nel.org,
        kafai@...com, songliubraving@...com, yhs@...com,
        john.fastabend@...il.com, kpsingh@...nel.org, sdf@...gle.com,
        haoluo@...gle.com, jolsa@...nel.org
Cc:     bpf@...r.kernel.org, linux-kernel@...r.kernel.org,
        Yafang Shao <laoar.shao@...il.com>
Subject: [RFC PATCH bpf-next 04/13] bpf: No need to check if id is 0

idr_alloc_cyclic() will return -ENOSPC if there's no available IDs, so
don't need to check if the id is less than the start number.

Signed-off-by: Yafang Shao <laoar.shao@...il.com>
---
 kernel/bpf/syscall.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index e18ac7f..f3664f2 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -387,9 +387,6 @@ static int bpf_map_alloc_id(struct bpf_map *map)
 	spin_unlock_bh(&map_idr_lock);
 	idr_preload_end();
 
-	if (WARN_ON_ONCE(!id))
-		return -ENOSPC;
-
 	return id > 0 ? 0 : id;
 }
 
@@ -2032,10 +2029,6 @@ static int bpf_prog_alloc_id(struct bpf_prog *prog)
 	spin_unlock_bh(&prog_idr_lock);
 	idr_preload_end();
 
-	/* id is in [1, INT_MAX) */
-	if (WARN_ON_ONCE(!id))
-		return -ENOSPC;
-
 	return id > 0 ? 0 : id;
 }
 
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ