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:   Tue, 11 Apr 2017 10:23:07 -0700
From:   Matthias Kaehlcke <mka@...omium.org>
To:     Mason <slash.tmp@...e.fr>
Cc:     Bjorn Helgaas <helgaas@...nel.org>,
        linux-pci <linux-pci@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Grant Grundler <grundler@...omium.org>,
        Greg Hackmann <ghackmann@...gle.com>,
        Michael Davidson <md@...gle.com>
Subject: Re: [PATCH] PCI: Add cast when assigning PCI_ROM_ADDRESS_MASK to a
 32-bit variable

El Tue, Apr 11, 2017 at 12:08:38PM +0200 Mason ha dit:

> On 11/04/2017 03:24, Bjorn Helgaas wrote:
> 
> > On Mon, Apr 10, 2017 at 03:24:57PM -0700, Matthias Kaehlcke wrote:
> >
> >> This fixes a clang warning about "implicit conversion from 'unsigned
> >> long' to 'u32'"
> >>
> >> Signed-off-by: Matthias Kaehlcke <mka@...omium.org>
> >> ---
> >>  drivers/pci/probe.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> >> index dfc9a2794141..148e80d5caf1 100644
> >> --- a/drivers/pci/probe.c
> >> +++ b/drivers/pci/probe.c
> >> @@ -180,7 +180,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
> >>  	u16 orig_cmd;
> >>  	struct pci_bus_region region, inverted_region;
> >>  
> >> -	mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
> >> +	mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
> > 
> > Can we put the cast in the PCI_ROM_ADDRESS_MASK #define so we don't have to
> > repeat it in all the uses?
> 
> Fixing these "implicit conversion" warnings, especially for
> unsigned types, is a slippery slope. (The behavior of the
> conversion is well-defined.)
> 
> How about changing the type of PCI_ROM_ADDRESS_MASK instead?
> It's defined as ~0x7ffUL but it's only used in the context
> of u32.
> 
> So make it an unsigned int:
> #define PCI_ROM_ADDRESS_MASK (~0x7ffU)
> 
> AFAIU, unsigned int is 32 bits on all platforms supported
> by Linux.

I considered this initially, but wasn't sure if the unsigned long
mask might be needed in some cases. From the comments I interpret that
there should be no problems with using a 32 bit mask everywhere.

I'll send out an updated patch shortly.

Thanks

Matthias

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ