Reiserfs development archive or lore.kernel.org
 help / color / mirror / Atom feed
From: Bragatheswaran Manickavel <bragathemanick0908@gmail.com>
To: reiserfs-devel@vger.kernel.org
Cc: Bragatheswaran Manickavel <bragathemanick0908@gmail.com>,
	linux-kernel@vger.kernel.org,
	syzbot+e5bb9eb00a5a5ed2a9a2@syzkaller.appspotmail.com
Subject: [PATCH] reiserfs: UBSAN: array-index-out-of-bounds in direntry_create_vi
Date: Thu, 26 Oct 2023 18:26:16 +0530	[thread overview]
Message-ID: <20231026125616.1859-1-bragathemanick0908@gmail.com> (raw)

deh defined as an array of type __u16[], and issue is
triggered when it's trying to access an element at
index 1, which is out of bounds because the array
has only one element at index 0.

Reported-by: syzbot+e5bb9eb00a5a5ed2a9a2@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e5bb9eb00a5a5ed2a9a2
Signed-off-by: Bragatheswaran Manickavel <bragathemanick0908@gmail.com>
---
 fs/reiserfs/item_ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c
index 3a5a752d96c7..ccf547c5e8e1 100644
--- a/fs/reiserfs/item_ops.c
+++ b/fs/reiserfs/item_ops.c
@@ -484,7 +484,7 @@ static int direntry_create_vi(struct virtual_node *vn,
 				  vn->vn_mode);
 		dir_u->entry_sizes[i] =
 		    (j ? deh_location(&deh[j - 1]) : ih_item_len(vi->vi_ih)) -
-		    deh_location(&deh[j]) + DEH_SIZE;
+		    deh_location(&deh[j - 1]) + DEH_SIZE;
 	}
 
 	size += (dir_u->entry_count * sizeof(short));
-- 
2.34.1


             reply	other threads:[~2023-10-26 12:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-26 12:56 Bragatheswaran Manickavel [this message]
2023-11-04 12:58 ` [PATCH] reiserfs: UBSAN: array-index-out-of-bounds in direntry_create_vi Bragatheswaran Manickavel

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=20231026125616.1859-1-bragathemanick0908@gmail.com \
    --to=bragathemanick0908@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=reiserfs-devel@vger.kernel.org \
    --cc=syzbot+e5bb9eb00a5a5ed2a9a2@syzkaller.appspotmail.com \
    /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 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 read-only IMAP folder(s) and NNTP newsgroup(s).