zlib won't necessarily set the system errno, and this is particularly evident on corrupted data (which results in a double free). Use zlib's gzerror to detect the failure, returning a generic EINVAL when zlib doesn't provide us with an errno. --- This fixes a crash that I had seen a few times from Arch users, but was never able to pin down, with the reporter disappearing fairly quickly. I finally traced it to corrupted gzip archives, which kmod should definitely not be exploding on, no matter how invalid they are. Below is a link to one such corrupted module to replicate the bug: http://dev.archlinux.org/~dreisner/hid-sunplus.ko.gz libkmod/libkmod-file.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libkmod/libkmod-file.c b/libkmod/libkmod-file.c index 46ad8d9..8beb7e3 100644 --- a/libkmod/libkmod-file.c +++ b/libkmod/libkmod-file.c @@ -199,7 +199,13 @@ static int load_zlib(struct kmod_file *file) if (r == 0) break; else if (r < 0) { - err = -errno; + int gzerr; + const char *gz_errmsg = gzerror(file->gzf, &gzerr); + + ERR(file->ctx, "gzip: %s\n", gz_errmsg); + + /* gzip might not set errno here */ + err = gzerr == Z_ERRNO ? -errno : -EINVAL; goto error; } did += r; -- 1.7.10.1 -- To unsubscribe from this list: send the line "unsubscribe linux-modules" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html