* [PATCH] arch: mips: sibyte: Return -EFAULT if copy_to_user() fails
@ 2021-03-01 6:33 Wang Qing
2021-03-01 8:53 ` Sergei Shtylyov
0 siblings, 1 reply; 3+ messages in thread
From: Wang Qing @ 2021-03-01 6:33 UTC (permalink / raw)
To: Thomas Bogendoerfer, Wang Qing, linux-mips, linux-kernel
The copy_to_user() function returns the number of bytes remaining to be
copied, but we want to return -EFAULT if the copy doesn't complete.
Signed-off-by: Wang Qing <wangqing@vivo.com>
---
arch/mips/sibyte/common/sb_tbprof.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/mips/sibyte/common/sb_tbprof.c b/arch/mips/sibyte/common/sb_tbprof.c
index f80d7a7..eac125f
--- a/arch/mips/sibyte/common/sb_tbprof.c
+++ b/arch/mips/sibyte/common/sb_tbprof.c
@@ -465,7 +465,7 @@ static ssize_t sbprof_tb_read(struct file *filp, char *buf,
if (err) {
*offp = cur_off + cur_count - err;
mutex_unlock(&sbp.lock);
- return err;
+ return -EFAULT;
}
pr_debug(DEVNAME ": read from sample %d, %d bytes\n",
cur_sample, cur_count);
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] arch: mips: sibyte: Return -EFAULT if copy_to_user() fails
2021-03-01 6:33 [PATCH] arch: mips: sibyte: Return -EFAULT if copy_to_user() fails Wang Qing
@ 2021-03-01 8:53 ` Sergei Shtylyov
2021-03-01 22:01 ` Maciej W. Rozycki
0 siblings, 1 reply; 3+ messages in thread
From: Sergei Shtylyov @ 2021-03-01 8:53 UTC (permalink / raw)
To: Wang Qing, Thomas Bogendoerfer, linux-mips, linux-kernel
Hello!
On 01.03.2021 9:33, Wang Qing wrote:
> The copy_to_user() function returns the number of bytes remaining to be
> copied, but we want to return -EFAULT if the copy doesn't complete.
Then 'err' is hardly a good name for that variable. :-)
>
> Signed-off-by: Wang Qing <wangqing@vivo.com>
> ---
> arch/mips/sibyte/common/sb_tbprof.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/mips/sibyte/common/sb_tbprof.c b/arch/mips/sibyte/common/sb_tbprof.c
> index f80d7a7..eac125f
> --- a/arch/mips/sibyte/common/sb_tbprof.c
> +++ b/arch/mips/sibyte/common/sb_tbprof.c
> @@ -465,7 +465,7 @@ static ssize_t sbprof_tb_read(struct file *filp, char *buf,
> if (err) {
> *offp = cur_off + cur_count - err;
> mutex_unlock(&sbp.lock);
> - return err;
> + return -EFAULT;
> }
> pr_debug(DEVNAME ": read from sample %d, %d bytes\n",
> cur_sample, cur_count);
MBR, Sergei
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] arch: mips: sibyte: Return -EFAULT if copy_to_user() fails
2021-03-01 8:53 ` Sergei Shtylyov
@ 2021-03-01 22:01 ` Maciej W. Rozycki
0 siblings, 0 replies; 3+ messages in thread
From: Maciej W. Rozycki @ 2021-03-01 22:01 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: Wang Qing, Thomas Bogendoerfer, linux-mips, linux-kernel
On Mon, 1 Mar 2021, Sergei Shtylyov wrote:
> > The copy_to_user() function returns the number of bytes remaining to be
> > copied, but we want to return -EFAULT if the copy doesn't complete.
>
> Then 'err' is hardly a good name for that variable. :-)
Something like `left' might be better, especially as it's the sole use.
Also it's been like this from the beginning, so:
Fixes: bb9b813bb665 ("[MIPS] Sibyte: Fix ZBbus profiler")
or maybe:
Fixes: d619f38fdacb ("[MIPS] Add bcm1480 ZBus trace support, fix wait related bugs")
(since the file was renamed from a different name with the latter commit)
would I think be helpful for backports too. It looks like potentially
quite a nasty bug to me if someone actually uses this piece (I haven't).
Maciej
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-02 7:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01 6:33 [PATCH] arch: mips: sibyte: Return -EFAULT if copy_to_user() fails Wang Qing
2021-03-01 8:53 ` Sergei Shtylyov
2021-03-01 22:01 ` Maciej W. Rozycki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).