* [PATCH V5] rxe: Fix a sleep-in-atomic bug in post_one_send
@ 2017-06-05 12:23 ` Jia-Ju Bai
0 siblings, 0 replies; 7+ messages in thread
From: Jia-Ju Bai @ 2017-06-05 12:23 UTC (permalink / raw)
To: monis-VPRAkNaXOzVWk0Htik3J/w, sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
dledford-H+wXaHxf7aLQT0dZR+AlfA,
hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Jia-Ju Bai
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 <baijiaju1990-9Onoh4P/yGk@public.gmane.org>
---
V5:
* Remove useless check of "qp->is_user".
Thank Leon for pointing it out.
V4:
* Remove the line of copy_from_user.
Thank Moni for good advice.
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 | 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 83d709e..073e667 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -740,13 +740,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;
}
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH V5] rxe: Fix a sleep-in-atomic bug in post_one_send
@ 2017-06-05 12:23 ` Jia-Ju Bai
0 siblings, 0 replies; 7+ messages in thread
From: Jia-Ju Bai @ 2017-06-05 12:23 UTC (permalink / raw)
To: monis, sean.hefty, dledford, hal.rosenstock, yuval.shaia
Cc: linux-rdma, linux-kernel, Jia-Ju Bai
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 <baijiaju1990@163.com>
---
V5:
* Remove useless check of "qp->is_user".
Thank Leon for pointing it out.
V4:
* Remove the line of copy_from_user.
Thank Moni for good advice.
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 | 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 83d709e..073e667 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -740,13 +740,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;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH V5] rxe: Fix a sleep-in-atomic bug in post_one_send
2017-06-05 12:23 ` Jia-Ju Bai
(?)
@ 2017-06-05 12:49 ` Leon Romanovsky
-1 siblings, 0 replies; 7+ messages in thread
From: Leon Romanovsky @ 2017-06-05 12:49 UTC (permalink / raw)
To: Jia-Ju Bai
Cc: monis, sean.hefty, dledford, hal.rosenstock, yuval.shaia,
linux-rdma, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 554 bytes --]
On Mon, Jun 05, 2017 at 08:23:40PM +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 lines of copy_from_user
> and check of "qp->is_user" are removed.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
> ---
Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V5] rxe: Fix a sleep-in-atomic bug in post_one_send
2017-06-05 12:23 ` Jia-Ju Bai
@ 2017-06-05 15:06 ` Moni Shoua
-1 siblings, 0 replies; 7+ messages in thread
From: Moni Shoua @ 2017-06-05 15:06 UTC (permalink / raw)
To: Jia-Ju Bai
Cc: Sean Hefty, Doug Ledford, Hal Rosenstock, Yuval Shaia,
linux-rdma, Linux Kernel Mailinglist
Acked-by: Moni Shoua <monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
thanks
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V5] rxe: Fix a sleep-in-atomic bug in post_one_send
@ 2017-06-05 15:06 ` Moni Shoua
0 siblings, 0 replies; 7+ messages in thread
From: Moni Shoua @ 2017-06-05 15:06 UTC (permalink / raw)
To: Jia-Ju Bai
Cc: Sean Hefty, Doug Ledford, Hal Rosenstock, Yuval Shaia,
linux-rdma, Linux Kernel Mailinglist
Acked-by: Moni Shoua <monis@mellanox.com>
thanks
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V5] rxe: Fix a sleep-in-atomic bug in post_one_send
2017-06-05 12:23 ` Jia-Ju Bai
@ 2017-06-13 21:01 ` Doug Ledford
-1 siblings, 0 replies; 7+ messages in thread
From: Doug Ledford @ 2017-06-13 21:01 UTC (permalink / raw)
To: Jia-Ju Bai, monis-VPRAkNaXOzVWk0Htik3J/w,
sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA
On Mon, 2017-06-05 at 20:23 +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 lines of
> copy_from_user
> and check of "qp->is_user" are removed.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990-9Onoh4P/yGk@public.gmane.org>
Thanks, applied.
--
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
GPG KeyID: B826A3330E572FDD
Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V5] rxe: Fix a sleep-in-atomic bug in post_one_send
@ 2017-06-13 21:01 ` Doug Ledford
0 siblings, 0 replies; 7+ messages in thread
From: Doug Ledford @ 2017-06-13 21:01 UTC (permalink / raw)
To: Jia-Ju Bai, monis, sean.hefty, hal.rosenstock, yuval.shaia
Cc: linux-rdma, linux-kernel
On Mon, 2017-06-05 at 20:23 +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 lines of
> copy_from_user
> and check of "qp->is_user" are removed.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
Thanks, applied.
--
Doug Ledford <dledford@redhat.com>
GPG KeyID: B826A3330E572FDD
Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-06-13 21:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-05 12:23 [PATCH V5] rxe: Fix a sleep-in-atomic bug in post_one_send Jia-Ju Bai
2017-06-05 12:23 ` Jia-Ju Bai
2017-06-05 12:49 ` Leon Romanovsky
[not found] ` <1496665420-8100-1-git-send-email-baijiaju1990-9Onoh4P/yGk@public.gmane.org>
2017-06-05 15:06 ` Moni Shoua
2017-06-05 15:06 ` Moni Shoua
2017-06-13 21:01 ` Doug Ledford
2017-06-13 21:01 ` Doug Ledford
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.