From: "Amrani, Ram" <Ram.Amrani-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org> To: Jia-Ju Bai <baijiaju1990-9Onoh4P/yGk@public.gmane.org>, "monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org" <monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>, "sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org" <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>, "dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org" <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>, "hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>, "leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org" <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> Cc: "linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" <linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>, "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> Subject: RE: [PATCH V2] rxe: Fix a sleep-in-atomic bug in post_one_send Date: Thu, 1 Jun 2017 08:11:12 +0000 [thread overview] Message-ID: <BN3PR07MB25781AF1049545F0555D3E83F8F60@BN3PR07MB2578.namprd07.prod.outlook.com> (raw) In-Reply-To: <1496303141-14925-1-git-send-email-baijiaju1990-9Onoh4P/yGk@public.gmane.org> > 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 > > To fix it, the lock is released before copy_from_user, and the lock is > acquired again after this function. The parameter "flags" is used to > restore and save the irq status. > Thank Leon for good advice. > ... > init_send_wr(qp, &wqe->wr, ibwr); > @@ -742,7 +742,12 @@ static int init_send_wqe(struct rxe_qp *qp, struct ib_send_wr *ibwr, > 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; > + spin_unlock_irqrestore(&qp->sq.sq_lock, *flags); > + err = copy_from_user(p, (__user void *) > + (uintptr_t)sge->addr, sge->length); > + spin_lock_irqsave(&qp->sq.sq_lock, *flags); > + if (qp->is_user && err) > + return -EFAULT; > > else if (!qp->is_user) > memcpy(p, (void *)(uintptr_t)sge->addr, This isn't my area of expertise. Still something seems weird. You are still calling 'copy_from_user' unprotected in the 'if'. Also, did you mean to use curly brackets on the indented part after the first if?! Ram -- 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
WARNING: multiple messages have this Message-ID (diff)
From: "Amrani, Ram" <Ram.Amrani@cavium.com> To: Jia-Ju Bai <baijiaju1990@163.com>, "monis@mellanox.com" <monis@mellanox.com>, "sean.hefty@intel.com" <sean.hefty@intel.com>, "dledford@redhat.com" <dledford@redhat.com>, "hal.rosenstock@gmail.com" <hal.rosenstock@gmail.com>, "leon@kernel.org" <leon@kernel.org> Cc: "linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org> Subject: RE: [PATCH V2] rxe: Fix a sleep-in-atomic bug in post_one_send Date: Thu, 1 Jun 2017 08:11:12 +0000 [thread overview] Message-ID: <BN3PR07MB25781AF1049545F0555D3E83F8F60@BN3PR07MB2578.namprd07.prod.outlook.com> (raw) In-Reply-To: <1496303141-14925-1-git-send-email-baijiaju1990@163.com> > 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 > > To fix it, the lock is released before copy_from_user, and the lock is > acquired again after this function. The parameter "flags" is used to > restore and save the irq status. > Thank Leon for good advice. > ... > init_send_wr(qp, &wqe->wr, ibwr); > @@ -742,7 +742,12 @@ static int init_send_wqe(struct rxe_qp *qp, struct ib_send_wr *ibwr, > 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; > + spin_unlock_irqrestore(&qp->sq.sq_lock, *flags); > + err = copy_from_user(p, (__user void *) > + (uintptr_t)sge->addr, sge->length); > + spin_lock_irqsave(&qp->sq.sq_lock, *flags); > + if (qp->is_user && err) > + return -EFAULT; > > else if (!qp->is_user) > memcpy(p, (void *)(uintptr_t)sge->addr, This isn't my area of expertise. Still something seems weird. You are still calling 'copy_from_user' unprotected in the 'if'. Also, did you mean to use curly brackets on the indented part after the first if?! Ram
next prev parent reply other threads:[~2017-06-01 8:11 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-06-01 7:45 [PATCH V2] rxe: Fix a sleep-in-atomic bug in post_one_send Jia-Ju Bai 2017-06-01 7:45 ` Jia-Ju Bai [not found] ` <1496303141-14925-1-git-send-email-baijiaju1990-9Onoh4P/yGk@public.gmane.org> 2017-06-01 8:11 ` Amrani, Ram [this message] 2017-06-01 8:11 ` Amrani, Ram 2017-06-01 9:28 ` kbuild test robot 2017-06-01 9:28 ` kbuild test robot
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=BN3PR07MB25781AF1049545F0555D3E83F8F60@BN3PR07MB2578.namprd07.prod.outlook.com \ --to=ram.amrani-ygcgfspz5w/qt0dzr+alfa@public.gmane.org \ --cc=baijiaju1990-9Onoh4P/yGk@public.gmane.org \ --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \ --cc=hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \ --cc=leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \ --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \ --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \ --cc=monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \ --cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.