linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [bug report] f2fs: fix to avoid reading out encrypted data in page cache
@ 2016-07-12 13:29 Dan Carpenter
  2016-07-12 15:15 ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2016-07-12 13:29 UTC (permalink / raw)
  To: yuchao0; +Cc: linux-f2fs-devel

Hello Chao Yu,

The patch 78682f794479: "f2fs: fix to avoid reading out encrypted
data in page cache" from Jul 3, 2016, leads to the following static
checker warning:

	fs/f2fs/data.c:1123 f2fs_mpage_readpages()
	error: 'bio' dereferencing possible ERR_PTR()

fs/f2fs/data.c
  1093                  }
  1094                  if (bio == NULL) {
  1095                          bio = f2fs_grab_bio(inode, block_nr, nr_pages);
  1096                          if (IS_ERR(bio))
                                    ^^^^^^^^^^
It's an error pointer.

  1097                                  goto set_error_page;
  1098                          bio_set_op_attrs(bio, REQ_OP_READ, 0);
  1099                  }
  1100  
  1101                  if (bio_add_page(bio, page, blocksize, 0) < blocksize)
  1102                          goto submit_and_realloc;
  1103  
  1104                  last_block_in_bio = block_nr;
  1105                  goto next_page;
  1106  set_error_page:
  1107                  SetPageError(page);
  1108                  zero_user_segment(page, 0, PAGE_SIZE);
  1109                  unlock_page(page);
  1110                  goto next_page;
  1111  confused:
  1112                  if (bio) {
  1113                          __submit_bio(F2FS_I_SB(inode), bio, DATA);
  1114                          bio = NULL;
  1115                  }
  1116                  unlock_page(page);
  1117  next_page:
  1118                  if (pages)
  1119                          put_page(page);
  1120          }
  1121          BUG_ON(pages && !list_empty(pages));
  1122          if (bio)
  1123                  __submit_bio(F2FS_I_SB(inode), bio, DATA);
                                                       ^^^
Dereferenced.

  1124          return 0;

regards,
dan carpenter

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev

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

* Re: [bug report] f2fs: fix to avoid reading out encrypted data in page cache
  2016-07-12 13:29 [bug report] f2fs: fix to avoid reading out encrypted data in page cache Dan Carpenter
@ 2016-07-12 15:15 ` Chao Yu
  2016-07-12 16:44   ` Jaegeuk Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2016-07-12 15:15 UTC (permalink / raw)
  To: Dan Carpenter, yuchao0; +Cc: linux-f2fs-devel

Hi Dan,

Thanks for your report, please check v2.

Thanks,

On 2016/7/12 21:29, Dan Carpenter wrote:
> Hello Chao Yu,
> 
> The patch 78682f794479: "f2fs: fix to avoid reading out encrypted
> data in page cache" from Jul 3, 2016, leads to the following static
> checker warning:
> 
> 	fs/f2fs/data.c:1123 f2fs_mpage_readpages()
> 	error: 'bio' dereferencing possible ERR_PTR()
> 
> fs/f2fs/data.c
>   1093                  }
>   1094                  if (bio == NULL) {
>   1095                          bio = f2fs_grab_bio(inode, block_nr, nr_pages);
>   1096                          if (IS_ERR(bio))
>                                     ^^^^^^^^^^
> It's an error pointer.
> 
>   1097                                  goto set_error_page;
>   1098                          bio_set_op_attrs(bio, REQ_OP_READ, 0);
>   1099                  }
>   1100  
>   1101                  if (bio_add_page(bio, page, blocksize, 0) < blocksize)
>   1102                          goto submit_and_realloc;
>   1103  
>   1104                  last_block_in_bio = block_nr;
>   1105                  goto next_page;
>   1106  set_error_page:
>   1107                  SetPageError(page);
>   1108                  zero_user_segment(page, 0, PAGE_SIZE);
>   1109                  unlock_page(page);
>   1110                  goto next_page;
>   1111  confused:
>   1112                  if (bio) {
>   1113                          __submit_bio(F2FS_I_SB(inode), bio, DATA);
>   1114                          bio = NULL;
>   1115                  }
>   1116                  unlock_page(page);
>   1117  next_page:
>   1118                  if (pages)
>   1119                          put_page(page);
>   1120          }
>   1121          BUG_ON(pages && !list_empty(pages));
>   1122          if (bio)
>   1123                  __submit_bio(F2FS_I_SB(inode), bio, DATA);
>                                                        ^^^
> Dereferenced.
> 
>   1124          return 0;
> 
> regards,
> dan carpenter
> 
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are 
> consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
> J-Flow, sFlow and other flows. Make informed decisions using capacity planning
> reports.http://sdm.link/zohodev2dev
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> 

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev

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

* Re: [bug report] f2fs: fix to avoid reading out encrypted data in page cache
  2016-07-12 15:15 ` Chao Yu
@ 2016-07-12 16:44   ` Jaegeuk Kim
  0 siblings, 0 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2016-07-12 16:44 UTC (permalink / raw)
  To: Chao Yu; +Cc: Dan Carpenter, linux-f2fs-devel

Hello,

It seems we can write just one patch to resolve this.
Thoughts?

>From f2bd632963409ff969aa2567a38f42f4b493a4b4 Mon Sep 17 00:00:00 2001
From: Jaegeuk Kim <jaegeuk@kernel.org>
Date: Tue, 12 Jul 2016 09:38:48 -0700
Subject: [PATCH] f2fs: fix ERR_PTR returned by bio

This is to fix wrong error pointer handling flow reported by Dan.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/data.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 9017366..991ce21 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1137,8 +1137,10 @@ submit_and_realloc:
 		}
 		if (bio == NULL) {
 			bio = f2fs_grab_bio(inode, block_nr, nr_pages);
-			if (IS_ERR(bio))
+			if (IS_ERR(bio)) {
+				bio = NULL;
 				goto set_error_page;
+			}
 		}
 
 		if (bio_add_page(bio, page, blocksize, 0) < blocksize)
-- 
2.8.3


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev

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

end of thread, other threads:[~2016-07-12 16:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-12 13:29 [bug report] f2fs: fix to avoid reading out encrypted data in page cache Dan Carpenter
2016-07-12 15:15 ` Chao Yu
2016-07-12 16:44   ` Jaegeuk Kim

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