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:   Fri, 28 Feb 2020 12:04:32 -0600
From:   Alex Elder <elder@...aro.org>
To:     Jakub Kicinski <kuba@...nel.org>
Cc:     Al Viro <viro@...iv.linux.org.uk>,
        Johannes Berg <johannes@...solutions.net>,
        Arnd Bergmann <arnd@...db.de>,
        Masahiro Yamada <masahiroy@...nel.org>,
        Bjorn Andersson <bjorn.andersson@...aro.org>,
        lkml <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] bitfield.h: add FIELD_MAX() and field_max()

On 2/28/20 11:56 AM, Jakub Kicinski wrote:
> On Fri, 28 Feb 2020 10:53:43 -0600 Alex Elder wrote:
>> Define FIELD_MAX(), which supplies the maximum value that can be
>> represented by a field value.  Define field_max() as well, to go
>> along with the lower-case forms of the field mask functions.
>>
>> Signed-off-by: Alex Elder <elder@...aro.org>
>> ---
>>
>>  NOTE:	I'm not entirely sure who owns/maintains this file so
>> 	I'm sending it to those who have committed things to it.
>> 	I hope someone will just take it in after review; I use
>> 	field_max() in some code I'm about to send out.
> 
> Could you give us an example use?
> 
> Is it that you find the current macros misnamed or there's something
> you can't do? Or are you trying to set fields to max?

I'm trying to validate variable values are in range before attempting
to use them in a bitfield.


I find field_max() to be a good name for what I'm looking for.

					-Alex

#define FOO_FMASK	0x000ff000

static u32 register = 0x12345678;

int foo(u32 value)
{
	if (value > field_max(FOO_FMASK))
		return -EINVAL;

	u32_replace_bits(&register, value, FOO_FMASK);
	
	return 0;
}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ