It seems like you can modify software legally, but it seems to be very limited for what purposes you can modify it.
http://cr.yp.to/softwarelaw.html
Also you have the right to modify the software on your car, EFF Wins Petition to Inspect and Modify Car Software | Electronic Frontier Foundation