Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1970296ima; Thu, 25 Oct 2018 07:44:49 -0700 (PDT) X-Google-Smtp-Source: AJdET5dz/BUGx8P7VubaFokpYa8CBccMa242yNdcs88qWC1UQ0hw7Mxt4Q9Eya7QsX6UBos8qSJJ X-Received: by 2002:a63:d444:: with SMTP id i4-v6mr1726335pgj.194.1540478689696; Thu, 25 Oct 2018 07:44:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540478689; cv=none; d=google.com; s=arc-20160816; b=DhuM3jS9G7yX6zXslzVPlGvAik+CMe0nz6CGk+QxHgjln+GdWBKoHHPouP6va1ee2b mMMUkNHSqU9RdUT6CW92g4p1+4QewpxN4mZvyhx30HiU9y1VanIfKXts9tVq/QoLLDXt Ti3vgQwuX696idKmFBO8IUtZugczj/t3KJABJyDxlEnR+MBihLJQPT9Q3xzQJIPgsOAU mDLTU5EK6QfGSMcXlIGs+iYto/ufL2wPHNrXkMZ7KOMxz20CE15iCDNlwcGx5mFP2vhw rEA07FYHUBj89h8iEi9tCPtiNvp8OnZ+Br5AP1HAolDDpEBVUv51HrqvsV6U7kaa9xTM pQjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=F8kmvbTuw3khu3jMXkdqVa5O5RjL+T+M3dMaInjvLjA=; b=Q2cPycsetYNQCZBMwQWghiURkUnxt4q95owLaq2sgAO/5f8iKBJKc5m1+9zhp8x606 k19atLoVU9y7snm9nyuV85DtBJsVHE7kLytsATQmi47lidnEvhDxFFEPJgN7SgfKQ7DB jLoYwVA0p7oDFfKe9UIJhyZ8qKquKEFrudim2o4oAJtGRxaqoKjWdY3i1WjAr4tjNrhI UuSVX06M5Vt6abI7d0uWKoRYfeDn6mHzEfDPPad9E91fnMCIJ6hcFCENaLDom2lE85pO A1LWEon8shfQrGISylPab2fJWslghzNlCyyEVH51BhOC2NOVhueDMc1OZ6e/XRerdNSy +ZzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JqD8liXf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c2-v6si7832294pgp.451.2018.10.25.07.44.31; Thu, 25 Oct 2018 07:44:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JqD8liXf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728681AbeJYWrt (ORCPT + 99 others); Thu, 25 Oct 2018 18:47:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:56002 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728660AbeJYWrs (ORCPT ); Thu, 25 Oct 2018 18:47:48 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1FDEC20854; Thu, 25 Oct 2018 14:14:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540476892; bh=zrPH1wC9WtalHNIKJhYdScHOCKQIqSXzX2bMfVQJkss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JqD8liXfHE5QB3q4j2lFvP18xhsA+TCEei0qIrLHgiin7GIR1YNXQuJgyNRWT3f7E aDFCj1/CXrlEFAFZ7REs0fmCuzsCZaxMj695RFlr3w2a9sbsNSKbMV5Hid/JwI7I1R lXbVFK3v8zNtet3lH2pDg5MOKA0+5aoHFOGdl+w4= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jia-Ju Bai , Doug Ledford , Sasha Levin Subject: [PATCH AUTOSEL 4.9 17/98] rxe: Fix a sleep-in-atomic bug in post_one_send Date: Thu, 25 Oct 2018 10:13:02 -0400 Message-Id: <20181025141423.213774-17-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141423.213774-1-sashal@kernel.org> References: <20181025141423.213774-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jia-Ju Bai [ Upstream commit 07d432bb97f19dd5e784175152f9fce3b2646133 ] 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 lines of copy_from_user and check of "qp->is_user" are removed. Signed-off-by: Jia-Ju Bai Reviewed-by: Leon Romanovsky Acked-by: Moni Shoua Signed-off-by: Doug Ledford Signed-off-by: Sasha Levin --- drivers/infiniband/sw/rxe/rxe_verbs.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index ced416f5dffb..ef13082d6ca1 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c @@ -729,13 +729,8 @@ 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) - memcpy(p, (void *)(uintptr_t)sge->addr, - sge->length); + memcpy(p, (void *)(uintptr_t)sge->addr, + sge->length); p += sge->length; } -- 2.17.1