Re: [PATCH] decompressors: fix "no limit" output buffer length

From: Alex Courbot
Date: Tue Jul 23 2013 - 01:01:43 EST


On 07/23/2013 12:32 PM, Stephen Warren wrote:
On 07/22/2013 07:15 PM, Alex Courbot wrote:
...
Although the patch seems ok to me in its current form, there are two
points for which I still have small doubts:

1) Whether size_t and pointers will have the same size on all platforms.

ptrsize_t?


Do you mean ptrdiff_t? (I cannot find ptrsize_t anywhere in the kernel)

Looking further about the uses of size_t and ptrdiff_t, it seems like size_t is designed to store the maximum addressable member of an array, whereas ptrdiff_t is used to store a substraction of two pointers. In effect, they translate to the unsigned (size_t) and signed (ptrdiff_t) variants of the same type.

But since here we know that the result of the substraction will always be positive and potentially big (for devices with memory in the lower half of the address space) using size_t sounds safer to avoid overflows and sign-conversion issues (strm->avail_out, where the value of out_len eventually ends, is an unsigned int).

So point 1) at least seems to be handled correctly with size_t. Point 2) might still be of concern, but if your uncompressed kernel image ends up overflowing your addressable memory, I guess you have a bigger problem to start with. :)

Andrew, do you think you can merge this as-is? Sorry if you are not the right person to ask, but there is no clear maintainer for this part of the code and you appear to have handled the latest patches that affect the same file.

Thanks,
Alex.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/