Vaio eeprom security issue
Hi all,
As some of you may know, I have been working on an EEPROM that is found in Sony Vaio laptops for quite some time now. I recently found that the BIOS password, when set, is stored in that EEPROM in a very lightly coded way (took me less than a minute to find the encoding/decoding method). Since the eeprom module will export the data to userspace, it looks like we could have a security issue.
The good thing is that I was precisely using that field as a way to detect the EEPROM, so once a password is set, sensors-detect won't detect it anymore (and thus give it a confidence 1 only). Sensors will not recognize the EEPROM either.
The bad thing is that the data is still exported to userspace. What's more, this field is also where the regular SPD main data are (the memory type and size). Fortunately, the values should be different enough so that no password could make sensors think this is a SPD EEPROM. Still, some password could make the SPD checksum succeed (while it usually fails on Sony Vaio EEPROMs) and confuse sensors-detect.
So, here is the proposed plan:
1* Fix sensors-detect so that it will identify the two different kind of eeproms correctly. I think we could have two distinct entries in our chips list (say "SPD EEPROM" and "Sony Vaio EEPROM"), even if both are EEPROMs, using the same driver and prefix.
2* Check that detection procedures in the eeprom driver are correct. IIRC, there is almost no check unless checksum=1, maybe some checks should be added.
3* Define a security policy for that password issue. I think we simply should disable the Vaio EEPROM in the eeprom module if we find there is a password set. It could be forced using the force_eeprom module parameter (or should we define another module parameter?) Another possibility is to hide that particular field instead, but I'm not sure it's worth the work.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Quoted 7 lines · Jean Delvare
3* Define a security policy for that password issue. I think we simply should disable the Vaio EEPROM in the eeprom module if we find there is a password set. It could be forced using the
force_eeprommodule parameter (or should we define another module parameter?) Another possibility is to hide that particular field instead, but I'm not sure it's worth the work.
How about only allowing root (or the proper CAP_* value) to read this value. I imagine it would be useful for some people to get access to this for legimate reasons.
thanks,
greg k-h
Quoted 10 lines · Jean Delvare
Quoted 7 lines
3* Define a security policy for that password issue. I think we simply should disable the Vaio EEPROM in the eeprom module if we find there is a password set. It could be forced using the
force_eeprommodule parameter (or should we define another module parameter?) Another possibility is to hide that particular field instead, but I'm not sure it's worth the work.
Quoted 3 lines
How about only allowing root (or the proper CAP_* value) to read this value. I imagine it would be useful for some people to get access to this for legimate reasons.
I'm not sure I get what you mean there (what are these CAP_* values?).
Here are my random thoughts about the problem:
1* We could add some code to eeprom_detect that determines wether this is a Sony Vaio EEPROM, and store the result in a new variable in eeprom_data. If this is a Sony Vaio EEPROM, we could check wether a BIOS password is set, and store the result in another variable in eeprom_data, or the same variable.
2* Using the variable(s) defined above, we can do one of the following:
#1 Nothing. Leave the responsability to the person who loaded the
module. We still can document the problem in doc/chips/eeprom.
#2 Do not support this EEPROM at all if a password is set. Document in
doc/chips/eeprom accordingly.
#3 Do not export that particular data. Remove the corresponding /proc
entry. I expect this solution to be difficult to handle for userspace programs such as sensors.
#4 Export that particular data with mode 400 instead of 444. Same
problems as with the previous option for non-root users.
#5 Export the seven bytes as 0x00 whatever their value. This is
probably the easier way for userspace programs. Tricky however.
#6 Something else?
I'm in favor of solution #2. If the user set a password, he/she is concerned by security, and probably don't want the EEPROM to be exported to userspace at all (the EEPROM contains the serial number and UUID of the machine). We still can honor the force_eeprom parameter.
Anyway, root still can run i2cdump and obtain the same information, so this isn't the problem.
Remember that the eeprom module is a generic module, although it was born to support SPD in the first place. I don't think we want it to become another overcrowded module like w83781d, so adding too much specific code, in particular for a rare and proprietary eeprom, does not sound good.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Quoted 10 lines · Jean Delvare
Quoted 10 lines · Jean Delvare
Quoted 7 lines
3* Define a security policy for that password issue. I think we simply should disable the Vaio EEPROM in the eeprom module if we find there is a password set. It could be forced using the
force_eeprommodule parameter (or should we define another module parameter?) Another possibility is to hide that particular field instead, but I'm not sure it's worth the work.
Quoted 5 lines
Quoted 3 lines
How about only allowing root (or the proper CAP_* value) to read this value. I imagine it would be useful for some people to get access to this for legimate reasons.
I'm not sure I get what you mean there (what are these CAP_* values?).
Different capability permission values. Look in include/linux/capability.h for more information. It's more fine grained than just "root".
Hope this helps,
greg k-h
Quoted 9 lines
Quoted 3 lines
I'm not sure I get what you mean there (what are these CAP_* values?).
Different capability permission values. Look in
include/linux/capability.hfor more information. It's more fine grained than just "root".Hope this helps,
Not really. Looks complicated ;) and it seems these are capabilities you give to a user/process, not to a file. I just don't want to dive into this for something that "simple".
Remember, the eeprom module, although widely used, is one of our least interesting drivers. And LM Sensors is useless on Sony Vaio's anyway (no sensor chips). So let's play it safe, but without extra technologies involved. Do not export the eeproms detected as Vaio's ones unless forced too. I'll implement that this afternoon, test it on my laptop and commit.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Quoted 8 lines · Jean Delvare
Quoted 8 lines
Quoted 3 lines
I'm not sure I get what you mean there (what are these CAP_* values?).
Different capability permission values. Look in
include/linux/capability.hfor more information. It's more fine grained than just "root".
Quoted 5 lines
Quoted 1 line
Hope this helps,
Not really. Looks complicated ;) and it seems these are capabilities you give to a user/process, not to a file. I just don't want to dive into this for something that "simple".
Why? Just check for CAP_SYS_ADMIN if the Vaio is detected. If that succeeds, then give access, otherwise deny it.
Quoted 2 lines
Remember, the eeprom module, although widely used, is one of our least interesting drivers.
But it's fun to play with :)
Quoted 1 line
And LM Sensors is useless on Sony Vaio's anyway (no sensor chips).
Looks like the eeprom driver works :)
Quoted 2 lines
So let's play it safe, but without extra technologies involved. Do not export the eeproms detected as Vaio's ones unless forced too.
What does "forced too" mean here?
thanks,
greg k-h
Quoted 10 lines · Jean Delvare
Quoted 7 lines
Quoted 4 lines
Not really. Looks complicated ;) and it seems these are capabilities you give to a user/process, not to a file. I just don't want to dive into this for something that "simple".
Why? Just check for
CAP_SYS_ADMINif the Vaio is detected. If that succeeds, then give access, otherwise deny it.I'm not sure I understand how it works. Whose capabilities are checked? The person accessing the proc file?
Yes.
Quoted 10 lines
In this case, yes, it would make sense. I would then have something like:
if (!capable(CAP_SYS_ADMIN)) { /* show the real data */ } else { /* show zeroes only */ }Is that it?
Looks good to me, as long as you have done the check for Vaio previous to this.
Quoted 1 line
I don't know actually what I should display for non-root users
0 looks like a good choice.
Quoted 1 line
(btw,
CAP_SYS_ADMIN= root, or is it more complex?).
It's a bit more complex. You can allow some users some rights. Traditionally root gets them all, but you can revoke some of them for some instances of root. In reality, it's not used that much :(
For a much more complex version of something like this, with different rights for different users, take a look at the SELinux stuff which just got merged into the 2.6.0-test3 kernel. It uses the LSM framework to catch all of this kind of stuff (LSM hooks into the capability call.) But this is off-topic for sensors, sorry...
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
Remember, the eeprom module, although widely used, is one of our least interesting drivers.
But it's fun to play with :)
Sure it is, that's the one I started with (due to that Vaio EEPROM already). But it's also one of the slowest drivers, and I believe we'll get rid of it someday (I really plan not to load it by default at some time).
I have a port of it in my 2.6 tree, that I need to move over to the binary sysfs file interface before adding. It's so simple I use it for testing all the time.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
And LM Sensors is useless on Sony Vaio's anyway (no sensor chips).
Looks like the eeprom driver works :)
Yes it does, but do users install
lm_sensorsto read how many memory they do have in their laptop? I doubt it.
Who knows :)
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
So let's play it safe, but without extra technologies involved. Do not export the eeproms detected as Vaio's ones unless forced too.
What does "forced too" mean here?
Force like in "modprobe eeprom force=0,0x57".
Ah. Makes sense.
thanks,
greg k-h
Quoted 7 lines
Quoted 4 lines
Not really. Looks complicated ;) and it seems these are capabilities you give to a user/process, not to a file. I just don't want to dive into this for something that "simple".
Why? Just check for
CAP_SYS_ADMINif the Vaio is detected. If that succeeds, then give access, otherwise deny it.
I'm not sure I understand how it works. Whose capabilities are checked? The person accessing the proc file? In this case, yes, it would make sense. I would then have something like:
if (!capable(CAP_SYS_ADMIN)) {
/* show the real data */
} else {
/* show zeroes only */
}Is that it? I don't know actually what I should display for non-root users (btw, CAP_SYS_ADMIN = root, or is it more complex?). Maybe an empty file, or maybe zero values instead of the password.
Quoted 4 lines
Quoted 2 lines
Remember, the eeprom module, although widely used, is one of our least interesting drivers.
But it's fun to play with :)
Sure it is, that's the one I started with (due to that Vaio EEPROM already). But it's also one of the slowest drivers, and I believe we'll get rid of it someday (I really plan not to load it by default at some time).
Quoted 3 lines
Quoted 1 line
And LM Sensors is useless on Sony Vaio's anyway (no sensor chips).
Looks like the eeprom driver works :)
Yes it does, but do users install lm_sensors to read how many memory they do have in their laptop? I doubt it.
Quoted 4 lines
Quoted 2 lines
So let's play it safe, but without extra technologies involved. Do not export the eeproms detected as Vaio's ones unless forced too.
What does "forced too" mean here?
Force like in "modprobe eeprom force=0,0x57".
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Quoted 11 lines
Quoted 8 lines
if (!capable(CAP_SYS_ADMIN)) { /* show the real data */ } else { /* show zeroes only */ }Is that it?
Looks good to me, as long as you have done the check for Vaio previous to this.
What header should I include? It worked without any additional header, but I'd like to make it clean. I searched the kernel sources, seems that capable is defined in linux/sched.h, but some files are using capable() without including it. Including linux/capability.h would sound good, but actually this header doesn't define capable() and does not include linux/sched.h either.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Why? Just check for
CAP_SYS_ADMINif the Vaio is detected. If that succeeds, then give access, otherwise deny it.
OK, that's done and tested OK (for me). Feel free to take a look if you want (it's straightforward anyway).
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/