All of lore.kernel.org
 help / color / mirror / Atom feed
From: Changwei Ge <gechangwei@live.cn>
To: Andrew Morton <akpm@linux-foundation.org>,
	"ocfs2-devel@oss.oracle.com" <ocfs2-devel@oss.oracle.com>,
	"junxiao.bi@oracle.com" <junxiao.bi@oracle.com>,
	"jiangqi903@gmail.com" <jiangqi903@gmail.com>
Cc: Changwei Ge <ge.changwei@h3c.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: [PATCH RESEND] ocfs2: fix a misuse a of brelse after failing ocfs2_check_dir_entry
Date: Mon, 28 May 2018 14:40:11 +0000	[thread overview]
Message-ID: <HK2PR06MB045211675B43EED794E597B6D56E0@HK2PR06MB0452.apcprd06.prod.outlook.com> (raw)

From: Changwei Ge <ge.changwei@h3c.com>

Somehow, file system metadata was corrupted, which causes
ocfs2_check_dir_entry() to fail in function ocfs2_dir_foreach_blk_el().

According to the original design intention, if above happens we should
skip the problematic block and continue to retrieve dir entry. But there
is obviouse misuse of brelse around related code.

After failure of ocfs2_check_dir_entry(), currunt code just moves to next
position and uses the problematic buffer head again and again during
which the problematic buffer head is released for multiple times. I
suppose, this a serious issue which is long-lived in ocfs2. This may
cause other file systems which is also used in a the same host insane.

So we should also consider about bakcporting this patch into
linux -stable.

Suggested-by: Changkuo Shi <shi.changkuo@h3c.com>
Cc: stable@vger.kernel.org
Signed-off-by: Changwei Ge <ge.changwei@h3c.com>
---
 fs/ocfs2/dir.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index b048d4f..c121abb 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -1897,8 +1897,7 @@ static int ocfs2_dir_foreach_blk_el(struct inode *inode,
 				/* On error, skip the f_pos to the
 				   next block. */
 				ctx->pos = (ctx->pos | (sb->s_blocksize - 1)) + 1;
-				brelse(bh);
-				continue;
+				break;
 			}
 			if (le64_to_cpu(de->inode)) {
 				unsigned char d_type = DT_UNKNOWN;
-- 
2.7.4

WARNING: multiple messages have this Message-ID (diff)
From: Changwei Ge <gechangwei@live.cn>
To: Andrew Morton <akpm@linux-foundation.org>,
	"ocfs2-devel@oss.oracle.com" <ocfs2-devel@oss.oracle.com>,
	"junxiao.bi@oracle.com" <junxiao.bi@oracle.com>,
	"jiangqi903@gmail.com" <jiangqi903@gmail.com>
Cc: Changwei Ge <ge.changwei@h3c.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: [Ocfs2-devel] [PATCH RESEND] ocfs2: fix a misuse a of brelse after failing ocfs2_check_dir_entry
Date: Mon, 28 May 2018 14:40:11 +0000	[thread overview]
Message-ID: <HK2PR06MB045211675B43EED794E597B6D56E0@HK2PR06MB0452.apcprd06.prod.outlook.com> (raw)

From: Changwei Ge <ge.changwei@h3c.com>

Somehow, file system metadata was corrupted, which causes
ocfs2_check_dir_entry() to fail in function ocfs2_dir_foreach_blk_el().

According to the original design intention, if above happens we should
skip the problematic block and continue to retrieve dir entry. But there
is obviouse misuse of brelse around related code.

After failure of ocfs2_check_dir_entry(), currunt code just moves to next
position and uses the problematic buffer head again and again during
which the problematic buffer head is released for multiple times. I
suppose, this a serious issue which is long-lived in ocfs2. This may
cause other file systems which is also used in a the same host insane.

So we should also consider about bakcporting this patch into
linux -stable.

Suggested-by: Changkuo Shi <shi.changkuo@h3c.com>
Cc: stable at vger.kernel.org
Signed-off-by: Changwei Ge <ge.changwei@h3c.com>
---
 fs/ocfs2/dir.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index b048d4f..c121abb 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -1897,8 +1897,7 @@ static int ocfs2_dir_foreach_blk_el(struct inode *inode,
 				/* On error, skip the f_pos to the
 				   next block. */
 				ctx->pos = (ctx->pos | (sb->s_blocksize - 1)) + 1;
-				brelse(bh);
-				continue;
+				break;
 			}
 			if (le64_to_cpu(de->inode)) {
 				unsigned char d_type = DT_UNKNOWN;
-- 
2.7.4

             reply	other threads:[~2018-05-28 14:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-28 14:40 Changwei Ge [this message]
2018-05-28 14:40 ` [Ocfs2-devel] [PATCH RESEND] ocfs2: fix a misuse a of brelse after failing ocfs2_check_dir_entry Changwei Ge
2018-11-10  6:33 ` piaojun
2018-11-10  6:33   ` piaojun
2018-11-10  7:58   ` Changwei Ge
2018-11-10  7:58     ` Changwei Ge
2018-11-10  8:04     ` piaojun
2018-11-10  8:04       ` piaojun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=HK2PR06MB045211675B43EED794E597B6D56E0@HK2PR06MB0452.apcprd06.prod.outlook.com \
    --to=gechangwei@live.cn \
    --cc=akpm@linux-foundation.org \
    --cc=ge.changwei@h3c.com \
    --cc=jiangqi903@gmail.com \
    --cc=junxiao.bi@oracle.com \
    --cc=ocfs2-devel@oss.oracle.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.