UBSAN: shift-out-of-bounds in e100_eeprom_load
Subsystems (2)
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Tested on:
commit: f9a2394a Merge tag 'mm-hotfixes-stable-2026-08-06-18-4.. git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git console output: https://syzkaller.appspot.com/x/log.txt?x=13050079580000 kernel config: https://syzkaller.appspot.com/x/.config?x=145fa60d73086782 dashboard link: https://syzkaller.appspot.com/bug?extid=e0abb1d45ac291ebebeb compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 patch: https://syzkaller.appspot.com/x/patch.diff?x=12a90079580000
Note: testing is done by a robot and is best-effort only.
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
drivers/net/ethernet/intel/e100.c +9 -7
@@ -746,10 +746,12 @@ static __le16 e100_eeprom_read(struct nic *nic, u16 *addr_len, u16 addr)if (!(ctrl & eedo) && i >16 ) {u16 len = i -16 ; -if (len > *addr_len) +if (len > *addr_len) { *addr_len =0 ; -else - *addr_len -= len; +break ; + } + + *addr_len -= len; i =17 ; }
@@ -771,14 +773,14 @@ static int e100_eeprom_load(struct nic *nic)/* Try reading with an 8-bit addr len to discover actual addr len */ e100_eeprom_read (nic, &addr_len,0 ); -if (!addr_len || addr_len >=16 ) { +if (!addr_len || addr_len >8 ) {netif_err (nic, probe, nic->netdev,"Invalid EEPROM address length %u\n" , addr_len);return -EIO ; } - nic->eeprom_wc =1 << addr_len; + nic->eeprom_wc = (u16 )BIT (addr_len);for (addr =0 ; addr < nic->eeprom_wc; addr++) { nic->eeprom[addr] =e100_eeprom_read (nic, &addr_len, addr);
@@ -805,14 +807,14 @@ static int e100_eeprom_save(struct nic *nic, u16 start, u16 count)/* Try reading with an 8-bit addr len to discover actual addr len */ e100_eeprom_read (nic, &addr_len,0 ); -if (!addr_len || addr_len >=16 ) { +if (!addr_len || addr_len >8 ) {netif_err (nic, probe, nic->netdev,"Invalid EEPROM address length %u\n" , addr_len);return -EIO ; } - nic->eeprom_wc =1 << addr_len; + nic->eeprom_wc = (u16 )BIT (addr_len);if (start + count >= nic->eeprom_wc)return -EINVAL ;
Signature · 1 line
2.43.0
syzbot
syzbotsyzbot tried to test the proposed patch but the build/boot failed:
Hello,
syzbot tried to test the proposed patch but the build/boot failed:
failed to apply patch:
error: patch failed: drivers/net/ethernet/intel/e100.c:746
error: drivers/net/ethernet/intel/e100.c: patch does not apply
Tested on:
commit: 8d3ae592 Linux 7.2 git tree: upstream kernel config: https://syzkaller.appspot.com/x/.config?x=145fa60d73086782 dashboard link: https://syzkaller.appspot.com/bug?extid=e0abb1d45ac291ebebeb
compiler:
patch: https://syzkaller.appspot.com/x/patch.diff?x=17c20679580000
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
drivers/net/ethernet/intel/e100.c +26 -3
@@ -744,7 +744,14 @@ static __le16 e100_eeprom_read(struct nic *nic, u16 *addr_len, u16 addr)* complete address. Use this to adjust addr_len. */ ctrl =ioread8 (&nic->csr->eeprom_ctrl_lo);if (!(ctrl & eedo) && i >16 ) { - *addr_len -= (i -16 ); +u16 len = i -16 ; + +if (len > *addr_len) { + *addr_len =0 ; +break ; + } + + *addr_len -= len; i =17 ; }
@@ -765,7 +772,15 @@ static int e100_eeprom_load(struct nic *nic)/* Try reading with an 8-bit addr len to discover actual addr len */ e100_eeprom_read (nic, &addr_len,0 ); - nic->eeprom_wc =1 << addr_len; + +if (!addr_len || addr_len >8 ) { +netif_err (nic, probe, nic->netdev, +"Invalid EEPROM address length %u\n" , + addr_len); +return -EIO ; + } + + nic->eeprom_wc = (u16 )BIT (addr_len);for (addr =0 ; addr < nic->eeprom_wc; addr++) { nic->eeprom[addr] =e100_eeprom_read (nic, &addr_len, addr);
@@ -791,7 +806,15 @@ static int e100_eeprom_save(struct nic *nic, u16 start, u16 count)/* Try reading with an 8-bit addr len to discover actual addr len */ e100_eeprom_read (nic, &addr_len,0 ); - nic->eeprom_wc =1 << addr_len; + +if (!addr_len || addr_len >8 ) { +netif_err (nic, probe, nic->netdev, +"Invalid EEPROM address length %u\n" , + addr_len); +return -EIO ; + } + + nic->eeprom_wc = (u16 )BIT (addr_len);if (start + count >= nic->eeprom_wc)return -EINVAL ;
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Tested on:
commit: 8d3ae592 Linux 7.2 git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=1247d949580000 kernel config: https://syzkaller.appspot.com/x/.config?x=d07fbc6821d72a61 dashboard link: https://syzkaller.appspot.com/bug?extid=e0abb1d45ac291ebebeb compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44 patch: https://syzkaller.appspot.com/x/patch.diff?x=16ca0679580000
Note: testing is done by a robot and is best-effort only.