All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: don't ignore return values from ext4_ext_dirty()
@ 2020-04-21  2:39 Harshad Shirwadkar
  2020-04-21  2:39 ` [PATCH] ext4: fix EXT_MAX_EXTENT/INDEX to check for zeroed eh_max Harshad Shirwadkar
  2020-04-21  3:02 ` [PATCH] ext4: don't ignore return values from ext4_ext_dirty() harshad shirwadkar
  0 siblings, 2 replies; 4+ messages in thread
From: Harshad Shirwadkar @ 2020-04-21  2:39 UTC (permalink / raw)
  To: linux-ext4; +Cc: Harshad Shirwadkar

Don't ignore return values from ext4_ext_dirty, since the errors
indicate valid failures below Ext4.  In all of the other instances of
ext4_ext_dirty calls, the error return value is handled in some
way. This patch makes those remaining couple of places to handle
ext4_ext_dirty errors as well. In the longer run, we probably should
make sure that errors from other mark_dirty routines are handled as
well.

Ran gce-xfstests smoke tests and verified that there were no
regressions.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
---
 fs/ext4/extents.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index f2b577b315a0..f62f55a16fe3 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3244,8 +3244,7 @@ static int ext4_split_extent_at(handle_t *handle,
 
 fix_extent_len:
 	ex->ee_len = orig_ex.ee_len;
-	ext4_ext_dirty(handle, inode, path + path->p_depth);
-	return err;
+	return ext4_ext_dirty(handle, inode, path + path->p_depth);
 }
 
 /*
@@ -3503,7 +3502,7 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
 	}
 	if (allocated) {
 		/* Mark the block containing both extents as dirty */
-		ext4_ext_dirty(handle, inode, path + depth);
+		err = ext4_ext_dirty(handle, inode, path + depth);
 
 		/* Update path to point to the right extent */
 		path[depth].p_ext = abut_ex;
-- 
2.26.1.301.g55bc3eb7cb9-goog


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

* [PATCH] ext4: fix EXT_MAX_EXTENT/INDEX to check for zeroed eh_max
  2020-04-21  2:39 [PATCH] ext4: don't ignore return values from ext4_ext_dirty() Harshad Shirwadkar
@ 2020-04-21  2:39 ` Harshad Shirwadkar
  2020-05-14 14:49   ` Theodore Y. Ts'o
  2020-04-21  3:02 ` [PATCH] ext4: don't ignore return values from ext4_ext_dirty() harshad shirwadkar
  1 sibling, 1 reply; 4+ messages in thread
From: Harshad Shirwadkar @ 2020-04-21  2:39 UTC (permalink / raw)
  To: linux-ext4; +Cc: Harshad Shirwadkar

If eh->eh_max is 0, EXT_MAX_EXTENT/INDEX would evaluate to unsigned
(-1) resulting in illegal memory accesses. Although there is no
consistent repro, we see that generic/019 sometimes crashes because of
this bug.

Ran gce-xfstests smoke and verified that there were no regressions.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
---
 fs/ext4/ext4_extents.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/ext4_extents.h b/fs/ext4/ext4_extents.h
index 1c216fcc202a..44e59881a1f0 100644
--- a/fs/ext4/ext4_extents.h
+++ b/fs/ext4/ext4_extents.h
@@ -170,10 +170,13 @@ struct partial_cluster {
 	(EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_entries) - 1)
 #define EXT_LAST_INDEX(__hdr__) \
 	(EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_entries) - 1)
-#define EXT_MAX_EXTENT(__hdr__) \
-	(EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)
+#define EXT_MAX_EXTENT(__hdr__)	\
+	((le16_to_cpu((__hdr__)->eh_max)) ? \
+	((EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)) \
+					: 0)
 #define EXT_MAX_INDEX(__hdr__) \
-	(EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)
+	((le16_to_cpu((__hdr__)->eh_max)) ? \
+	((EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)) : 0)
 
 static inline struct ext4_extent_header *ext_inode_hdr(struct inode *inode)
 {
-- 
2.26.1.301.g55bc3eb7cb9-goog


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

* Re: [PATCH] ext4: don't ignore return values from ext4_ext_dirty()
  2020-04-21  2:39 [PATCH] ext4: don't ignore return values from ext4_ext_dirty() Harshad Shirwadkar
  2020-04-21  2:39 ` [PATCH] ext4: fix EXT_MAX_EXTENT/INDEX to check for zeroed eh_max Harshad Shirwadkar
@ 2020-04-21  3:02 ` harshad shirwadkar
  1 sibling, 0 replies; 4+ messages in thread
From: harshad shirwadkar @ 2020-04-21  3:02 UTC (permalink / raw)
  To: Ext4 Developers List

On Mon, Apr 20, 2020 at 7:40 PM Harshad Shirwadkar
<harshadshirwadkar@gmail.com> wrote:
>
> Don't ignore return values from ext4_ext_dirty, since the errors
> indicate valid failures below Ext4.  In all of the other instances of
> ext4_ext_dirty calls, the error return value is handled in some
> way. This patch makes those remaining couple of places to handle
> ext4_ext_dirty errors as well. In the longer run, we probably should
> make sure that errors from other mark_dirty routines are handled as
> well.
>
> Ran gce-xfstests smoke tests and verified that there were no
> regressions.
>
> Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
> ---
>  fs/ext4/extents.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index f2b577b315a0..f62f55a16fe3 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -3244,8 +3244,7 @@ static int ext4_split_extent_at(handle_t *handle,
>
>  fix_extent_len:
>         ex->ee_len = orig_ex.ee_len;
> -       ext4_ext_dirty(handle, inode, path + path->p_depth);
> -       return err;
> +       return ext4_ext_dirty(handle, inode, path + path->p_depth);
>  }

I realized that this is not correct. That's because fix_extent_len is
an error path and this change would make ext4_split_extent_at() return
success if ext4_ext_dirty succeeds in this path. I think instead I
should be adding a comment here explaining why we are not handling
ext4_ext_dirty(). Sorry for that.

- Harshad

>
>  /*
> @@ -3503,7 +3502,7 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
>         }
>         if (allocated) {
>                 /* Mark the block containing both extents as dirty */
> -               ext4_ext_dirty(handle, inode, path + depth);
> +               err = ext4_ext_dirty(handle, inode, path + depth);
>
>                 /* Update path to point to the right extent */
>                 path[depth].p_ext = abut_ex;
> --
> 2.26.1.301.g55bc3eb7cb9-goog
>

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

* Re: [PATCH] ext4: fix EXT_MAX_EXTENT/INDEX to check for zeroed eh_max
  2020-04-21  2:39 ` [PATCH] ext4: fix EXT_MAX_EXTENT/INDEX to check for zeroed eh_max Harshad Shirwadkar
@ 2020-05-14 14:49   ` Theodore Y. Ts'o
  0 siblings, 0 replies; 4+ messages in thread
From: Theodore Y. Ts'o @ 2020-05-14 14:49 UTC (permalink / raw)
  To: Harshad Shirwadkar; +Cc: linux-ext4

On Mon, Apr 20, 2020 at 07:39:59PM -0700, Harshad Shirwadkar wrote:
> If eh->eh_max is 0, EXT_MAX_EXTENT/INDEX would evaluate to unsigned
> (-1) resulting in illegal memory accesses. Although there is no
> consistent repro, we see that generic/019 sometimes crashes because of
> this bug.
> 
> Ran gce-xfstests smoke and verified that there were no regressions.
> 
> Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>

Applied, thanks.

					- Ted

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-21  2:39 [PATCH] ext4: don't ignore return values from ext4_ext_dirty() Harshad Shirwadkar
2020-04-21  2:39 ` [PATCH] ext4: fix EXT_MAX_EXTENT/INDEX to check for zeroed eh_max Harshad Shirwadkar
2020-05-14 14:49   ` Theodore Y. Ts'o
2020-04-21  3:02 ` [PATCH] ext4: don't ignore return values from ext4_ext_dirty() harshad shirwadkar

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.