From: Matthew Wilcox <willy@infradead.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, Jordy Zomer <jordy@pwning.systems>,
"Ahmed S. Darwish" <a.darwish@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Eric Biggers <ebiggers@google.com>
Subject: Re: [PATCH v2] fs: make d_path-like functions all have unsigned size
Date: Tue, 27 Jul 2021 14:53:27 +0100 [thread overview]
Message-ID: <YQAP1/N5hudsmbu6@casper.infradead.org> (raw)
In-Reply-To: <YQAKj4LFifmlVi0q@kroah.com>
On Tue, Jul 27, 2021 at 03:30:55PM +0200, Greg Kroah-Hartman wrote:
> On Tue, Jul 27, 2021 at 02:14:37PM +0100, Matthew Wilcox wrote:
> > On Tue, Jul 27, 2021 at 02:56:53PM +0200, Greg Kroah-Hartman wrote:
> > > And my mistake from earlier, size_t is the same as unsigned int, not
> > > unsigned long.
> >
> > No.
> >
> > include/linux/types.h:typedef __kernel_size_t size_t;
> >
> > include/uapi/asm-generic/posix_types.h:
> >
> > #ifndef __kernel_size_t
> > #if __BITS_PER_LONG != 64
> > typedef unsigned int __kernel_size_t;
> > #else
> > typedef __kernel_ulong_t __kernel_size_t;
> > #endif
> > #endif
> >
> > size_t is an unsigned long on 64-bit, unless otherwise defined by the
> > arch.
>
> ugh, ok, so there really is a problem, as we have a size_t value being
> passed in as an int, and then it could be treated as a negative value
> for some fun pointer math to copy buffers around.
>
> How is this not causing problems now already? Are we just getting
> lucky?
include/uapi/linux/limits.h:#define PATH_MAX 4096 /* # chars in a path name including nul */
Clearly some places aren't checking that, but _in principle_, you
aren't supposed to be able to create a pathname longer than that.
prev parent reply other threads:[~2021-07-27 13:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-27 12:07 [PATCH v2] fs: make d_path-like functions all have unsigned size Greg Kroah-Hartman
2021-07-27 12:39 ` Andy Shevchenko
2021-07-27 12:56 ` Greg Kroah-Hartman
2021-07-27 13:14 ` Matthew Wilcox
2021-07-27 13:30 ` Greg Kroah-Hartman
2021-07-27 13:53 ` Matthew Wilcox [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=YQAP1/N5hudsmbu6@casper.infradead.org \
--to=willy@infradead.org \
--cc=a.darwish@linutronix.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=ebiggers@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=jordy@pwning.systems \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.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).