diff options
author | Jason Gunthorpe <jgg@mellanox.com> | 2018-03-27 14:32:49 -0600 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2018-03-27 14:32:49 -0600 |
commit | 819b60286e4e99e499d966ea55d5ef8fb9151b13 (patch) | |
tree | 33a01f00d30e60c07a1e6142fe55ddec46c4bf4f /drivers | |
parent | f64705b8715a090cd5526a2c082eeb199a51e8b2 (diff) | |
parent | 26b9906612c3553189d7d1673ee116ffac474d53 (diff) |
Merge branch '32compat'
The design of the uAPI had intended all structs to share the same layout on 32
and 64 bit compiles. Unfortunately over the years some errors have crept in.
This series fixes all the incompatabilities. It goes along with a userspace
rdma-core series that causes the providers to use these structs directly and
then does various self-checks on the command formation.
Those checks were combined with output from pahole on 32 and 64 bit compiles
to confirm that the structure layouts are the same.
This series does not make implicit padding explicit, as long as the implicit
padding is the same on 32 and 64 bit compiles.
Finally, the issue is put to rest by using __aligned_u64 in the uapi headers,
if new code copies that type, and is checked in userspace, it is unlikely we
will see problems in future.
There are two patches that break the ABI for a 32 bit kernel, one for rxe and
one for mlx4. Both patches have notes, but the overall feeling from Doug and I
is that providing compat is just too difficult and not necessary since there
is no real user of a 32 bit userspace and 32 bit kernel for various good
reasons.
The 32 bit userspace / 64 bit kernel case however does seem to have some real
users and does need to work as designed.
* 32compat:
RDMA: Change all uapi headers to use __aligned_u64 instead of __u64
RDMA/rxe: Fix uABI structure layouts for 32/64 compat
RDMA/mlx4: Fix uABI structure layouts for 32/64 compat
RDMA/qedr: Fix uABI structure layouts for 32/64 compat
RDMA/ucma: Fix uABI structure layouts for 32/64 compat
RDMA: Remove minor pahole differences between 32/64
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/core/ucma.c | 9 | ||||
-rw-r--r-- | drivers/infiniband/sw/rxe/rxe.h | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 4bb5bed596c9..db4190b2ed27 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -382,7 +382,11 @@ static ssize_t ucma_get_event(struct ucma_file *file, const char __user *inbuf, struct ucma_event *uevent; int ret = 0; - if (out_len < sizeof uevent->resp) + /* + * Old 32 bit user space does not send the 4 byte padding in the + * reserved field. We don't care, allow it to keep working. + */ + if (out_len < sizeof(uevent->resp) - sizeof(uevent->resp.reserved)) return -ENOSPC; if (copy_from_user(&cmd, inbuf, sizeof(cmd))) @@ -417,7 +421,8 @@ static ssize_t ucma_get_event(struct ucma_file *file, const char __user *inbuf, } if (copy_to_user((void __user *)(unsigned long)cmd.response, - &uevent->resp, sizeof uevent->resp)) { + &uevent->resp, + min_t(size_t, out_len, sizeof(uevent->resp)))) { ret = -EFAULT; goto done; } diff --git a/drivers/infiniband/sw/rxe/rxe.h b/drivers/infiniband/sw/rxe/rxe.h index 7d232611303f..561ad307c6ec 100644 --- a/drivers/infiniband/sw/rxe/rxe.h +++ b/drivers/infiniband/sw/rxe/rxe.h @@ -59,7 +59,11 @@ #include "rxe_verbs.h" #include "rxe_loc.h" -#define RXE_UVERBS_ABI_VERSION (1) +/* + * Version 1 and Version 2 are identical on 64 bit machines, but on 32 bit + * machines Version 2 has a different struct layout. + */ +#define RXE_UVERBS_ABI_VERSION 2 #define IB_PHYS_STATE_LINK_UP (5) #define IB_PHYS_STATE_LINK_DOWN (3) |