GNOME Bugzilla – Bug 772605
[review] ubsan reports unaligned access to stats64 members in nm-linux-platform.c [bg/platform-unaligned-stats64-bgo772605]
Last modified: 2016-10-14 09:31:08 UTC
The undefined behavior sanitizer complains with: platform/nm-linux-platform.c:1482:31: runtime error: member access within misaligned address 0x61a000016fac for type 'struct rtnl_link_stats64', which requires 8 byte alignment 0x61a000016fac: note: pointer points here bc 00 17 00 bf 05 00 00 00 00 00 00 bf 05 00 00 00 00 00 00 b5 68 02 00 00 00 00 00 b5 68 02 00 ^ platform/nm-linux-platform.c:1483:29: runtime error: member access within misaligned address 0x61a000016fac for type 'struct rtnl_link_stats64', which requires 8 byte alignment 0x61a000016fac: note: pointer points here bc 00 17 00 bf 05 00 00 00 00 00 00 bf 05 00 00 00 00 00 00 b5 68 02 00 00 00 00 00 b5 68 02 00 ^ platform/nm-linux-platform.c:1484:31: runtime error: member access within misaligned address 0x61a000016fac for type 'struct rtnl_link_stats64', which requires 8 byte alignment 0x61a000016fac: note: pointer points here bc 00 17 00 bf 05 00 00 00 00 00 00 bf 05 00 00 00 00 00 00 b5 68 02 00 00 00 00 00 b5 68 02 00 ^ platform/nm-linux-platform.c:1485:29: runtime error: member access within misaligned address 0x61a000016fac for type 'struct rtnl_link_stats64', which requires 8 byte alignment 0x61a000016fac: note: pointer points here bc 00 17 00 bf 05 00 00 00 00 00 00 bf 05 00 00 00 00 00 00 b5 68 02 00 00 00 00 00 b5 68 02 00
Fix in branch bg/platform-unaligned-stats64-bgo772605.
usually, all our code in a header file should have "nm" prefixes. But I think for stuff that is taken as a whole from somewhere else, there is value in leavin it in it's unmodified form (unless the form has come issues). Then, we can diff the file with the origin, and possibly re-import a newer versions without having conflicts. The prime example for this is shared/nm-utils/gsystem-local-alloc.h, which is unmodified from libgsystem. A counter-example is shvarFile.h, for how it should not be done: we kept the non-nm-names, but heavily modified the files that were originally imported. I think that is wrong, because as we already modify shvarFile.h, we could just as well adjust the coding style. I would take src/basic/unaligned.h as-is, without any modification.
(In reply to Thomas Haller from comment #2) > I would take src/basic/unaligned.h as-is, without any modification. Fair enough, branch updated.
lgtm
Merged to master: https://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=d7b32008b7c66709df41b96d58d83fc4bb0a4d08 and nm-1-4: https://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?h=nm-1-4&id=b81cd79750812216fbcc2c947179dbbd168f4333