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]
Message-ID: <00d497cd0162f3033c8c7aa57daf4630@paul-moore.com>
Date: Tue, 07 Jan 2025 22:00:08 -0500
From: Paul Moore <paul@...l-moore.com>
To: Christian Göttsche <cgoettsche@...tendoof.de>, selinux@...r.kernel.org
Cc: Christian Göttsche <cgzones@...glemail.com>, Stephen Smalley <stephen.smalley.work@...il.com>, Ondrej Mosnacek <omosnace@...hat.com>, Nathan Chancellor <nathan@...nel.org>, Nick Desaulniers <ndesaulniers@...gle.com>, Bill Wendling <morbo@...gle.com>, Justin Stitt <justinstitt@...gle.com>, Thiébaud Weksteen <tweek@...gle.com>, Bram Bonné <brambonne@...gle.com>, Masahiro Yamada <masahiroy@...nel.org>, linux-kernel@...r.kernel.org, llvm@...ts.linux.dev, Eric Suen <ericsu@...ux.microsoft.com>, Canfeng Guo <guocanfeng@...ontech.com>
Subject: Re: [PATCH RFC v2 15/22] selinux: introduce ebitmap_highest_set_bit()

On Dec 16, 2024 =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgoettsche@...tendoof.de> wrote:
> 
> Introduce an ebitmap function to calculate the highest set bit.
> 
> Signed-off-by: Christian Göttsche <cgzones@...glemail.com>
> ---
>  security/selinux/ss/ebitmap.c | 27 +++++++++++++++++++++++++++
>  security/selinux/ss/ebitmap.h |  1 +
>  2 files changed, 28 insertions(+)
> 
> diff --git a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c
> index 43bc19e21960..5d6b5b72b3e5 100644
> --- a/security/selinux/ss/ebitmap.c
> +++ b/security/selinux/ss/ebitmap.c
> @@ -257,6 +257,33 @@ int ebitmap_contains(const struct ebitmap *e1, const struct ebitmap *e2,
>  	return 1;
>  }
>  
> +u32 ebitmap_highest_set_bit(const struct ebitmap *e)
> +{
> +	const struct ebitmap_node *n;
> +	unsigned long unit;
> +	u32 pos = 0;
> +
> +	n = e->node;
> +	if (!n)
> +		return 0;
> +
> +	while (n->next)
> +		n = n->next;
> +
> +	for (unsigned int i = EBITMAP_UNIT_NUMS; i > 0; i--) {
> +		unit = n->maps[i - 1];
> +		if (unit == 0)
> +			continue;
> +
> +		pos = (i - 1) * EBITMAP_UNIT_SIZE;
> +		while (unit >>= 1)
> +			pos++;
> +		break;
> +	}
> +
> +	return n->startbit + pos;
> +}

Squash this patch with 16/22.  We generally don't add code that isn't
used, so squashing this with the caller in 16/22 ensures we have at
least one caller.

--
paul-moore.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ