Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751579AbdFEKMy (ORCPT ); Mon, 5 Jun 2017 06:12:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:54078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751332AbdFEKMx (ORCPT ); Mon, 5 Jun 2017 06:12:53 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 19F5C239ED Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=leon@kernel.org Date: Mon, 5 Jun 2017 13:12:49 +0300 From: Leon Romanovsky To: Jia-Ju Bai Cc: monis@mellanox.com, sean.hefty@intel.com, dledford@redhat.com, hal.rosenstock@gmail.com, yuval.shaia@oracle.com, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V4] rxe: Fix a sleep-in-atomic bug in post_one_send Message-ID: <20170605101249.GK6868@mtr-leonro.local> References: <1496655588-5598-1-git-send-email-baijiaju1990@163.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="zqjkMoGlbUJ91oFe" Content-Disposition: inline In-Reply-To: <1496655588-5598-1-git-send-email-baijiaju1990@163.com> User-Agent: Mutt/1.8.2 (2017-04-18) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2812 Lines: 81 --zqjkMoGlbUJ91oFe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jun 05, 2017 at 05:39:48PM +0800, Jia-Ju Bai wrote: > The driver may sleep under a spin lock, and the function call path is: > post_one_send (acquire the lock by spin_lock_irqsave) > init_send_wqe > copy_from_user --> may sleep > > There is no flow that makes "qp->is_user" true, and copy_from_user may > cause bug when a non-user pointer is used. So, the line of copy_from_user > is removed. > > Signed-off-by: Jia-Ju Bai > --- > V4: > * Remove the line of copy_from_user. > > V3: > * It corrects the mistakes of remaining legacy code in V2. > (Thank Ram for pointing it out) > > V2: > * The parameter "flags" is added to restore and save the irq status. > Thank Leon for good advice. > --- > drivers/infiniband/sw/rxe/rxe_verbs.c | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c > index 83d709e..7c52c7c 100644 > --- a/drivers/infiniband/sw/rxe/rxe_verbs.c > +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c > @@ -740,11 +740,7 @@ static int init_send_wqe(struct rxe_qp *qp, struct ib_send_wr *ibwr, > > sge = ibwr->sg_list; > for (i = 0; i < num_sge; i++, sge++) { > - if (qp->is_user && copy_from_user(p, (__user void *) > - (uintptr_t)sge->addr, sge->length)) > - return -EFAULT; > - > - else if (!qp->is_user) > + if (!qp->is_user) According to the Moni's previous responses the line above is always true. > memcpy(p, (void *)(uintptr_t)sge->addr, > sge->length); > > -- > 1.7.9.5 > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html --zqjkMoGlbUJ91oFe Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEkhr/r4Op1/04yqaB5GN7iDZyWKcFAlk1LqEACgkQ5GN7iDZy WKeN3BAAxtIr6JDfut2Qtkb8jcWNMyIQx+QyOaUGTw3PujcYdjw5m/IsGUt3HOao cx3myqOrbreR/2L3Ghew3/L/SsXPUdrBjGNYZdp0jCkfh2vcQ19f9+6igaOZk0i6 p8Jm4SWWgxvLiy5klqMjfw7ny3yj9HUc+4qIXvRIaCUIABDIjPIWFdEDI7NZ5yvH 6n/ZWKBr7riwDG59dteGB4flIcVG/xrMuf4zln/n9d6yWsCk1vnjefmeiUcwygJV rJeRmNHBb7gHbSlXlCPsLa9jZE4ylfrQaWLObPh5LRitbW0Q9k9xdavsnSRBzpGm K3zgKReBihbDEBtDdk1U9pIUb1HuAWNFt7/Lsdrs7smvhWhYMR8JyBE7cQXTPuhZ sJdfML8vzXWDfw/YvKkcGAdLE9AZB0mHlCtxQ6tpigyS5RbTFua/iEO9kMGEFhTi vMigmBVNDACD6mXcTbLpWreDImqH2DpnO4wO0Ejx7k++xre2VbauWweEO1GFk+Zm avT/36Q3RvYDYOP2r8PQ5bxHEV8BYn48oSq2flLYxyswzupzzeCcg+11HBaM6lrr DoS+slVL6gUl+dtnFYdcl4ZkXO2GVNcQVXrRDdMRPEE0GxLmcjtmTbMkRvxFvlUQ QGByhllvmRh/wHRBhODg07BdYbKtMA6etOF0zD2nphsnCtk+2kU= =3VLz -----END PGP SIGNATURE----- --zqjkMoGlbUJ91oFe--