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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 25 Mar 2021 20:37:11 +0200
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Linus Torvalds <torvalds@...ux-foundation.org>
Cc:     Lee Jones <lee.jones@...aro.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [GIT PULL] MFD fixes for v5.12

On Thu, Mar 25, 2021 at 11:23:06AM -0700, Linus Torvalds wrote:
> On Thu, Mar 25, 2021 at 9:34 AM Lee Jones <lee.jones@...aro.org> wrote:
> >
> >    - Unconstify editable placeholder structures
> 
> Hmm. This does show a real issue with that gpio driver.
> 
> It does garbage things:
> 
>   static int intel_quark_gpio_setup(struct pci_dev *pdev, struct mfd_cell *cell)
>   {
>         struct dwapb_platform_data *pdata;
>         struct resource *res = (struct resource *)cell->resources;
> 
> where that cast is exactly because "cell->resources" _is_ const, and
> the driver violates that.
> 
> This horrible mis-use of a const pointer is why the original patch
> that got reverted didn't cause build-time warnings.
> 
> Honestly, I think the right thing to do is to get rid of that cast, and do
> 
>         struct resource *res = intel_quark_mfd_cells;
> 
> instead, so that you clearly edit somethign that isn't const, and so
> that the compiler would have warned about the whole constification in
> the first place.
> 
> This broken pattern shows up for both intel_quark_i2c_setup() and
> intel_quark_gpio_setup().
> 
> I've pulled this, but I really want this kind of "take a const pointer
> and violate it" crap removed. It is *only* correct if you know exactly
> which pointer it is, and then you should just have used that original
> pointer in the first place (ie use that intel_quark_mfd_cells[]
> directly like suggested above).

Thanks for pointing this out! I'll take it in my TODO list.

Hmm... I missed the above b/c I have seen the pattern of supplying non-const
data structures via .driver_data field and thought that here is something
similar without looking into the actual approach.

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ