patch "firmware: google: check if size is valid when decoding VPD data" added to char-misc-testing
This is a note to let you know that I've just added the patch titled
firmware: google: check if size is valid when decoding VPD data
to my char-misc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-testing branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will be merged to the char-misc-next branch sometime soon, after it passes testing, and the merge window is open.
If you have any questions about this process, please let me know.
From d616b75cb793a0707345ccf4c6f239b6d16e1e5b Mon Sep 17 00:00:00 2001
From: Hung-Te Lin <[email protected]>
Date: Fri, 30 Aug 2019 10:23:58 +0800
Subject: firmware: google: check if size is valid when decoding VPD data
The VPD implementation from Chromium Vital Product Data project used to parse data from untrusted input without checking if the meta data is invalid or corrupted. For example, the size from decoded content may be negative value, or larger than whole input buffer. Such invalid data may cause buffer overflow.
To fix that, the size parameters passed to vpd_decode functions should be changed to unsigned integer (u32) type, and the parsing of entry header should be refactored so every size field is correctly verified before starting to decode.
--- drivers/firmware/google/vpd.c | 4 +- drivers/firmware/google/vpd_decode.c | 55 ++++++++++++++++------------ drivers/firmware/google/vpd_decode.h | 6 +-- 3 files changed, 37 insertions(+), 28 deletions(-)
drivers/firmware/google/vpd.c +2 -2
@@ -92,8 +92,8 @@ static int vpd_section_check_key_name(const u8 *key, s32 key_len)return VPD_OK ; } -static int vpd_section_attrib_add (const u8 *key,s32 key_len, -const u8 *value,s32 value_len, +static int vpd_section_attrib_add (const u8 *key,u32 key_len, +const u8 *value,u32 value_len,void *arg) {int ret;
drivers/firmware/google/vpd_decode.c +32 -23
84 lines not on this page · raw message
drivers/firmware/google/vpd_decode.h +3 -3
@@ -25,8 +25,8 @@ enum { };/* Callback for vpd_decode_string to invoke. */ -typedef int vpd_decode_callback (const u8 *key,s32 key_len, -const u8 *value,s32 value_len, +typedef int vpd_decode_callback (const u8 *key,u32 key_len, +const u8 *value,u32 value_len,void *arg);/*
@@ -44,7 +44,7 @@ typedef int vpd_decode_callback(const u8 *key, s32 key_len,* If one entry is successfully decoded, sends it to callback and returns the * result. */ -int vpd_decode_string (const s32 max_len,const u8 *input_buf,s32 *consumed, +int vpd_decode_string (const u32 max_len,const u8 *input_buf,u32 *consumed,vpd_decode_callback callback,void *callback_arg);#endif /* __VPD_DECODE_H */
Signature · 1 line
2.23.0