linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: do not overwrite scrub error with fault error in scrub ioctl
@ 2018-12-14 19:44 fdmanana
  2018-12-14 19:50 ` [PATCH v2] " fdmanana
  0 siblings, 1 reply; 3+ messages in thread
From: fdmanana @ 2018-12-14 19:44 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

If scrub returned an error and then the copy_to_user() call did not
succeed, we would overwrite the error returned by scrub with -EFAULT.
Fix that by removing the call to copy_to_user() as there is no need
to do it at all.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/ioctl.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 3a27efa2b955..01d18e1a393e 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -4301,9 +4301,6 @@ static long btrfs_ioctl_scrub(struct file *file, void __user *arg)
 			      &sa->progress, sa->flags & BTRFS_SCRUB_READONLY,
 			      0);
 
-	if (copy_to_user(arg, sa, sizeof(*sa)))
-		ret = -EFAULT;
-
 	if (!(sa->flags & BTRFS_SCRUB_READONLY))
 		mnt_drop_write_file(file);
 out:
-- 
2.11.0


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

* [PATCH v2] Btrfs: do not overwrite scrub error with fault error in scrub ioctl
  2018-12-14 19:44 [PATCH] Btrfs: do not overwrite scrub error with fault error in scrub ioctl fdmanana
@ 2018-12-14 19:50 ` fdmanana
  2019-01-02 17:56   ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: fdmanana @ 2018-12-14 19:50 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

If scrub returned an error and then the copy_to_user() call did not
succeed, we would overwrite the error returned by scrub with -EFAULT.
Fix that by removing the call to copy_to_user() as there is no need
to do it at all.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---

V2: Leave to copy_to_user() call since progress needs to be reported back
    to user space.

 fs/btrfs/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 3a27efa2b955..4c05d9c4fe3d 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -4301,7 +4301,7 @@ static long btrfs_ioctl_scrub(struct file *file, void __user *arg)
 			      &sa->progress, sa->flags & BTRFS_SCRUB_READONLY,
 			      0);
 
-	if (copy_to_user(arg, sa, sizeof(*sa)))
+	if (ret == 0 && copy_to_user(arg, sa, sizeof(*sa)))
 		ret = -EFAULT;
 
 	if (!(sa->flags & BTRFS_SCRUB_READONLY))
-- 
2.11.0


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

* Re: [PATCH v2] Btrfs: do not overwrite scrub error with fault error in scrub ioctl
  2018-12-14 19:50 ` [PATCH v2] " fdmanana
@ 2019-01-02 17:56   ` David Sterba
  0 siblings, 0 replies; 3+ messages in thread
From: David Sterba @ 2019-01-02 17:56 UTC (permalink / raw)
  To: fdmanana; +Cc: linux-btrfs

On Fri, Dec 14, 2018 at 07:50:17PM +0000, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> If scrub returned an error and then the copy_to_user() call did not
> succeed, we would overwrite the error returned by scrub with -EFAULT.
> Fix that by removing the call to copy_to_user() as there is no need
> to do it at all.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
> ---
> 
> V2: Leave to copy_to_user() call since progress needs to be reported back
>     to user space.

The changelog does not reflect v2, I'll update the last sentence to

"Fix that by calling copy_to_user() only if btrfs_scrub_dev returned
success."

Thanks.

Reviewed-by: David Sterba <dsterba@suse.com>

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

end of thread, other threads:[~2019-01-02 17:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-14 19:44 [PATCH] Btrfs: do not overwrite scrub error with fault error in scrub ioctl fdmanana
2018-12-14 19:50 ` [PATCH v2] " fdmanana
2019-01-02 17:56   ` David Sterba

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).