i2c/eeprom: Hide Sony Vaio serial numbers

The sysfs interface to DMI data takes care to not make the system
serial number and UUID world-readable, presumably due to privacy
concerns. For consistency, we should not let the eeprom driver
export these same strings to the world on Sony Vaio laptops.
Instead, only make them readable by root, as we already do for BIOS
passwords.

Signed-off-by: Jean Delvare <khali@linux-fr.org>

authored by Jean Delvare and committed by Jean Delvare 0f2cbd38 be8a1f7c

+15 -8
+15 -8
drivers/i2c/chips/eeprom.c
··· 128 128 for (slice = off >> 5; slice <= (off + count - 1) >> 5; slice++) 129 129 eeprom_update_client(client, slice); 130 130 131 - /* Hide Vaio security settings to regular users (16 first bytes) */ 132 - if (data->nature == VAIO && off < 16 && !capable(CAP_SYS_ADMIN)) { 133 - size_t in_row1 = 16 - off; 134 - in_row1 = min(in_row1, count); 135 - memset(buf, 0, in_row1); 136 - if (count - in_row1 > 0) 137 - memcpy(buf + in_row1, &data->data[16], count - in_row1); 131 + /* Hide Vaio private settings to regular users: 132 + - BIOS passwords: bytes 0x00 to 0x0f 133 + - UUID: bytes 0x10 to 0x1f 134 + - Serial number: 0xc0 to 0xdf */ 135 + if (data->nature == VAIO && !capable(CAP_SYS_ADMIN)) { 136 + int i; 137 + 138 + for (i = 0; i < count; i++) { 139 + if ((off + i <= 0x1f) || 140 + (off + i >= 0xc0 && off + i <= 0xdf)) 141 + buf[i] = 0; 142 + else 143 + buf[i] = data->data[off + i]; 144 + } 138 145 } else { 139 146 memcpy(buf, &data->data[off], count); 140 147 } ··· 211 204 && i2c_smbus_read_byte(new_client) == 'G' 212 205 && i2c_smbus_read_byte(new_client) == '-') { 213 206 dev_info(&new_client->dev, "Vaio EEPROM detected, " 214 - "enabling password protection\n"); 207 + "enabling privacy protection\n"); 215 208 data->nature = VAIO; 216 209 } 217 210 }