coda: return -EFAULT if copy fails

Message ID 20230515061923.767680-1-suhui@nfschina.com
State New
Headers
Series coda: return -EFAULT if copy fails |

Commit Message

Su Hui May 15, 2023, 6:19 a.m. UTC
  The copy_to/from_user() functions should return -EFAULT instead of -EINVAL.

Signed-off-by: Su Hui <suhui@nfschina.com>
---
 fs/coda/upcall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Dan Carpenter May 15, 2023, 7:35 a.m. UTC | #1
On Mon, May 15, 2023 at 02:19:23PM +0800, Su Hui wrote:
> The copy_to/from_user() functions should return -EFAULT instead of -EINVAL.
> 
> Signed-off-by: Su Hui <suhui@nfschina.com>
> ---

Could you add a Fixes tag?

regards,
dan carpenter
  
Christophe JAILLET May 15, 2023, 5:15 p.m. UTC | #2
Le 15/05/2023 à 08:19, Su Hui a écrit :
> The copy_to/from_user() functions should return -EFAULT instead of -EINVAL.

Hi,

just for my understanding, why?

Even if not perfect:
    git grep -A1 copy_from_user | grep EINV | wc -l
    15

    git grep -A1 copy_to_user | grep EINV | wc -l
    12

CJ

> 
> Signed-off-by: Su Hui <suhui@nfschina.com>
> ---
>   fs/coda/upcall.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
> index cd6a3721f6f6..1517dc3bd592 100644
> --- a/fs/coda/upcall.c
> +++ b/fs/coda/upcall.c
> @@ -510,7 +510,7 @@ int venus_pioctl(struct super_block *sb, struct CodaFid *fid,
>           /* get the data out of user space */
>   	if (copy_from_user((char *)inp + (long)inp->coda_ioctl.data,
>   			   data->vi.in, data->vi.in_size)) {
> -		error = -EINVAL;
> +		error = -EFAULT;
>   	        goto exit;
>   	}
>
  
Su Hui May 16, 2023, 1:35 a.m. UTC | #3
On 2023/5/15 15:35, Dan Carpenter wrote:
> On Mon, May 15, 2023 at 02:19:23PM +0800, Su Hui wrote:
>> The copy_to/from_user() functions should return -EFAULT instead of -EINVAL.
>>
>> Signed-off-by: Su Hui <suhui@nfschina.com>
>> ---
> Could you add a Fixes tag?

Hi,

This doesn't seem like a bug.

So I think Fixes tag should not be used here.

Thanks for your reply!

Su Hui

> regards,
> dan carpenter
>
  

Patch

diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
index cd6a3721f6f6..1517dc3bd592 100644
--- a/fs/coda/upcall.c
+++ b/fs/coda/upcall.c
@@ -510,7 +510,7 @@  int venus_pioctl(struct super_block *sb, struct CodaFid *fid,
         /* get the data out of user space */
 	if (copy_from_user((char *)inp + (long)inp->coda_ioctl.data,
 			   data->vi.in, data->vi.in_size)) {
-		error = -EINVAL;
+		error = -EFAULT;
 	        goto exit;
 	}