Skip to content

Commit 22d6576

Browse files
andrewshaduraJiri Kosina
authored andcommitted
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: 42337b9("HID: add driver for U2F Zero built-in LED and RNG") Signed-off-by: Andrej Shadura <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent d46ef75 commit 22d6576

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/hid/hid-u2fzero.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ static int u2fzero_rng_read(struct hwrng *rng, void *data,
198198
}
199199

200200
ret = u2fzero_recv(dev, &req, &resp);
201-
if (ret < 0)
201+
202+
/* ignore errors or packets without data */
203+
if (ret < offsetof(struct u2f_hid_msg, init.data))
202204
return 0;
203205

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

0 commit comments

Comments
 (0)