From: Al Viro <viro@ZenIV.linux.org.uk>
To: Arun KS <arunks.linux@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Matthew Wilcox <matthew@wil.cx>,
Bruce Fields <bfields@fieldses.org>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
vinayak menon <vinayakm.list@gmail.com>,
Nagachandra P <nagachandra@gmail.com>,
Vikram MP <mp.vikram@gmail.com>
Subject: Re: [PATCH v1] seq_file: Fix overflow condition in seq_commit
Date: Tue, 20 Aug 2013 08:36:22 +0100 [thread overview]
Message-ID: <20130820073622.GK27005@ZenIV.linux.org.uk> (raw)
In-Reply-To: <CAKZGPAN3W_FFHcxnatFJNQ9VDt-TL9c2Wyddqvdz98612U4gzQ@mail.gmail.com>
On Tue, Aug 20, 2013 at 12:51:56PM +0530, Arun KS wrote:
> d_path expects the pathname to be less than 64 bytes. If its more than
> 64, it returns -ENAMETOOLONG.
?!?!? d_path() does not expect anything of that sort - it can very
well produce names much longer, without ENAMETOOLONG.
> char *dynamic_dname(struct dentry *dentry, char *buffer, int buflen,
> const char *fmt, ...)
> {
> va_list args;
> char temp[64];
> int sz;
>
> va_start(args, fmt);
> sz = vsnprintf(temp, sizeof(temp), fmt, args) + 1;
> va_end(args);
>
> if (sz > sizeof(temp) || sz > buflen)
> return ERR_PTR(-ENAMETOOLONG);
>
> buffer += buflen - sz;
> return memcpy(buffer, temp, sz);
> }
Aha. _That_ is a bug, all right - dynamic_dname() is simply not suitable
for that kind of uses. ashmem.c is certainly abusing shmem_file_setup();
feeding that kind of mess as dentry name is a Bad Idea(tm). Anyway,
I'd suggest this for a fix:
va_list args;
size_t sz;
va_start(args, fmt);
sz = vsnprintf(NULL, 0, fmt, args) + 1;
va_end(args);
if (sz > buflen)
return ERR_PTR(-ENAMETOOLONG);
va_start(args, fmt);
buffer += buflen - sz;
vsprintf(buffer, fmt, args);
va_end(args);
return buffer;
Either right in dynamic_dname(), or as possibly_fucking_long_dname(),
to be used by shmem.c...
next prev parent reply other threads:[~2013-08-20 7:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-20 5:25 [PATCH v1] seq_file: Fix overflow condition in seq_commit Arun KS
2013-08-20 5:51 ` Al Viro
2013-08-20 7:21 ` Arun KS
2013-08-20 7:36 ` Al Viro [this message]
2013-08-20 8:03 ` Arun KS
2013-08-20 14:04 ` Al Viro
2013-08-21 6:01 ` Arun KS
2013-10-14 22:57 ` Colin Cross
2013-10-15 18:33 ` Greg KH
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=20130820073622.GK27005@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=akpm@linux-foundation.org \
--cc=arunks.linux@gmail.com \
--cc=bfields@fieldses.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=mp.vikram@gmail.com \
--cc=nagachandra@gmail.com \
--cc=vinayakm.list@gmail.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