* [PATCH 2/2] lz4 overflow bug
@ 2015-04-15 20:51 Toomas Soome
2015-04-16 4:20 ` Andrei Borzenkov
0 siblings, 1 reply; 4+ messages in thread
From: Toomas Soome @ 2015-04-15 20:51 UTC (permalink / raw)
To: The development of GNU GRUB
hi!
yep, this old bug is not fixed in grub. cpy can (theoretically?) overflow.
---
grub-core/fs/zfs/zfs_lz4.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/grub-core/fs/zfs/zfs_lz4.c b/grub-core/fs/zfs/zfs_lz4.c
index 1212a89..ca6445d 100644
--- a/grub-core/fs/zfs/zfs_lz4.c
+++ b/grub-core/fs/zfs/zfs_lz4.c
@@ -185,6 +185,8 @@ LZ4_uncompress_unknownOutputSize(const char *source,
}
/* copy literals */
cpy = op + length;
+ if (cpy < op)
+ goto _output_error;
if ((cpy > oend - COPYLENGTH) ||
(ip + length > iend - COPYLENGTH)) {
if (cpy > oend)
--
1.7.9.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] lz4 overflow bug
2015-04-15 20:51 [PATCH 2/2] lz4 overflow bug Toomas Soome
@ 2015-04-16 4:20 ` Andrei Borzenkov
2015-04-16 4:51 ` Toomas Soome
0 siblings, 1 reply; 4+ messages in thread
From: Andrei Borzenkov @ 2015-04-16 4:20 UTC (permalink / raw)
To: Toomas Soome; +Cc: The development of GNU GRUB
В Wed, 15 Apr 2015 23:51:16 +0300
Toomas Soome <tsoome@me.com> пишет:
>
> hi!
>
> yep, this old bug is not fixed in grub. cpy can (theoretically?) overflow.
You mean "length"? Or do you really mean pointer overflow?
Anyway in both cases it seems more reasonable to check when length is
computed, not after overflow, when it is already too late.
>
> ---
> grub-core/fs/zfs/zfs_lz4.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/grub-core/fs/zfs/zfs_lz4.c b/grub-core/fs/zfs/zfs_lz4.c
> index 1212a89..ca6445d 100644
> --- a/grub-core/fs/zfs/zfs_lz4.c
> +++ b/grub-core/fs/zfs/zfs_lz4.c
> @@ -185,6 +185,8 @@ LZ4_uncompress_unknownOutputSize(const char *source,
> }
> /* copy literals */
> cpy = op + length;
> + if (cpy < op)
> + goto _output_error;
> if ((cpy > oend - COPYLENGTH) ||
> (ip + length > iend - COPYLENGTH)) {
> if (cpy > oend)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] lz4 overflow bug
2015-04-16 4:20 ` Andrei Borzenkov
@ 2015-04-16 4:51 ` Toomas Soome
2015-04-16 5:07 ` Andrei Borzenkov
0 siblings, 1 reply; 4+ messages in thread
From: Toomas Soome @ 2015-04-16 4:51 UTC (permalink / raw)
To: The development of GNU GRUB
> On 16.04.2015, at 7:20, Andrei Borzenkov <arvidjaar@gmail.com> wrote:
>
> В Wed, 15 Apr 2015 23:51:16 +0300
> Toomas Soome <tsoome@me.com> пишет:
>
>>
>> hi!
>>
>> yep, this old bug is not fixed in grub. cpy can (theoretically?) overflow.
>
> You mean "length"? Or do you really mean pointer overflow?
>
> Anyway in both cases it seems more reasonable to check when length is
> computed, not after overflow, when it is already too late.
integer overflow. from 0xFFFFFFFF to 0x0.
>
>>
>> ---
>> grub-core/fs/zfs/zfs_lz4.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/grub-core/fs/zfs/zfs_lz4.c b/grub-core/fs/zfs/zfs_lz4.c
>> index 1212a89..ca6445d 100644
>> --- a/grub-core/fs/zfs/zfs_lz4.c
>> +++ b/grub-core/fs/zfs/zfs_lz4.c
>> @@ -185,6 +185,8 @@ LZ4_uncompress_unknownOutputSize(const char *source,
>> }
>> /* copy literals */
>> cpy = op + length;
>> + if (cpy < op)
>> + goto _output_error;
>> if ((cpy > oend - COPYLENGTH) ||
>> (ip + length > iend - COPYLENGTH)) {
>> if (cpy > oend)
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] lz4 overflow bug
2015-04-16 4:51 ` Toomas Soome
@ 2015-04-16 5:07 ` Andrei Borzenkov
0 siblings, 0 replies; 4+ messages in thread
From: Andrei Borzenkov @ 2015-04-16 5:07 UTC (permalink / raw)
To: Toomas Soome; +Cc: The development of GNU GRUB
В Thu, 16 Apr 2015 07:51:50 +0300
Toomas Soome <tsoome@me.com> пишет:
>
> > On 16.04.2015, at 7:20, Andrei Borzenkov <arvidjaar@gmail.com> wrote:
> >
> > В Wed, 15 Apr 2015 23:51:16 +0300
> > Toomas Soome <tsoome@me.com> пишет:
> >
> >>
> >> hi!
> >>
> >> yep, this old bug is not fixed in grub. cpy can (theoretically?) overflow.
> >
> > You mean "length"? Or do you really mean pointer overflow?
> >
> > Anyway in both cases it seems more reasonable to check when length is
> > computed, not after overflow, when it is already too late.
>
> integer overflow. from 0xFFFFFFFF to 0x0.
signed integer overflow is undefined behavior in C. It is too late to
check for it after it happened.
>
> >
> >>
> >> ---
> >> grub-core/fs/zfs/zfs_lz4.c | 2 ++
> >> 1 file changed, 2 insertions(+)
> >>
> >> diff --git a/grub-core/fs/zfs/zfs_lz4.c b/grub-core/fs/zfs/zfs_lz4.c
> >> index 1212a89..ca6445d 100644
> >> --- a/grub-core/fs/zfs/zfs_lz4.c
> >> +++ b/grub-core/fs/zfs/zfs_lz4.c
> >> @@ -185,6 +185,8 @@ LZ4_uncompress_unknownOutputSize(const char *source,
> >> }
> >> /* copy literals */
> >> cpy = op + length;
> >> + if (cpy < op)
> >> + goto _output_error;
> >> if ((cpy > oend - COPYLENGTH) ||
> >> (ip + length > iend - COPYLENGTH)) {
> >> if (cpy > oend)
> >
> >
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-16 13:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-15 20:51 [PATCH 2/2] lz4 overflow bug Toomas Soome
2015-04-16 4:20 ` Andrei Borzenkov
2015-04-16 4:51 ` Toomas Soome
2015-04-16 5:07 ` Andrei Borzenkov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.