linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH v3] f2fs: avoid out-of-range memory access
@ 2019-07-03 15:33 Ocean Chen via Linux-f2fs-devel
  2019-07-04  7:22 ` Chao Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Ocean Chen via Linux-f2fs-devel @ 2019-07-03 15:33 UTC (permalink / raw)
  To: jaegeuk, yuchao0, linux-f2fs-devel, linux-kernel; +Cc: oceanchen

blk_off might over 512 due to fs corrupt and should
be checked before being used.
Use ENTRIES_IN_SUM to protect invalid memory access.

--
v2:
- fix typo
v3:
- check blk_off before being used
--
Signed-off-by: Ocean Chen <oceanchen@google.com>
---
 fs/f2fs/segment.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 8dee063c833f..c3eae3239345 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -3401,6 +3401,9 @@ static int read_compacted_summaries(struct f2fs_sb_info *sbi)
 		if (seg_i->alloc_type == SSR)
 			blk_off = sbi->blocks_per_seg;
 
+                if (blk_off >= ENTRIES_IN_SUM)
+                  return -EFAULT;
+
 		for (j = 0; j < blk_off; j++) {
 			struct f2fs_summary *s;
 			s = (struct f2fs_summary *)(kaddr + offset);
-- 
2.22.0.410.gd8fdbe21b5-goog



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH v3] f2fs: avoid out-of-range memory access
  2019-07-03 15:33 [f2fs-dev] [PATCH v3] f2fs: avoid out-of-range memory access Ocean Chen via Linux-f2fs-devel
@ 2019-07-04  7:22 ` Chao Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2019-07-04  7:22 UTC (permalink / raw)
  To: Ocean Chen, jaegeuk, linux-f2fs-devel, linux-kernel

On 2019/7/3 23:33, Ocean Chen wrote:
> blk_off might over 512 due to fs corrupt and should
> be checked before being used.
> Use ENTRIES_IN_SUM to protect invalid memory access.
> 
> --
> v2:
> - fix typo
> v3:
> - check blk_off before being used
> --
> Signed-off-by: Ocean Chen <oceanchen@google.com>
> ---
>  fs/f2fs/segment.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 8dee063c833f..c3eae3239345 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -3401,6 +3401,9 @@ static int read_compacted_summaries(struct f2fs_sb_info *sbi)
>  		if (seg_i->alloc_type == SSR)
>  			blk_off = sbi->blocks_per_seg;
>  
> +                if (blk_off >= ENTRIES_IN_SUM)
> +                  return -EFAULT;

- scripts/checkpatch.pl will complain such format.
- miss to call f2fs_put_page(page, 1) before return.

Thanks,

> +
>  		for (j = 0; j < blk_off; j++) {
>  			struct f2fs_summary *s;
>  			s = (struct f2fs_summary *)(kaddr + offset);
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2019-07-04  7:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-03 15:33 [f2fs-dev] [PATCH v3] f2fs: avoid out-of-range memory access Ocean Chen via Linux-f2fs-devel
2019-07-04  7:22 ` Chao Yu

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