All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails
@ 2020-05-11 18:37 ` Dan Carpenter
  0 siblings, 0 replies; 16+ messages in thread
From: Dan Carpenter @ 2020-05-11 18:37 UTC (permalink / raw)
  To: Zhu Yanjun, Sudip Mukherjee
  Cc: Doug Ledford, Jason Gunthorpe, linux-rdma, kernel-janitors

This function used to always return -EINVAL but we updated it to try
preserve the error codes.  Unfortunately the copy_to_user() is returning
the number of bytes remaining to be copied instead of a negative error
code.

Fixes: a3a974b4654d ("RDMA/rxe: Always return ERR_PTR from rxe_create_mmap_info()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/infiniband/sw/rxe/rxe_queue.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_queue.c b/drivers/infiniband/sw/rxe/rxe_queue.c
index fef2ab5112de5..245040c3a35d0 100644
--- a/drivers/infiniband/sw/rxe/rxe_queue.c
+++ b/drivers/infiniband/sw/rxe/rxe_queue.c
@@ -50,9 +50,10 @@ int do_mmap_info(struct rxe_dev *rxe, struct mminfo __user *outbuf,
 			goto err1;
 		}
 
-		err = copy_to_user(outbuf, &ip->info, sizeof(ip->info));
-		if (err)
+		if (copy_to_user(outbuf, &ip->info, sizeof(ip->info))) {
+			err = -EFAULT;
 			goto err2;
+		}
 
 		spin_lock_bh(&rxe->pending_lock);
 		list_add(&ip->pending_mmaps, &rxe->pending_mmaps);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails
@ 2020-05-11 18:37 ` Dan Carpenter
  0 siblings, 0 replies; 16+ messages in thread
From: Dan Carpenter @ 2020-05-11 18:37 UTC (permalink / raw)
  To: Zhu Yanjun, Sudip Mukherjee
  Cc: Doug Ledford, Jason Gunthorpe, linux-rdma, kernel-janitors

This function used to always return -EINVAL but we updated it to try
preserve the error codes.  Unfortunately the copy_to_user() is returning
the number of bytes remaining to be copied instead of a negative error
code.

Fixes: a3a974b4654d ("RDMA/rxe: Always return ERR_PTR from rxe_create_mmap_info()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/infiniband/sw/rxe/rxe_queue.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_queue.c b/drivers/infiniband/sw/rxe/rxe_queue.c
index fef2ab5112de5..245040c3a35d0 100644
--- a/drivers/infiniband/sw/rxe/rxe_queue.c
+++ b/drivers/infiniband/sw/rxe/rxe_queue.c
@@ -50,9 +50,10 @@ int do_mmap_info(struct rxe_dev *rxe, struct mminfo __user *outbuf,
 			goto err1;
 		}
 
-		err = copy_to_user(outbuf, &ip->info, sizeof(ip->info));
-		if (err)
+		if (copy_to_user(outbuf, &ip->info, sizeof(ip->info))) {
+			err = -EFAULT;
 			goto err2;
+		}
 
 		spin_lock_bh(&rxe->pending_lock);
 		list_add(&ip->pending_mmaps, &rxe->pending_mmaps);
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* RE: [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails
  2020-05-11 18:37 ` Dan Carpenter
  (?)
@ 2020-05-12  1:12 ` Yanjun Zhu
  2020-05-12  6:22     ` Leon Romanovsky
  -1 siblings, 1 reply; 16+ messages in thread
From: Yanjun Zhu @ 2020-05-12  1:12 UTC (permalink / raw)
  To: Dan Carpenter, Sudip Mukherjee
  Cc: Doug Ledford, Jason Gunthorpe, linux-rdma, kernel-janitors

Does this "err = -EFAULT;" make any sense in your commit?

Zhu Yanjun

-----Original Message-----
From: Dan Carpenter <dan.carpenter@oracle.com> 
Sent: Tuesday, May 12, 2020 2:38 AM
To: Yanjun Zhu <yanjunz@mellanox.com>; Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Doug Ledford <dledford@redhat.com>; Jason Gunthorpe <jgg@ziepe.ca>; linux-rdma@vger.kernel.org; kernel-janitors@vger.kernel.org
Subject: [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails

This function used to always return -EINVAL but we updated it to try preserve the error codes.  Unfortunately the copy_to_user() is returning the number of bytes remaining to be copied instead of a negative error code.

Fixes: a3a974b4654d ("RDMA/rxe: Always return ERR_PTR from rxe_create_mmap_info()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/infiniband/sw/rxe/rxe_queue.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_queue.c b/drivers/infiniband/sw/rxe/rxe_queue.c
index fef2ab5112de5..245040c3a35d0 100644
--- a/drivers/infiniband/sw/rxe/rxe_queue.c
+++ b/drivers/infiniband/sw/rxe/rxe_queue.c
@@ -50,9 +50,10 @@ int do_mmap_info(struct rxe_dev *rxe, struct mminfo __user *outbuf,
 			goto err1;
 		}
 
-		err = copy_to_user(outbuf, &ip->info, sizeof(ip->info));
-		if (err)
+		if (copy_to_user(outbuf, &ip->info, sizeof(ip->info))) {
+			err = -EFAULT;
 			goto err2;
+		}
 
 		spin_lock_bh(&rxe->pending_lock);
 		list_add(&ip->pending_mmaps, &rxe->pending_mmaps);
--
2.26.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails
  2020-05-12  1:12 ` Yanjun Zhu
@ 2020-05-12  6:22     ` Leon Romanovsky
  0 siblings, 0 replies; 16+ messages in thread
From: Leon Romanovsky @ 2020-05-12  6:22 UTC (permalink / raw)
  To: Yanjun Zhu
  Cc: Dan Carpenter, Sudip Mukherjee, Doug Ledford, Jason Gunthorpe,
	linux-rdma, kernel-janitors

On Tue, May 12, 2020 at 01:12:38AM +0000, Yanjun Zhu wrote:
> Does this "err = -EFAULT;" make any sense in your commit?

Yanjun, please stop top-posting, it is annoying.

Thanks

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails
@ 2020-05-12  6:22     ` Leon Romanovsky
  0 siblings, 0 replies; 16+ messages in thread
From: Leon Romanovsky @ 2020-05-12  6:22 UTC (permalink / raw)
  To: Yanjun Zhu
  Cc: Dan Carpenter, Sudip Mukherjee, Doug Ledford, Jason Gunthorpe,
	linux-rdma, kernel-janitors

On Tue, May 12, 2020 at 01:12:38AM +0000, Yanjun Zhu wrote:
> Does this "err = -EFAULT;" make any sense in your commit?

Yanjun, please stop top-posting, it is annoying.

Thanks

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails
  2020-05-11 18:37 ` Dan Carpenter
@ 2020-05-12  6:29   ` Leon Romanovsky
  -1 siblings, 0 replies; 16+ messages in thread
From: Leon Romanovsky @ 2020-05-12  6:29 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Zhu Yanjun, Sudip Mukherjee, Doug Ledford, Jason Gunthorpe,
	linux-rdma, kernel-janitors

On Mon, May 11, 2020 at 09:37:42PM +0300, Dan Carpenter wrote:
> This function used to always return -EINVAL but we updated it to try
> preserve the error codes.  Unfortunately the copy_to_user() is returning
> the number of bytes remaining to be copied instead of a negative error
> code.
>
> Fixes: a3a974b4654d ("RDMA/rxe: Always return ERR_PTR from rxe_create_mmap_info()")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/infiniband/sw/rxe/rxe_queue.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)


Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails
@ 2020-05-12  6:29   ` Leon Romanovsky
  0 siblings, 0 replies; 16+ messages in thread
From: Leon Romanovsky @ 2020-05-12  6:29 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Zhu Yanjun, Sudip Mukherjee, Doug Ledford, Jason Gunthorpe,
	linux-rdma, kernel-janitors

On Mon, May 11, 2020 at 09:37:42PM +0300, Dan Carpenter wrote:
> This function used to always return -EINVAL but we updated it to try
> preserve the error codes.  Unfortunately the copy_to_user() is returning
> the number of bytes remaining to be copied instead of a negative error
> code.
>
> Fixes: a3a974b4654d ("RDMA/rxe: Always return ERR_PTR from rxe_create_mmap_info()")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/infiniband/sw/rxe/rxe_queue.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)


Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails
  2020-05-12  6:29   ` Leon Romanovsky
@ 2020-05-12  7:02     ` Leon Romanovsky
  -1 siblings, 0 replies; 16+ messages in thread
From: Leon Romanovsky @ 2020-05-12  7:02 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Zhu Yanjun, Sudip Mukherjee, Doug Ledford, Jason Gunthorpe,
	linux-rdma, kernel-janitors

On Tue, May 12, 2020 at 09:29:36AM +0300, Leon Romanovsky wrote:
> On Mon, May 11, 2020 at 09:37:42PM +0300, Dan Carpenter wrote:
> > This function used to always return -EINVAL but we updated it to try
> > preserve the error codes.  Unfortunately the copy_to_user() is returning
> > the number of bytes remaining to be copied instead of a negative error
> > code.
> >
> > Fixes: a3a974b4654d ("RDMA/rxe: Always return ERR_PTR from rxe_create_mmap_info()")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> >  drivers/infiniband/sw/rxe/rxe_queue.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
>
>
> Thanks,
> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

Actually Yanjun is right and "err" can be removed.

Thanks

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails
@ 2020-05-12  7:02     ` Leon Romanovsky
  0 siblings, 0 replies; 16+ messages in thread
From: Leon Romanovsky @ 2020-05-12  7:02 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Zhu Yanjun, Sudip Mukherjee, Doug Ledford, Jason Gunthorpe,
	linux-rdma, kernel-janitors

On Tue, May 12, 2020 at 09:29:36AM +0300, Leon Romanovsky wrote:
> On Mon, May 11, 2020 at 09:37:42PM +0300, Dan Carpenter wrote:
> > This function used to always return -EINVAL but we updated it to try
> > preserve the error codes.  Unfortunately the copy_to_user() is returning
> > the number of bytes remaining to be copied instead of a negative error
> > code.
> >
> > Fixes: a3a974b4654d ("RDMA/rxe: Always return ERR_PTR from rxe_create_mmap_info()")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> >  drivers/infiniband/sw/rxe/rxe_queue.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
>
>
> Thanks,
> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

Actually Yanjun is right and "err" can be removed.

Thanks

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails
  2020-05-12  7:02     ` Leon Romanovsky
@ 2020-05-12  8:17       ` Dan Carpenter
  -1 siblings, 0 replies; 16+ messages in thread
From: Dan Carpenter @ 2020-05-12  8:17 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Zhu Yanjun, Sudip Mukherjee, Doug Ledford, Jason Gunthorpe,
	linux-rdma, kernel-janitors

On Tue, May 12, 2020 at 10:02:03AM +0300, Leon Romanovsky wrote:
> On Tue, May 12, 2020 at 09:29:36AM +0300, Leon Romanovsky wrote:
> > On Mon, May 11, 2020 at 09:37:42PM +0300, Dan Carpenter wrote:
> > > This function used to always return -EINVAL but we updated it to try
> > > preserve the error codes.  Unfortunately the copy_to_user() is returning
> > > the number of bytes remaining to be copied instead of a negative error
> > > code.
> > >
> > > Fixes: a3a974b4654d ("RDMA/rxe: Always return ERR_PTR from rxe_create_mmap_info()")
> > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > ---
> > >  drivers/infiniband/sw/rxe/rxe_queue.c | 5 +++--
> > >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> >
> > Thanks,
> > Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
> 
> Actually Yanjun is right and "err" can be removed.
> 
> Thanks

I don't know if the code you guys are looking at is older or newer than
linux-next...  :P

drivers/infiniband/sw/rxe/rxe_queue.c
    39  int do_mmap_info(struct rxe_dev *rxe, struct mminfo __user *outbuf,
    40                   struct ib_udata *udata, struct rxe_queue_buf *buf,
    41                   size_t buf_size, struct rxe_mmap_info **ip_p)
    42  {
    43          int err;
                    ^^^

    44          struct rxe_mmap_info *ip = NULL;
    45  
    46          if (outbuf) {
    47                  ip = rxe_create_mmap_info(rxe, buf_size, udata, buf);
    48                  if (IS_ERR(ip)) {
    49                          err = PTR_ERR(ip);
    50                          goto err1;
                                ^^^^^^^^^
    51                  }
    52  
    53                  err = copy_to_user(outbuf, &ip->info, sizeof(ip->info));
    54                  if (err)
    55                          goto err2;
                                ^^^^^^^^^
    56  
    57                  spin_lock_bh(&rxe->pending_lock);
    58                  list_add(&ip->pending_mmaps, &rxe->pending_mmaps);
    59                  spin_unlock_bh(&rxe->pending_lock);
    60          }
    61  
    62          *ip_p = ip;
    63  
    64          return 0;
    65  
    66  err2:
    67          kfree(ip);
    68  err1:
    69          return err;
                       ^^^
    70  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails
@ 2020-05-12  8:17       ` Dan Carpenter
  0 siblings, 0 replies; 16+ messages in thread
From: Dan Carpenter @ 2020-05-12  8:17 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Zhu Yanjun, Sudip Mukherjee, Doug Ledford, Jason Gunthorpe,
	linux-rdma, kernel-janitors

On Tue, May 12, 2020 at 10:02:03AM +0300, Leon Romanovsky wrote:
> On Tue, May 12, 2020 at 09:29:36AM +0300, Leon Romanovsky wrote:
> > On Mon, May 11, 2020 at 09:37:42PM +0300, Dan Carpenter wrote:
> > > This function used to always return -EINVAL but we updated it to try
> > > preserve the error codes.  Unfortunately the copy_to_user() is returning
> > > the number of bytes remaining to be copied instead of a negative error
> > > code.
> > >
> > > Fixes: a3a974b4654d ("RDMA/rxe: Always return ERR_PTR from rxe_create_mmap_info()")
> > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > ---
> > >  drivers/infiniband/sw/rxe/rxe_queue.c | 5 +++--
> > >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> >
> > Thanks,
> > Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
> 
> Actually Yanjun is right and "err" can be removed.
> 
> Thanks

I don't know if the code you guys are looking at is older or newer than
linux-next...  :P

drivers/infiniband/sw/rxe/rxe_queue.c
    39  int do_mmap_info(struct rxe_dev *rxe, struct mminfo __user *outbuf,
    40                   struct ib_udata *udata, struct rxe_queue_buf *buf,
    41                   size_t buf_size, struct rxe_mmap_info **ip_p)
    42  {
    43          int err;
                    ^^^

    44          struct rxe_mmap_info *ip = NULL;
    45  
    46          if (outbuf) {
    47                  ip = rxe_create_mmap_info(rxe, buf_size, udata, buf);
    48                  if (IS_ERR(ip)) {
    49                          err = PTR_ERR(ip);
    50                          goto err1;
                                ^^^^^^^^^
    51                  }
    52  
    53                  err = copy_to_user(outbuf, &ip->info, sizeof(ip->info));
    54                  if (err)
    55                          goto err2;
                                ^^^^^^^^^
    56  
    57                  spin_lock_bh(&rxe->pending_lock);
    58                  list_add(&ip->pending_mmaps, &rxe->pending_mmaps);
    59                  spin_unlock_bh(&rxe->pending_lock);
    60          }
    61  
    62          *ip_p = ip;
    63  
    64          return 0;
    65  
    66  err2:
    67          kfree(ip);
    68  err1:
    69          return err;
                       ^^^
    70  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails
  2020-05-12  8:17       ` Dan Carpenter
@ 2020-05-12  8:31         ` Leon Romanovsky
  -1 siblings, 0 replies; 16+ messages in thread
From: Leon Romanovsky @ 2020-05-12  8:31 UTC (permalink / raw)
  To: Dan Carpenter, Jason Gunthorpe
  Cc: Zhu Yanjun, Sudip Mukherjee, Doug Ledford, linux-rdma, kernel-janitors

On Tue, May 12, 2020 at 11:17:06AM +0300, Dan Carpenter wrote:
> On Tue, May 12, 2020 at 10:02:03AM +0300, Leon Romanovsky wrote:
> > On Tue, May 12, 2020 at 09:29:36AM +0300, Leon Romanovsky wrote:
> > > On Mon, May 11, 2020 at 09:37:42PM +0300, Dan Carpenter wrote:
> > > > This function used to always return -EINVAL but we updated it to try
> > > > preserve the error codes.  Unfortunately the copy_to_user() is returning
> > > > the number of bytes remaining to be copied instead of a negative error
> > > > code.
> > > >
> > > > Fixes: a3a974b4654d ("RDMA/rxe: Always return ERR_PTR from rxe_create_mmap_info()")
> > > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > > ---
> > > >  drivers/infiniband/sw/rxe/rxe_queue.c | 5 +++--
> > > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > >
> > >
> > > Thanks,
> > > Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
> >
> > Actually Yanjun is right and "err" can be removed.
> >
> > Thanks
>
> I don't know if the code you guys are looking at is older or newer than
> linux-next...  :P

We both looked on rdma-next, but the wrong code was added to -rc.

Jason, that patch was marked as stable@.

Thanks

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails
@ 2020-05-12  8:31         ` Leon Romanovsky
  0 siblings, 0 replies; 16+ messages in thread
From: Leon Romanovsky @ 2020-05-12  8:31 UTC (permalink / raw)
  To: Dan Carpenter, Jason Gunthorpe
  Cc: Zhu Yanjun, Sudip Mukherjee, Doug Ledford, linux-rdma, kernel-janitors

On Tue, May 12, 2020 at 11:17:06AM +0300, Dan Carpenter wrote:
> On Tue, May 12, 2020 at 10:02:03AM +0300, Leon Romanovsky wrote:
> > On Tue, May 12, 2020 at 09:29:36AM +0300, Leon Romanovsky wrote:
> > > On Mon, May 11, 2020 at 09:37:42PM +0300, Dan Carpenter wrote:
> > > > This function used to always return -EINVAL but we updated it to try
> > > > preserve the error codes.  Unfortunately the copy_to_user() is returning
> > > > the number of bytes remaining to be copied instead of a negative error
> > > > code.
> > > >
> > > > Fixes: a3a974b4654d ("RDMA/rxe: Always return ERR_PTR from rxe_create_mmap_info()")
> > > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > > ---
> > > >  drivers/infiniband/sw/rxe/rxe_queue.c | 5 +++--
> > > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > >
> > >
> > > Thanks,
> > > Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
> >
> > Actually Yanjun is right and "err" can be removed.
> >
> > Thanks
>
> I don't know if the code you guys are looking at is older or newer than
> linux-next...  :P

We both looked on rdma-next, but the wrong code was added to -rc.

Jason, that patch was marked as stable@.

Thanks

^ permalink raw reply	[flat|nested] 16+ messages in thread

* RE: [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails
  2020-05-12  8:31         ` Leon Romanovsky
  (?)
@ 2020-05-12  8:33         ` Yanjun Zhu
  -1 siblings, 0 replies; 16+ messages in thread
From: Yanjun Zhu @ 2020-05-12  8:33 UTC (permalink / raw)
  To: Leon Romanovsky, Dan Carpenter, Jason Gunthorpe
  Cc: Sudip Mukherjee, Doug Ledford, linux-rdma, kernel-janitors



-----Original Message-----
From: Leon Romanovsky <leon@kernel.org> 
Sent: Tuesday, May 12, 2020 4:31 PM
To: Dan Carpenter <dan.carpenter@oracle.com>; Jason Gunthorpe <jgg@ziepe.ca>
Cc: Yanjun Zhu <yanjunz@mellanox.com>; Sudip Mukherjee <sudipm.mukherjee@gmail.com>; Doug Ledford <dledford@redhat.com>; linux-rdma@vger.kernel.org; kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails

On Tue, May 12, 2020 at 11:17:06AM +0300, Dan Carpenter wrote:
> On Tue, May 12, 2020 at 10:02:03AM +0300, Leon Romanovsky wrote:
> > On Tue, May 12, 2020 at 09:29:36AM +0300, Leon Romanovsky wrote:
> > > On Mon, May 11, 2020 at 09:37:42PM +0300, Dan Carpenter wrote:
> > > > This function used to always return -EINVAL but we updated it to 
> > > > try preserve the error codes.  Unfortunately the copy_to_user() 
> > > > is returning the number of bytes remaining to be copied instead 
> > > > of a negative error code.
> > > >
> > > > Fixes: a3a974b4654d ("RDMA/rxe: Always return ERR_PTR from 
> > > > rxe_create_mmap_info()")
> > > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > > ---
> > > >  drivers/infiniband/sw/rxe/rxe_queue.c | 5 +++--
> > > >  1 file changed, 3 insertions(+), 2 deletions(-)
> > >
> > >
> > > Thanks,
> > > Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
> >
> > Actually Yanjun is right and "err" can be removed.
> >
> > Thanks
>
> I don't know if the code you guys are looking at is older or newer 
> than linux-next...  :P

> We both looked on rdma-next, but the wrong code was added to -rc.

Yes. I agree with you.

Zhu Yanjun

> Jason, that patch was marked as stable@.

Thanks

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails
  2020-05-11 18:37 ` Dan Carpenter
@ 2020-05-12 14:51   ` Jason Gunthorpe
  -1 siblings, 0 replies; 16+ messages in thread
From: Jason Gunthorpe @ 2020-05-12 14:51 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Zhu Yanjun, Sudip Mukherjee, Doug Ledford, linux-rdma, kernel-janitors

On Mon, May 11, 2020 at 09:37:42PM +0300, Dan Carpenter wrote:
> This function used to always return -EINVAL but we updated it to try
> preserve the error codes.  Unfortunately the copy_to_user() is returning
> the number of bytes remaining to be copied instead of a negative error
> code.
> 
> Fixes: a3a974b4654d ("RDMA/rxe: Always return ERR_PTR from rxe_create_mmap_info()")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/infiniband/sw/rxe/rxe_queue.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

I squashed this into to the above patch since it is marked for -stable

This means for-rc gets rebased

Thanks,
Jason

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails
@ 2020-05-12 14:51   ` Jason Gunthorpe
  0 siblings, 0 replies; 16+ messages in thread
From: Jason Gunthorpe @ 2020-05-12 14:51 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Zhu Yanjun, Sudip Mukherjee, Doug Ledford, linux-rdma, kernel-janitors

On Mon, May 11, 2020 at 09:37:42PM +0300, Dan Carpenter wrote:
> This function used to always return -EINVAL but we updated it to try
> preserve the error codes.  Unfortunately the copy_to_user() is returning
> the number of bytes remaining to be copied instead of a negative error
> code.
> 
> Fixes: a3a974b4654d ("RDMA/rxe: Always return ERR_PTR from rxe_create_mmap_info()")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/infiniband/sw/rxe/rxe_queue.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

I squashed this into to the above patch since it is marked for -stable

This means for-rc gets rebased

Thanks,
Jason

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2020-05-12 14:51 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-11 18:37 [PATCH] RDMA/rxe: Return -EFAULT if copy_from_user() fails Dan Carpenter
2020-05-11 18:37 ` Dan Carpenter
2020-05-12  1:12 ` Yanjun Zhu
2020-05-12  6:22   ` Leon Romanovsky
2020-05-12  6:22     ` Leon Romanovsky
2020-05-12  6:29 ` Leon Romanovsky
2020-05-12  6:29   ` Leon Romanovsky
2020-05-12  7:02   ` Leon Romanovsky
2020-05-12  7:02     ` Leon Romanovsky
2020-05-12  8:17     ` Dan Carpenter
2020-05-12  8:17       ` Dan Carpenter
2020-05-12  8:31       ` Leon Romanovsky
2020-05-12  8:31         ` Leon Romanovsky
2020-05-12  8:33         ` Yanjun Zhu
2020-05-12 14:51 ` Jason Gunthorpe
2020-05-12 14:51   ` Jason Gunthorpe

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.