* [PATCH] xf86drm: ensure proper alignment of pointers in drmProcessPciDevice
@ 2016-05-13 6:14 Nicolai Hähnle
2016-05-14 23:03 ` Emil Velikov
2016-06-10 14:07 ` Nicolai Hähnle
0 siblings, 2 replies; 6+ messages in thread
From: Nicolai Hähnle @ 2016-05-13 6:14 UTC (permalink / raw)
To: dri-devel; +Cc: Nicolai Hähnle
From: Nicolai Hähnle <nicolai.haehnle@amd.com>
Previously, (*device)->businfo.pci would end up misaligned, which results
in undefined behavior.
Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
---
xf86drm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xf86drm.c b/xf86drm.c
index 5f587d9..94efc08 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -3000,7 +3000,7 @@ static int drmProcessPciDevice(drmDevicePtr *device, const char *d_name,
const char *node, int node_type,
int maj, int min, bool fetch_deviceinfo)
{
- const int max_node_str = drmGetMaxNodeName();
+ const int max_node_str = ALIGN(drmGetMaxNodeName(), sizeof(void *));
int ret, i;
char *addr;
--
2.7.4
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] xf86drm: ensure proper alignment of pointers in drmProcessPciDevice
2016-05-13 6:14 [PATCH] xf86drm: ensure proper alignment of pointers in drmProcessPciDevice Nicolai Hähnle
@ 2016-05-14 23:03 ` Emil Velikov
2016-05-17 15:24 ` Nicolai Hähnle
2016-06-10 14:07 ` Nicolai Hähnle
1 sibling, 1 reply; 6+ messages in thread
From: Emil Velikov @ 2016-05-14 23:03 UTC (permalink / raw)
To: Nicolai Hähnle; +Cc: Nicolai Hähnle, ML dri-devel
Hi Nicolai,
On 13 May 2016 at 07:14, Nicolai Hähnle <nhaehnle@gmail.com> wrote:
> From: Nicolai Hähnle <nicolai.haehnle@amd.com>
>
> Previously, (*device)->businfo.pci would end up misaligned, which results
> in undefined behavior.
>
Can you point me to a source where I can read more on the topic ?
I'm pretty sure I ran this through valgrind and it gave a clear bill of health.
Thanks
Emil
P.S. Please run the following in your repo $git config --local
format.subjectPrefix "PATCH libdrm"
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xf86drm: ensure proper alignment of pointers in drmProcessPciDevice
2016-05-14 23:03 ` Emil Velikov
@ 2016-05-17 15:24 ` Nicolai Hähnle
0 siblings, 0 replies; 6+ messages in thread
From: Nicolai Hähnle @ 2016-05-17 15:24 UTC (permalink / raw)
To: Emil Velikov; +Cc: Nicolai Hähnle, ML dri-devel
Hi Emil,
On 14.05.2016 18:03, Emil Velikov wrote:
> Hi Nicolai,
>
> On 13 May 2016 at 07:14, Nicolai Hähnle <nhaehnle@gmail.com> wrote:
>> From: Nicolai Hähnle <nicolai.haehnle@amd.com>
>>
>> Previously, (*device)->businfo.pci would end up misaligned, which results
>> in undefined behavior.
>>
> Can you point me to a source where I can read more on the topic ?
> I'm pretty sure I ran this through valgrind and it gave a clear bill of health.
Valgrind doesn't complain here either, I noticed it with
-fsanitize=undefined (ubsan) applied to Mesa.
That makes sense, since unaligned loads/stores aren't really a bug as
far as the x86 ISA is concerned, which is the level at which valgrind
looks at the code. On the other hand, apparently already an unaligned
cast (not just the dereference!) is undefined behavior as far as C is
concerned. I'm not a C language lawyer, but that's what people are
saying on the interwebs, so it must be true :)
> P.S. Please run the following in your repo $git config --local
> format.subjectPrefix "PATCH libdrm"
Done.
Cheers,
Nicolai
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xf86drm: ensure proper alignment of pointers in drmProcessPciDevice
2016-05-13 6:14 [PATCH] xf86drm: ensure proper alignment of pointers in drmProcessPciDevice Nicolai Hähnle
2016-05-14 23:03 ` Emil Velikov
@ 2016-06-10 14:07 ` Nicolai Hähnle
2016-06-10 16:55 ` Emil Velikov
1 sibling, 1 reply; 6+ messages in thread
From: Nicolai Hähnle @ 2016-06-10 14:07 UTC (permalink / raw)
To: dri-devel
Ping.
On 13.05.2016 08:14, Nicolai Hähnle wrote:
> From: Nicolai Hähnle <nicolai.haehnle@amd.com>
>
> Previously, (*device)->businfo.pci would end up misaligned, which results
> in undefined behavior.
>
> Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
> ---
> xf86drm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/xf86drm.c b/xf86drm.c
> index 5f587d9..94efc08 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
> @@ -3000,7 +3000,7 @@ static int drmProcessPciDevice(drmDevicePtr *device, const char *d_name,
> const char *node, int node_type,
> int maj, int min, bool fetch_deviceinfo)
> {
> - const int max_node_str = drmGetMaxNodeName();
> + const int max_node_str = ALIGN(drmGetMaxNodeName(), sizeof(void *));
> int ret, i;
> char *addr;
>
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-06-10 18:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-13 6:14 [PATCH] xf86drm: ensure proper alignment of pointers in drmProcessPciDevice Nicolai Hähnle
2016-05-14 23:03 ` Emil Velikov
2016-05-17 15:24 ` Nicolai Hähnle
2016-06-10 14:07 ` Nicolai Hähnle
2016-06-10 16:55 ` Emil Velikov
2016-06-10 18:19 ` Nicolai Hähnle
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.