[Qemu-devel] [PATCH 0/1] Fix unaligned reads in the tcg/tci.c

Anatoly Trosinenko posted 1 patch 6 years, 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20180127134908.24095-1-anatoly.trosinenko@gmail.com
Test checkpatch passed
Test docker-build@min-glib passed
Test docker-mingw@fedora passed
Test docker-quick@centos6 passed
Test ppc passed
Test s390x passed
tcg/tci.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
[Qemu-devel] [PATCH 0/1] Fix unaligned reads in the tcg/tci.c
Posted by Anatoly Trosinenko 6 years, 2 months ago
The code in tcg/tci.c reads some data from TCI bytecode through
pointer dereferencing. As far as I know unaligned reads in such a way are
undefined behavior and compiling with -fsanitize=undefined enumerated
them as such at run-time.

I have replaced such reads with invocations of ld{l,q}_he_p.
A comment in include/qemu/bswap.h:310 suggests they should be properly
translated by the compiler. I didn't added signed/unsigned casts
since bswap.h does contain separate signed/unsigned versions
for 16-bit integers but does not for 32- and 64-bit ones, so I supposed
the developers of the bswap.h already arranged everything so
integer promotions don't mess things up. I can add casts in case I'm
not right about it.

Anatoly Trosinenko (1):
  tci: eliminate UB due to unaligned reads

 tcg/tci.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

-- 
2.14.1


Re: [Qemu-devel] [PATCH 0/1] Fix unaligned reads in the tcg/tci.c
Posted by Anatoly Trosinenko 6 years, 2 months ago
Ping.
Patchwork link: http://patchwork.ozlabs.org/patch/866732/
Patchew link:
http://patchew.org/QEMU/20180127134908.24095-1-anatoly.trosinenko@gmail.com/

(Initially forgot to add Richard Henderson to CC.)

2018-01-27 16:49 GMT+03:00 Anatoly Trosinenko <anatoly.trosinenko@gmail.com>
:

> The code in tcg/tci.c reads some data from TCI bytecode through
> pointer dereferencing. As far as I know unaligned reads in such a way are
> undefined behavior and compiling with -fsanitize=undefined enumerated
> them as such at run-time.
>
> I have replaced such reads with invocations of ld{l,q}_he_p.
> A comment in include/qemu/bswap.h:310 suggests they should be properly
> translated by the compiler. I didn't added signed/unsigned casts
> since bswap.h does contain separate signed/unsigned versions
> for 16-bit integers but does not for 32- and 64-bit ones, so I supposed
> the developers of the bswap.h already arranged everything so
> integer promotions don't mess things up. I can add casts in case I'm
> not right about it.
>
> Anatoly Trosinenko (1):
>   tci: eliminate UB due to unaligned reads
>
>  tcg/tci.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
>
> --
> 2.14.1
>
>


-- 
Best regards,
Anatoly Trosinenko