Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1701526
| From | Stephen Rothwell <sfr@canb.auug.org.au> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 2/2] adfs: use 'unsigned' types for memcpy length |
| Date | 2017-08-01 23:50 +0200 |
| Message-ID | <u9Nd7-UI-3@gated-at.bofh.it> (permalink) |
| References | <u7zHk-3ZT-15@gated-at.bofh.it> <u9E9S-3Rb-37@gated-at.bofh.it> <u9E9S-3Rb-39@gated-at.bofh.it> <u9K5z-7tS-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Hi Arnd,
On Tue, 1 Aug 2017 11:20:26 -0700 Kees Cook <keescook@chromium.org> wrote:
>
> On Tue, Aug 1, 2017 at 5:04 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> > After commit 62d1034f53e3 ("fortify: use WARN instead of BUG for now"), we
> > get a warning in adfs about a possible buffer overflow:
> >
> > In function 'memcpy',
> > inlined from '__adfs_dir_put' at fs/adfs/dir_f.c:318:2,
> > inlined from 'adfs_f_update' at fs/adfs/dir_f.c:403:2:
> > include/linux/string.h:305:4: error: call to '__read_overflow2' declared with attribute error: detected read beyond size of object passed as 2nd parameter
> > __read_overflow2();
> > ^~~~~~~~~~~~~~~~~~
> >
> > The warning is correct in the sense that a negative 'pos' argument
> > to the function would have that result. However, this is not a bug,
> > as we know the position is always positive (in fact, between 5
> > and 2007, inclusive) when the function gets called.
> >
> > Changing the variable to a unsigned type avoids the problem. I decided
> > to use 'unsigned int' for the position in the directory and the block
> > number, as they are both counting things, but use size_t for the
> > offset and length that get passed into memcpy. This shuts up the
> > warning.
> >
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Acked-by: Kees Cook <keescook@chromium.org>
>
> Thanks for the fix! (Added sfr to Cc since he noticed this too.)
Can someone please send me the patch so I can use it if Andrew doesn't
get around to updating mmotd today?
--
Cheers,
Stephen Rothwell
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 1/2] ext4: fix warning about stack corruption Arnd Bergmann <arnd@arndb.de> - 2017-08-01 14:10 +0200
[PATCH 2/2] adfs: use 'unsigned' types for memcpy length Arnd Bergmann <arnd@arndb.de> - 2017-08-01 14:10 +0200
Re: [PATCH 2/2] adfs: use 'unsigned' types for memcpy length Kees Cook <keescook@chromium.org> - 2017-08-01 20:30 +0200
Re: [PATCH 2/2] adfs: use 'unsigned' types for memcpy length Stephen Rothwell <sfr@canb.auug.org.au> - 2017-08-01 23:50 +0200
Re: [PATCH 1/2] ext4: fix warning about stack corruption Kees Cook <keescook@chromium.org> - 2017-08-01 20:30 +0200
Re: [PATCH 1/2] ext4: fix warning about stack corruption Theodore Ts'o <tytso@mit.edu> - 2017-08-06 04:00 +0200
Re: [PATCH 1/2] ext4: fix warning about stack corruption Arnd Bergmann <arnd@arndb.de> - 2017-08-06 22:40 +0200
Re: [PATCH 1/2] ext4: fix warning about stack corruption Chandan Rajendra <chandan@linux.vnet.ibm.com> - 2017-08-07 08:50 +0200
csiph-web