Commit 497e8d72 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Luo Gengkun
Browse files

ocfs2: handle a symlink read error correctly

stable inclusion
from stable-v6.6.78
commit b6833b38984d1e9f20dd80f9ec9050c10d687f30
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBPC8H
CVE: CVE-2024-58001

Reference: https://git.kernel.org/stable/c/b6833b38984d1e9f20dd80f9ec9050c10d687f30

--------------------------------

commit 2b4c2094da6d84e69b843dd3317902e977bf64bd upstream.

Patch series "Convert ocfs2 to use folios".

Mark did a conversion of ocfs2 to use folios and sent it to me as a
giant patch for review ;-)

So I've redone it as individual patches, and credited Mark for the patches
where his code is substantially the same.  It's not a bad way to do it;
his patch had some bugs and my patches had some bugs.  Hopefully all our
bugs were different from each other.  And hopefully Mark likes all the
changes I made to his code!

This patch (of 23):

If we can't read the buffer, be sure to unlock the page before returning.

Link: https://lkml.kernel.org/r/20241205171653.3179945-1-willy@infradead.org
Link: https://lkml.kernel.org/r/20241205171653.3179945-2-willy@infradead.org


Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Jun Piao <piaojun@huawei.com>
Cc: Mark Tinguely <mark.tinguely@oracle.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarLuo Gengkun <luogengkun2@huawei.com>
parent 3a20dc05
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ static int ocfs2_fast_symlink_read_folio(struct file *f, struct folio *folio)

	if (status < 0) {
		mlog_errno(status);
		return status;
		goto out;
	}

	fe = (struct ocfs2_dinode *) bh->b_data;
@@ -76,9 +76,10 @@ static int ocfs2_fast_symlink_read_folio(struct file *f, struct folio *folio)
	memcpy(kaddr, link, len + 1);
	kunmap_atomic(kaddr);
	SetPageUptodate(page);
out:
	unlock_page(page);
	brelse(bh);
	return 0;
	return status;
}

const struct address_space_operations ocfs2_fast_symlink_aops = {