linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Milan Broz <mbroz@redhat.com>
To: linux-btrfs@vger.kernel.org
Cc: Milan Broz <mbroz@redhat.com>
Subject: [PATCH] btrfs: Null terminate string in scan device ioctl
Date: Fri,  3 Jun 2011 19:34:07 +0200	[thread overview]
Message-ID: <1307122447-25062-1-git-send-email-mbroz@redhat.com> (raw)

btrfs_scan_one_device() directly uses vol->name
without additional checks so in the case of unterminated
string in ioctl it can access memory outside
of btrfs_ioctl_vol_args struct.

Always terminate name string (as the same as other users
do already).

Signed-off-by: Milan Broz <mbroz@redhat.com>
---
 fs/btrfs/super.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 9b2e7e5..2bb1a99 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1148,6 +1148,8 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
 	if (IS_ERR(vol))
 		return PTR_ERR(vol);
 
+	vol->name[BTRFS_PATH_NAME_MAX] = '\0';
+
 	switch (cmd) {
 	case BTRFS_IOC_SCAN_DEV:
 		ret = btrfs_scan_one_device(vol->name, FMODE_READ,
-- 
1.7.5.3


                 reply	other threads:[~2011-06-03 17:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1307122447-25062-1-git-send-email-mbroz@redhat.com \
    --to=mbroz@redhat.com \
    --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 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 NNTP newsgroup(s).