All of lore.kernel.org
 help / color / mirror / Atom feed
From: Su Yue <suy.fnst@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Cc: <dsterba@suse.cz>
Subject: [PATCH v2 5/9] btrfs: Check namelen in 'btrfs_check_ref_name_override'
Date: Thu, 1 Jun 2017 16:57:12 +0800	[thread overview]
Message-ID: <20170601085716.25898-6-suy.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <20170601085716.25898-1-suy.fnst@cn.fujitsu.com>

Call 'btrfs_is_namelen_valid' before reading name.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
 fs/btrfs/tree-log.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index ae51144571e2..fdab0f021197 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -4562,6 +4562,11 @@ static int btrfs_check_ref_name_override(struct extent_buffer *eb,
 			this_len = sizeof(*extref) + this_name_len;
 		}
 
+		ret = btrfs_is_namelen_valid(eb, slot, name_ptr, this_name_len);
+		if (!ret) {
+			ret = -EIO;
+			goto out;
+		}
 		if (this_name_len > name_len) {
 			char *new_name;
 
-- 
2.13.0




  parent reply	other threads:[~2017-06-01  8:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-01  8:57 [PATCH v2 0/9] btrfs: check namelen before read name Su Yue
2017-06-01  8:57 ` [PATCH v2 1/9] btrfs: Introduce btrfs_is_namelen_valid to avoid reading beyond boundary Su Yue
2017-06-01  9:44   ` Nikolay Borisov
2017-06-02  3:55     ` Su Yue
2017-06-01  8:57 ` [PATCH v2 2/9] btrfs: Check namelen with boundary in verify dir_item Su Yue
2017-06-01  8:57 ` [PATCH v2 3/9] btrfs: Check name len on add_inode_ref call path Su Yue
2017-06-01  9:53   ` Nikolay Borisov
2017-06-01 17:18     ` David Sterba
2017-06-01  8:57 ` [PATCH v2 4/9] btrfs: Verify dir_item in 'replay_xattr_deletes' Su Yue
2017-06-01  8:57 ` Su Yue [this message]
2017-06-01  8:57 ` [PATCH v2 6/9] btrfs: Check name before read in 'iterate_dir_item' Su Yue
2017-06-01  9:58   ` Nikolay Borisov
2017-06-02 17:07     ` David Sterba
2017-06-01  8:57 ` [PATCH v2 7/9] btrfs: Check namelen before read in 'btrfs_get_name' Su Yue
2017-06-01  8:57 ` [PATCH v2 8/9] btrfs: Check namelen before in 'btrfs_del_root_ref' Su Yue
2017-06-05 15:12   ` David Sterba
2017-06-01  8:57 ` [PATCH v2 9/9] btrfs: Verify dir_item 'in iterate_object_props' Su Yue
2017-06-02 17:34 ` [PATCH v2 0/9] btrfs: check namelen before read name David Sterba
2017-06-02 18:01   ` David Sterba

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=20170601085716.25898-6-suy.fnst@cn.fujitsu.com \
    --to=suy.fnst@cn.fujitsu.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@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.