linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chandan Rajendra <chandan@linux.vnet.ibm.com>
To: viro@zeniv.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, abdhalee@linux.vnet.ibm.com,
	joe@perches.com
Subject: Re: [PATCH V2] get_fs_type: Validate fs type string argument
Date: Mon, 24 Jul 2017 20:47:20 +0530	[thread overview]
Message-ID: <1842620.RrM76BaaeK@localhost.localdomain> (raw)
In-Reply-To: <20170711140421.31205-1-chandan@linux.vnet.ibm.com>

On Tuesday, July 11, 2017 7:34:21 PM IST Chandan Rajendra wrote:
> On ppc64, When a non-nul terminated string is passed as an argument to
> the mount(2) syscall, copy_mount_string() ends up allocating 64k (the
> PAGE_SIZE on ppc64) worth of space for holding the string in kernel's
> address space.
> 
> Later, in set_precision() (invoked indirectly by get_fs_type()), we end
> up assigning 65535 as the value to 'struct printf_spec'->precision
> member. This field has a width of 16 bits and also it is signed data
> type. Hence an invalid value ends up getting assigned. This causes the
> "WARN_ONCE(spec->precision != prec, "precision %d too large", prec)"
> statement inside set_precision() to be executed.
> 
> This commit fixes the bug by validating the length of the "filesystem
> type" argument passed to get_fs_type() function.
> 
> Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
> Reported-by: Abdul Haleem <abdhalee@linux.vnet.ibm.com>
> Suggested-by: Joe Perches <joe@perches.com>
> ---
> Changelog:
> v1->v2: Fix commit message.
> 
>  fs/filesystems.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/filesystems.c b/fs/filesystems.c
> index a920ad2..8e309d3 100644
> --- a/fs/filesystems.c
> +++ b/fs/filesystems.c
> @@ -275,6 +275,9 @@ struct file_system_type *get_fs_type(const char *name)
>  	const char *dot = strchr(name, '.');
>  	int len = dot ? dot - name : strlen(name);
> 
> +       if (len >= PATH_MAX)
> +               return NULL;
> +
>  	fs = __get_fs_type(name, len);
>  	if (!fs && (request_module("fs-%.*s", len, name) == 0)) {
>  		fs = __get_fs_type(name, len);
> 

Hi Al Viro,

Can you please let me know if you have any review comments about this patch.

-- 
chandan

      reply	other threads:[~2017-07-24 15:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-11 13:47 [PATCH] get_fs_type: Validate fs type string argument Chandan Rajendra
2017-07-11 14:04 ` [PATCH V2] " Chandan Rajendra
2017-07-24 15:17   ` Chandan Rajendra [this message]

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=1842620.RrM76BaaeK@localhost.localdomain \
    --to=chandan@linux.vnet.ibm.com \
    --cc=abdhalee@linux.vnet.ibm.com \
    --cc=joe@perches.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).