Skip to contentSkip to conversation

drivers/hwmon/w83627ehf.c:2672 w83627ehf_resume() error: buffer overflow 'W83627EHF

lm-sensors Guenter Roeck 1 participant 1 message Oct 30, 2012

lore
Share & tools
lore
#0 lore raw
Quoted 46 lines · Guenter Roeck
Quoted 45 lines · Jean Delvare
Quoted 44 lines · Guenter Roeck

Hi Jean,

Quoted 40 lines · Jean Delvare

Hi Peter,

Quoted 30 lines · Peter Hüwe

FYI, there are new smatch warnings show up in

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next master
head:   8243aafc4f54244984d7ea707265e98810a3a066
commit: 0110e1dd583ee412ccde1ba027dced6b828fb466 hwmon: (w83627ehf) Add support for suspend
date:   32 hours ago

:::::: branch date: 3 hours ago
:::::: commit date: 32 hours ago

drivers/hwmon/w83627ehf.c:911 w83627ehf_update_device() error: buffer overflow 'W83627EHF_REG_TEMP_OFFSET' 3 <= 8 drivers/hwmon/w83627ehf.c:909 w83627ehf_update_device() error: buffer overflow 'data->temp_offset' 3 <= 8
+ drivers/hwmon/w83627ehf.c:2672 w83627ehf_resume() error: buffer overflow 'W83627EHF_REG_TEMP_OFFSET' 3 <= 8
+ drivers/hwmon/w83627ehf.c:2673 w83627ehf_resume() error: buffer overflow 'data->temp_offset' 3 <= 8

git remote update next
git checkout 0110e1dd583ee412ccde1ba027dced6b828fb466 vim +2672 drivers/hwmon/w83627ehf.c

0110e1dd Jean Delvare 2012-10-25  2666                                               data->temp_max[i]);
0110e1dd Jean Delvare 2012-10-25  2667                  if (data->reg_temp_hyst[i])
0110e1dd Jean Delvare 2012-10-25  2668                          w83627ehf_write_temp(data, data->reg_temp_hyst[i],
0110e1dd Jean Delvare 2012-10-25  2669                                               data->temp_max_hyst[i]);
0110e1dd Jean Delvare 2012-10-25  2670                  if (data->have_temp_offset & (1 << i))
0110e1dd Jean Delvare 2012-10-25  2671                          w83627ehf_write_value(data,
0110e1dd Jean Delvare 2012-10-25 @2672                                                W83627EHF_REG_TEMP_OFFSET[i],
0110e1dd Jean Delvare 2012-10-25 @2673                                                data->temp_offset[i]);
0110e1dd Jean Delvare 2012-10-25  2674          }
0110e1dd Jean Delvare 2012-10-25  2675  
0110e1dd Jean Delvare 2012-10-25  2676          /* Restore other settings */
Quoted 1 line

I checked it and it seems valid.

Actually this is a false positive, only the lower 3 bits of data->have_temp_offset can be set so the write is never attempted with i >= 3. However this isn't something a static code analyzer can easily figure out, so it would be better and safer to adjust the code to make it more obvious. I'll send a patch.

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

If you really want to patch it, there are more places like that; pretty much every loop around the temperature registers is affected. I marked the others as false positive quite some time ago.

Marked how?

On coverity. Only looks like they changed the UI and I don't find the reports anymore :(. I'll try again later today.

Looks like it was only one case in update_device, and you fixed it in your patch.

Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors