linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: validate inode in mapping_set_error
@ 2020-10-10  0:06 Minchan Kim
  2020-10-10 11:58 ` Jeff Layton
  0 siblings, 1 reply; 2+ messages in thread
From: Minchan Kim @ 2020-10-10  0:06 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jeff Layton, Jan Kara, linux-mm, LKML, Minchan Kim

The swap address_space doesn't have host. Thus, it makes kernel crash once
swap write meets error. Fix it.

[1] 735e4ae5ba28, vfs: track per-sb writeback errors and report them to syncfs
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
 include/linux/pagemap.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 17ba0fe59290..9cf540447e73 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -55,7 +55,8 @@ static inline void mapping_set_error(struct address_space *mapping, int error)
 	__filemap_set_wb_err(mapping, error);
 
 	/* Record it in superblock */
-	errseq_set(&mapping->host->i_sb->s_wb_err, error);
+	if (mapping->host)
+		errseq_set(&mapping->host->i_sb->s_wb_err, error);
 
 	/* Record it in flags for now, for legacy callers */
 	if (error == -ENOSPC)
-- 
2.28.0.1011.ga647a8990f-goog



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

* Re: [PATCH] mm: validate inode in mapping_set_error
  2020-10-10  0:06 [PATCH] mm: validate inode in mapping_set_error Minchan Kim
@ 2020-10-10 11:58 ` Jeff Layton
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Layton @ 2020-10-10 11:58 UTC (permalink / raw)
  To: Minchan Kim, Andrew Morton; +Cc: Jan Kara, linux-mm, LKML

On Fri, 2020-10-09 at 17:06 -0700, Minchan Kim wrote:
> The swap address_space doesn't have host. Thus, it makes kernel crash once
> swap write meets error. Fix it.
> 
> [1] 735e4ae5ba28, vfs: track per-sb writeback errors and report them to syncfs
> Signed-off-by: Minchan Kim <minchan@kernel.org>
> ---
>  include/linux/pagemap.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> index 17ba0fe59290..9cf540447e73 100644
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -55,7 +55,8 @@ static inline void mapping_set_error(struct address_space *mapping, int error)
>  	__filemap_set_wb_err(mapping, error);
>  
>  	/* Record it in superblock */
> -	errseq_set(&mapping->host->i_sb->s_wb_err, error);
> +	if (mapping->host)
> +		errseq_set(&mapping->host->i_sb->s_wb_err, error);
>  
>  	/* Record it in flags for now, for legacy callers */
>  	if (error == -ENOSPC)

Good catch.

Acked-by: Jeff Layton <jlayton@kernel.org>



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

end of thread, other threads:[~2020-10-10 11:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-10  0:06 [PATCH] mm: validate inode in mapping_set_error Minchan Kim
2020-10-10 11:58 ` Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox