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: <CAA8EJpo_7x28BkvwOma4=-=4ricqRYCb42dXc72i4wcSceyV5w@mail.gmail.com>
Date:   Sat, 12 Feb 2022 01:10:09 +0300
From:   Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     linux-kernel@...r.kernel.org,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: Re: [PATCH] container_of.h: make container_of const-aware

On Sat, 12 Feb 2022 at 01:05, Andrew Morton <akpm@...ux-foundation.org> wrote:
>
> On Thu, 10 Feb 2022 20:04:34 +0300 Dmitry Baryshkov <dmitry.baryshkov@...aro.org> wrote:
>
> > container_of() macro has one major drawback. It does not check whether
> > the passed ptr has a const pointer, the result will always be a
> > non-const pointer. Use a _Generic() construct (supported since gcc 4.9
> > and Clang 3.0) to teach container_of that if converting a const pointer,
> > the returned pointer should also have the const modifier.
> >
>
> Nice idea, but my x86_64 allnoconfig build explodes with zillions of
> warnings.
>
> In file included from ./include/linux/list.h:5,
>                  from ./include/linux/module.h:12,
>                  from init/do_mounts.c:2:
> ./include/net/sock.h: In function 'sk_entry':
> ./include/linux/container_of.h:17:42: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

Are these warnings legit? In other words, is the code converting a
const pointer into a modifiable one? I've stumbled upon this in drm
drivers.
How do we proceed with this patch?


-- 
With best wishes
Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ