Content-Type: multipart/mixed; boundary="===============8985908626043589493==" MIME-Version: 1.0 From: eadavis@sina.com To: kbuild-all@lists.01.org Subject: [PATCH v3] fs/ntfs3: add a boundary check for EA_FULL Date: Mon, 19 Sep 2022 19:19:54 +0800 Message-ID: <20220919111954.283125-1-eadavis@sina.com> In-Reply-To: List-Id: --===============8985908626043589493== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Edward Adam Davis the root cause is: = The remaining space after the offset is less than the space needed to = accommodate the next EA_FULL struct. Link: https://syzkaller.appspot.com/bug?extid=3Dc4d950787fd5553287b7 Reported-by: syzbot+c4d950787fd5553287b7(a)syzkaller.appspotmail.com Suggested-by: Dan Carpenter Signed-off-by: Edward Adam Davis --- Changes in v3: Add Suggested-by: and fix the syntax err. fs/ntfs3/xattr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index 7de8718c68a9..c90cc453390d 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -52,6 +52,7 @@ static inline bool find_ea(const struct EA_FULL *ea_all, = u32 bytes, for (;;) { const struct EA_FULL *ea =3D Add2Ptr(ea_all, *off); u32 next_off =3D *off + unpacked_ea_size(ea); + u32 next_len =3D 0; = if (next_off > bytes) return false; @@ -63,6 +64,13 @@ static inline bool find_ea(const struct EA_FULL *ea_all,= u32 bytes, *off =3D next_off; if (next_off >=3D bytes) return false; + + next_len =3D next_off + 8; + if (next_len >=3D bytes || + ((!ea->size) && + (next_len + ea->name_len + = + le16_to_cpu(ea->elength) >=3D bytes))) + return false; } } = -- = 2.37.2 --===============8985908626043589493==--