diff options
author | Zach Reizner <zachr@google.com> | 2017-05-30 18:45:05 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-07-05 21:54:53 -0700 |
commit | f2164a18bf9e58051e5b8bf4c063c19297a77878 (patch) | |
tree | 312830766556c8a147e25ad89f5f73e0f48e9148 /src/hw/serial.rs | |
parent | 639d96775c5de91f1025456d7e7ee914f5661291 (diff) | |
download | crosvm-f2164a18bf9e58051e5b8bf4c063c19297a77878.tar crosvm-f2164a18bf9e58051e5b8bf4c063c19297a77878.tar.gz crosvm-f2164a18bf9e58051e5b8bf4c063c19297a77878.tar.bz2 crosvm-f2164a18bf9e58051e5b8bf4c063c19297a77878.tar.lz crosvm-f2164a18bf9e58051e5b8bf4c063c19297a77878.tar.xz crosvm-f2164a18bf9e58051e5b8bf4c063c19297a77878.tar.zst crosvm-f2164a18bf9e58051e5b8bf4c063c19297a77878.zip |
crosvm: fix serial device panic on write to read-only registers
There were a few cases of a write into the serial device that would panic because the registers were read-only. This change simply ignores those writes instead of raising a panic. This is also the first bug that was found by cargo-fuzz! Wohoo! TEST=None BUG=None Change-Id: I8b6805617ac3dcfddd0555c1bb394a7bc1a7cf6d Reviewed-on: https://chromium-review.googlesource.com/518445 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'src/hw/serial.rs')
-rw-r--r-- | src/hw/serial.rs | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/hw/serial.rs b/src/hw/serial.rs index f93631d..68bc63e 100644 --- a/src/hw/serial.rs +++ b/src/hw/serial.rs @@ -176,11 +176,10 @@ impl Serial { } } IER => self.interrupt_enable = v & IER_FIFO_BITS, - FCR => {} LCR => self.line_control = v, MCR => self.modem_control = v, SCR => self.scratch = v, - o => panic!("bad write offset on serial device: {}", o), + _ => {} } Ok(()) } @@ -192,10 +191,6 @@ impl BusDevice for Serial { return; } - if offset >= 8 { - return; - } - if let Err(e) = self.handle_write(offset as u8, data[0]) { println!("serial failed write: {:?}", e); } @@ -227,7 +222,7 @@ impl BusDevice for Serial { LSR => self.line_status, MSR => self.modem_status, SCR => self.scratch, - o => panic!("bad read offset on serial device: {}", o), + _ => 0, }; } } |