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: <CAK7LNAT9SMvNaFLoddYtZg+8bNnN2f343F_mjQ6awpqS4s0phg@mail.gmail.com>
Date:   Thu, 30 Mar 2017 10:57:27 +0900
From:   Masahiro Yamada <yamada.masahiro@...ionext.com>
To:     "H. Peter Anvin" <hpa@...or.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Niklas Söderlund 
        <niklas.soderlund+renesas@...natech.se>,
        Jessica Yu <jeyu@...hat.com>,
        Johannes Berg <johannes.berg@...el.com>,
        Petr Mladek <pmladek@...e.com>,
        Larry Finger <Larry.Finger@...inger.net>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Gustavo Padovan <gustavo.padovan@...labora.co.uk>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Peter Zijlstra <peterz@...radead.org>,
        Luis de Bethencourt <luisbg@....samsung.com>,
        Josh Triplett <josh@...htriplett.org>
Subject: Re: [PATCH] kernel.h: add IS_PTR_ALIGNED() macro

Hi.

2017-03-30 6:24 GMT+09:00 H. Peter Anvin <hpa@...or.com>:
> On 03/29/17 03:22, Masahiro Yamada wrote:
>> We often check if a pointer has a specific alignment.  Because the
>> '&' (bitwise AND) operator cannot take a pointer for the operand,
>> so we need a cast like, IS_ALIGNED((unsigned long)p, a).
>>
>> IS_PTR_ALIGNED will be useful as a shorthand.
>>
>> Signed-off-by: Masahiro Yamada <yamada.masahiro@...ionext.com>
>> ---
>>
>>  include/linux/kernel.h | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
>> index e5edd55..a810e4b 100644
>> --- a/include/linux/kernel.h
>> +++ b/include/linux/kernel.h
>> @@ -50,6 +50,7 @@
>>  #define __ALIGN_MASK(x, mask)        __ALIGN_KERNEL_MASK((x), (mask))
>>  #define PTR_ALIGN(p, a)              ((typeof(p))ALIGN((unsigned long)(p), (a)))
>>  #define IS_ALIGNED(x, a)             (((x) & ((typeof(x))(a) - 1)) == 0)
>> +#define IS_PTR_ALIGNED(p, a)         (IS_ALIGNED((unsigned long)p, a))
>>
>
> No need for two macros; make one work for both.
>
> You could move the __inttype() macro from arch/x86/include/asm/uaccess.h
> into this file and replace typeof(x) with __inttype(x) in the above macro.
>
> Attached is a set of slightly improved (safer and a bit more
> generalized) versions of the same macro that might be more appropriate
> to include in <linux/kernel.h>.
>
>         -hpa


Could you care to send a patch?

Perhaps, ALIGN and PTR_ALIGN can be merged as well?



-- 
Best Regards
Masahiro Yamada

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ