Commit 22d65765 authored by Andrej Shadura's avatar Andrej Shadura Committed by Jiri Kosina

HID: u2fzero: ignore incomplete packets without data

Since the actual_length calculation is performed unsigned, packets
shorter than 7 bytes (e.g. packets without data or otherwise truncated)
or non-received packets ("zero" bytes) can cause buffer overflow.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=214437
Fixes: 42337b9d("HID: add driver for U2F Zero built-in LED and RNG")
Signed-off-by: default avatarAndrej Shadura <andrew.shadura@collabora.co.uk>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent d46ef750
...@@ -198,7 +198,9 @@ static int u2fzero_rng_read(struct hwrng *rng, void *data, ...@@ -198,7 +198,9 @@ static int u2fzero_rng_read(struct hwrng *rng, void *data,
} }
ret = u2fzero_recv(dev, &req, &resp); ret = u2fzero_recv(dev, &req, &resp);
if (ret < 0)
/* ignore errors or packets without data */
if (ret < offsetof(struct u2f_hid_msg, init.data))
return 0; return 0;
/* only take the minimum amount of data it is safe to take */ /* only take the minimum amount of data it is safe to take */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment