Skip to content

Commit

Permalink
HID: u2fzero: ignore incomplete packets without data
Browse files Browse the repository at this point in the history
commit 22d6576 upstream.

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: 42337b9("HID: add driver for U2F Zero built-in LED and RNG")
Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
andrewshadura authored and gregkh committed Oct 6, 2021
1 parent 3770e21 commit a7f4c63
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/hid/hid-u2fzero.c
Expand Up @@ -198,7 +198,9 @@ static int u2fzero_rng_read(struct hwrng *rng, void *data,
}

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;

/* only take the minimum amount of data it is safe to take */
Expand Down

0 comments on commit a7f4c63

Please sign in to comment.