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
| ||
|
Date: Tue, 10 May 2016 18:27:04 +0000 From: Yuval Mintz <Yuval.Mintz@...gic.com> To: Yuval Mintz <Yuval.Mintz@...gic.com>, David Miller <davem@...emloft.net> CC: netdev <netdev@...r.kernel.org>, Ariel Elior <Ariel.Elior@...gic.com> Subject: RE: [PATCH net-next 01/14] qed: Add CONFIG_QED_SRIOV > > > I'm not entirely convinced this is true; If we'll not enforce the > > > alignment of this 64-bit field, it's possible there will be > > > differences between 32-bit and 64-bit machines versions of this struct. > > > You have to recall that this is going to be copied via DMA between > > > PF and VF, so they must have the exact same representation of the structure. > > > > Then use properly sized types to fill in all the space in the > > structure, that's how you guarantee layout, not aligned_u64. Also, do not use > the packed attribute. > > > > struct foo { > > u32 x; > > u32 y; > > u64 z; > > }; > > > > 'z' will always be 64-bit aligned. > > Perhaps my bit-numeric is a bit weak - why is it so? > I.e., what prevents `z' from only being 32-bit aligned on a 32-bit machine? > Isn't it possible that (&x % 8) == 4, (&y % 8) == 0 and (&z % 8) == 4 on such a > platform? If struct foo were to have been allocated, would it be guaranteed to be 64-bit aligned on a 64-bit platform and 32-bit aligned on a 32-bit platform? Assuming it is the case, is it theoretically possible that you'd have 2 different 32-bit platforms, where on one the `z' field would be packed while on the other it will not, introducing a 4-byte gap [assuming `foo' itself was only 32-bit aligned]?
Powered by blists - more mailing lists