libkmod: Verify memory sizes on 32 bit systems.
PATCH 1/1 libkmod: Verify memory sizes on 32 bit systems.
Large file system support is activated by default, which means that on 32 bit systems, off_t is 64 bit in size.
Using st.st_size or any other 64 bit variable with mmap can lead to integer truncation and therefore insufficient memory mapping.
Signed-off-by Tobias Stoeckmann <[email protected]>
--- libkmod/libkmod-file.c | 2 ++ 1 file changed, 2 insertions(+)
libkmod/libkmod-file.c +2 -0
@@ -255,6 +255,8 @@ static int load_reg(struct kmod_file *file)return -errno; file->size = st.st_size; +if ((uintmax_t )st.st_size > (uintmax_t )SIZE_MAX ) +return -EFBIG ; file->memory =mmap (NULL , file->size,PROT_READ ,MAP_PRIVATE , file->fd,0 );if (file->memory ==MAP_FAILED )
Signature · 1 line
2.13.2