From patchwork Tue Mar 20 20:19:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10297827 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AF9FE6039A for ; Tue, 20 Mar 2018 20:20:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D3B428F5F for ; Tue, 20 Mar 2018 20:20:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 926E829577; Tue, 20 Mar 2018 20:20:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C1AC294D4 for ; Tue, 20 Mar 2018 20:20:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751499AbeCTUUT (ORCPT ); Tue, 20 Mar 2018 16:20:19 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34154 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751317AbeCTUUS (ORCPT ); Tue, 20 Mar 2018 16:20:18 -0400 Received: by mail-wm0-f68.google.com with SMTP id a20so18947258wmd.1 for ; Tue, 20 Mar 2018 13:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/15YlvgURdmouOhwSNNH+8T1FP4qdQ1ckDUmPwPvMaw=; b=P8IRlXKpyliRbFpJdvuReKV5l9lmDDIVJAwuiny4TD6kg4GgSkmgObKjJ9qLm0hX7F AxgVZYR3GmAvx1TkHehBU3+pVOfcgS/4UPTz3HMmsj9wp6t6hgGCCFrNFpi0F+PysBHz 5aJ3OIf2BAuS4S8Bj1PzB9hdWHEIfNoZhBSQeXWCEMpzuEgq5OkSE0bU/u1XmwR7eNcz oet9QONHYgg9neHulzjIdfQN5ol5vGFTvQ0hQJd45C+ZUxwJTsdySVHeEhHNlLZ/UVpX UNnAJVWumYVlwp++baQJTn8chUnCngB0nSG4kSvQXh1v+dHFeb+FQ3Y2EQ1Ly23d332O Yhug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/15YlvgURdmouOhwSNNH+8T1FP4qdQ1ckDUmPwPvMaw=; b=eqSBNgIYkqqgx/mOXirWNPXgY6qTS0/N68Z6rDLTjzjHvxnJQ05fAZ0a3qqq64gfU9 DrHxaDN+AC/WSqvaQe0IzBGXPCySCSfnlVdApHW6Cwtpk7c+L/yFr9RR5B1W8vx2XiiP 2PqN9IYSNrDT8uXroC3J/Ajjyl22zHqSCHX6+nkpoCrO3Ucxt05mYg8EvYkLKHwsaGtP 4wfhWu2VS3JSWoZTFHtUZi1lNEawARJ4dmXZ06zFf4ID1EFcmzlG/pHN6HilHP3iAwY1 Chwhj8HWk7J8Qn9A0tA6NnV02mfOAQpRg/dHJ5vv5wazT1StxutpqxqPaVqpq6a8LNTR 6Mfg== X-Gm-Message-State: AElRT7HHrYZ1LeURbmJB+S6wQ9mRZAntZtkCdp44Y/zb5ZZhiuMmro4L X7QJqQOHRWLOa6iq9Kky7iFD1hkhn3Q= X-Google-Smtp-Source: AG47ELs6lhiktst829qmdxZ/QZJcRszGHFuhuMCIqUolGEjxyPf4acCkYj45WMzi2nxUhHP5C1wnSQ== X-Received: by 10.28.158.197 with SMTP id h188mr772339wme.72.1521577216500; Tue, 20 Mar 2018 13:20:16 -0700 (PDT) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [174.3.196.123]) by smtp.gmail.com with ESMTPSA id x18sm2493897wmc.2.2018.03.20.13.20.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Mar 2018 13:20:12 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1eyNjt-0001NW-PH; Tue, 20 Mar 2018 14:20:09 -0600 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org, Sean Hefty Cc: Jason Gunthorpe Subject: [PATCH 2/6] RDMA/ucma: Fix uABI structure layouts for 32/64 compat Date: Tue, 20 Mar 2018 14:19:47 -0600 Message-Id: <20180320201951.4998-3-jgg@ziepe.ca> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180320201951.4998-1-jgg@ziepe.ca> References: <20180320201951.4998-1-jgg@ziepe.ca> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jason Gunthorpe The rdma_ucm_event_resp is a different length on 32 and 64 bit compiles. The kernel requires it to be the expected length or longer so 32 bit builds running on a 64 bit kernel will not work. Retain full compat by having all kernels accept a struct with or without the trailing reserved field. Signed-off-by: Jason Gunthorpe --- drivers/infiniband/core/ucma.c | 9 +++++++-- include/uapi/rdma/rdma_user_cm.h | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 4bb5bed596c9d8..db4190b2ed2741 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/include/uapi/rdma/rdma_user_cm.h b/include/uapi/rdma/rdma_user_cm.h index c83ef0026079c8..65399c837762f5 100644 --- a/include/uapi/rdma/rdma_user_cm.h +++ b/include/uapi/rdma/rdma_user_cm.h @@ -270,10 +270,15 @@ struct rdma_ucm_event_resp { __u32 id; __u32 event; __u32 status; + /* + * NOTE: This union is not aligned to 8 bytes so none of the union + * members may contain a u64 or anything with higher alignment than 4. + */ union { struct rdma_ucm_conn_param conn; struct rdma_ucm_ud_param ud; } param; + __u32 reserved; }; /* Option levels */