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:	Mon, 2 Feb 2015 14:04:06 +0100
From:	Geert Uytterhoeven <geert@...ux-m68k.org>
To:	Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
Cc:	Arnd Bergmann <arnd@...db.de>,
	Linux-Arch <linux-arch@...r.kernel.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: Can this be a invalid memory access? (was: Re: [PATCH]
 spi/xilinx: Cast ioread32/iowrite32 function pointers)

Hi Ricardo,

On Mon, Feb 2, 2015 at 1:49 PM, Ricardo Ribalda Delgado
<ricardo.ribalda@...il.com> wrote:
> Regarding ioread8 et al.
>
> On include/asm-generic/io.h is defined as:
> extern unsigned int ioread8(void __iomem *);
>
> On include/asm-generic/io.h:
> static inline u8 ioread8(const volatile void __iomem *addr)
>
> Please ignore the qualifiers right now. The first function returns an
> unsigned integer, the second a u8.
>
> Through #ifdefs, different arches uses the first or the second definitions.
>
> If we consider this code:
>
> u8 varA;
> u8 varB;
> u8 varC;
> void * pvar=varB;

... = &varB;

> *pvar = ioread8(valid_memory);
>
> Depending if ioread8 returns a u8 or a unsigned int, aren't we also
> accessing varC?
>
> Could not this be a problem?

Please try to compile the above.
The compiler will tell you you cannot dereference a void pointer.

Now, replace "void *" by "unsigned int *".
After that, varC will indeed be overwritten. But the compiler will still have
warned you that you assigned the address of an u8 variable to an
unsigned int pointer.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
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