Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1657469 > unrolled thread

[PATCH V4] rxe: Fix a sleep-in-atomic bug in post_one_send

Started byJia-Ju Bai <baijiaju1990@163.com>
First post2017-06-05 11:40 +0200
Last post2017-06-05 12:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH V4] rxe: Fix a sleep-in-atomic bug in post_one_send Jia-Ju Bai <baijiaju1990@163.com> - 2017-06-05 11:40 +0200
    Re: [PATCH V4] rxe: Fix a sleep-in-atomic bug in post_one_send Leon Romanovsky <leon@kernel.org> - 2017-06-05 12:20 +0200

#1657469 — [PATCH V4] rxe: Fix a sleep-in-atomic bug in post_one_send

FromJia-Ju Bai <baijiaju1990@163.com>
Date2017-06-05 11:40 +0200
Subject[PATCH V4] rxe: Fix a sleep-in-atomic bug in post_one_send
Message-ID<tOWEq-193-29@gated-at.bofh.it>
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 <baijiaju1990@163.com>
---
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)
 				memcpy(p, (void *)(uintptr_t)sge->addr,
 				       sge->length);
 
-- 
1.7.9.5

[toc] | [next] | [standalone]


#1657481

FromLeon Romanovsky <leon@kernel.org>
Date2017-06-05 12:20 +0200
Message-ID<tOXh7-1Ba-5@gated-at.bofh.it>
In reply to#1657469

[Multipart message — attachments visible in raw view] — view raw

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 <baijiaju1990@163.com>
> ---
> 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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web