From patchwork Mon Sep 19 11:57:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9339163 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 96FEB601C2 for ; Mon, 19 Sep 2016 11:58:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87EB428C8C for ; Mon, 19 Sep 2016 11:58:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C13529171; Mon, 19 Sep 2016 11:58:53 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 D271028C8C for ; Mon, 19 Sep 2016 11:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753283AbcISL6v (ORCPT ); Mon, 19 Sep 2016 07:58:51 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:50608 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751713AbcISL6u (ORCPT ); Mon, 19 Sep 2016 07:58:50 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue102) with ESMTPA (Nemesis) id 0M09s4-1arfCb1Tci-00uLDn; Mon, 19 Sep 2016 13:58:29 +0200 From: Arnd Bergmann To: Doug Ledford , Sean Hefty , Hal Rosenstock Cc: Arnd Bergmann , Moni Shoua , Yonatan Cohen , Leon Romanovsky , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] IB/rxe: avoid putting a large struct rxe_qp on stack Date: Mon, 19 Sep 2016 13:57:26 +0200 Message-Id: <20160919115826.553858-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:2jaO6kJn/dKuTYRs5vrSuz+sxjesz27sXda8zMNXtD+tlMu7STa 5H7blhWqELg3CqnARFabtlTIPW/A0+r8SBSN/QI7Vd3qa9i1MSLkK9bZf9oJpbIq+PRUvrV QN3SK7jMrVN0KpFXMmT23k5Z8J0Se9tnthE889tIGt5aIaUorduhz4b1CF97/NP7wesxwA6 f26NeKCefvCdlhhmTMNcQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:e02GWVG2wlw=:e8iT82Uh8BBp0e7YPMjEJ4 kRLrEZnCLWGOwrIZWkQ4MeIVJE7xHC/lF9Ytsq05JOJsDUx0KYx6hjNq/UMu29X69yyf9K7Lx 2wj8XSqIM1CprQt0YPAGTwiZG1/WP3LxXofpr5WwMkWRxtDp94FNqMi65zi8CTxhgKdYb/eOX qm92oKqDd85qCeBNHCRFoCnObiDGYHAEskcEO1ou1RiPUvDOF9TlEORtQp/XUfc2QSlRXnp3S GICL+3a+8/n7LTVfmSqe3UadnD73sMKIteUABlCBg3yYC8OdHK336JgmVxNOxmpprhGUVSJJb SJMTmcInsKIcq58zNVbKtV7sD4qbym88UuOFu5qBxeBvZkPoVaeQilzt7DK5w+Jlm8l24F0Xr W5UdTxo2GXTzBBli4v5Z3UaOxJhX2CZp8eu/hJfNZkinh1krUNml7d7lbK3l2TiXFIxXK7Pi9 p26sk9H0FzExZdbBaHs5mCEI+/ym+720/07Yo572oCgjYN897ujNhVPR09a1/aoMiONoVDXi6 eRqumCM6X5sCKgaP4QCs7i0cb4QlUKCHaEVWwJrfTgXR42HLxpIkJ4zO30/a/SX+5dJBVMwNn c6XpTlBkjwI6Q8r3EXHPT5PZMvEo1Y6AxqQciwWRdkQ2QaT2WRZNiI6las0t0lU7/rhW692hs HNWbW1OnoU3BFlbfxlVTe+Vze25A8VohGcQueE7s/fiY5BvKrTQLM690Zl9F5vBAQ/cM= 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 A race condition fix added an rxe_qp structure to the stack in order to be able to perform rollback in rxe_requester(), but the structure is large enough to trigger the warning for possible stack overflow: drivers/infiniband/sw/rxe/rxe_req.c: In function 'rxe_requester': drivers/infiniband/sw/rxe/rxe_req.c:757:1: error: the frame size of 2064 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] This changes the rollback function to only save the psn inside the qp, which is the only field we access in the rollback_qp anyway. Fixes: 3050b9985024 ("IB/rxe: Fix race condition between requester and completer") Signed-off-by: Arnd Bergmann Reviewed-by: Leon Romanovsky --- drivers/infiniband/sw/rxe/rxe_req.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c index 13a848a518e8..cf1ffac25585 100644 --- a/drivers/infiniband/sw/rxe/rxe_req.c +++ b/drivers/infiniband/sw/rxe/rxe_req.c @@ -548,23 +548,23 @@ static void update_wqe_psn(struct rxe_qp *qp, static void save_state(struct rxe_send_wqe *wqe, struct rxe_qp *qp, struct rxe_send_wqe *rollback_wqe, - struct rxe_qp *rollback_qp) + u32 *rollback_psn) { rollback_wqe->state = wqe->state; rollback_wqe->first_psn = wqe->first_psn; rollback_wqe->last_psn = wqe->last_psn; - rollback_qp->req.psn = qp->req.psn; + *rollback_psn = qp->req.psn; } static void rollback_state(struct rxe_send_wqe *wqe, struct rxe_qp *qp, struct rxe_send_wqe *rollback_wqe, - struct rxe_qp *rollback_qp) + u32 rollback_psn) { wqe->state = rollback_wqe->state; wqe->first_psn = rollback_wqe->first_psn; wqe->last_psn = rollback_wqe->last_psn; - qp->req.psn = rollback_qp->req.psn; + qp->req.psn = rollback_psn; } static void update_state(struct rxe_qp *qp, struct rxe_send_wqe *wqe, @@ -593,8 +593,8 @@ int rxe_requester(void *arg) int mtu; int opcode; int ret; - struct rxe_qp rollback_qp; struct rxe_send_wqe rollback_wqe; + u32 rollback_psn; next_wqe: if (unlikely(!qp->valid || qp->req.state == QP_STATE_ERROR)) @@ -717,7 +717,7 @@ int rxe_requester(void *arg) * rxe_xmit_packet(). * Otherwise, completer might initiate an unjustified retry flow. */ - save_state(wqe, qp, &rollback_wqe, &rollback_qp); + save_state(wqe, qp, &rollback_wqe, &rollback_psn); update_wqe_state(qp, wqe, &pkt); update_wqe_psn(qp, wqe, &pkt, payload); ret = rxe_xmit_packet(to_rdev(qp->ibqp.device), qp, &pkt, skb); @@ -725,7 +725,7 @@ int rxe_requester(void *arg) qp->need_req_skb = 1; kfree_skb(skb); - rollback_state(wqe, qp, &rollback_wqe, &rollback_qp); + rollback_state(wqe, qp, &rollback_wqe, rollback_psn); if (ret == -EAGAIN) { rxe_run_task(&qp->req.task, 1);