[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iKJQCmEPxf=296_dGt9Wb3MD=0mp0vP6X4exWUPML=UUw@mail.gmail.com>
Date: Thu, 13 Oct 2022 08:37:08 -0700
From: Eric Dumazet <edumazet@...gle.com>
To: Xiaobo Liu <cppcoffee@...il.com>
Cc: davem@...emloft.net, kuba@...nel.org, pabeni@...hat.com,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net/atm: fix proc_mpc_write 1 byte less calculated
On Thu, Oct 13, 2022 at 8:19 AM Xiaobo Liu <cppcoffee@...il.com> wrote:
>
> Then the input contains '\0' or '\n', proc_mpc_write has read them,
> so the return value needs +1.
>
> Signed-off-by: Xiaobo Liu <cppcoffee@...il.com>
> ---
> net/atm/mpoa_proc.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c
> index 829db9eba..444ceda60 100755
> --- a/net/atm/mpoa_proc.c
> +++ b/net/atm/mpoa_proc.c
> @@ -224,8 +224,11 @@ static ssize_t proc_mpc_write(struct file *file, const char __user *buff,
> free_page((unsigned long)page);
> return -EFAULT;
> }
> - if (*p == '\0' || *p == '\n')
> +
> + if (*p == '\0' || *p == '\n') {
> + len += 1
> break;
> + }
> }
>
> *p = '\0';
> --
> 2.21.0 (Apple Git-122.2)
>
Hi Xiaobo
Can you submit a v2, with this added tag ?
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Also, I would switch to something cleaner like
diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c
index 829db9eba0cb95ac9cfe775e8eaad712943a8dbe..df530e9725fa63820a7adcd44e750db0733f9d94
100644
--- a/net/atm/mpoa_proc.c
+++ b/net/atm/mpoa_proc.c
@@ -219,11 +219,12 @@ static ssize_t proc_mpc_write(struct file *file,
const char __user *buff,
if (!page)
return -ENOMEM;
- for (p = page, len = 0; len < nbytes; p++, len++) {
+ for (p = page, len = 0; len < nbytes; p++) {
if (get_user(*p, buff++)) {
free_page((unsigned long)page);
return -EFAULT;
}
+ len++;
if (*p == '\0' || *p == '\n')
break;
}
Powered by blists - more mailing lists