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:	Thu, 8 Oct 2015 16:21:55 +0200
From:	David Herrmann <dh.herrmann@...il.com>
To:	Sergei Zviagintsev <sergei@...v.net>
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Daniel Mack <daniel@...que.org>,
	David Herrmann <dh.herrmann@...glemail.com>,
	Djalal Harouni <tixxdz@...ndz.org>,
	linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 14/44] kdbus: Simplify expression in kdbus_get_memfd()

Hi

On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev <sergei@...v.net> wrote:
> '(s & m) != m' means that mask 'm' contains some bits which are not set
> in 's', and this is literally equal to '~s & m'.

Sure, but you make the code look much less obvious. Checking a bit is
set is "a & b", checking if not set is "!(a & b)". If you check
whether a whole mask is set, you run "(a & m) == m", checking whether
it not set should be the negation, which is "(a & m) != m".

I'd prefer keeping the current code, unless the compiler cannot figure
it out on its own.
David

> Signed-off-by: Sergei Zviagintsev <sergei@...v.net>
> ---
>  ipc/kdbus/message.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ipc/kdbus/message.c b/ipc/kdbus/message.c
> index ae565cd343f8..c7ef23d40471 100644
> --- a/ipc/kdbus/message.c
> +++ b/ipc/kdbus/message.c
> @@ -273,7 +273,7 @@ static struct file *kdbus_get_memfd(const struct kdbus_memfd *memfd)
>         s = shmem_get_seals(f);
>         if (s < 0)
>                 ret = ERR_PTR(-EMEDIUMTYPE);
> -       else if ((s & m) != m)
> +       else if (~s & m)
>                 ret = ERR_PTR(-ETXTBSY);
>         else if (memfd->start + memfd->size > (u64)i_size_read(file_inode(f)))
>                 ret = ERR_PTR(-EFAULT);
> --
> 1.8.3.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ