Skip to content

Commit

Permalink
tools: let jailhouse-cell-linux check header signatures
Browse files Browse the repository at this point in the history
We do have magic bytes in configfile headers for distunguishing cell and
system configurations. Add this check to jailhouse-cell-linux to avoid
passing system configurations to jailhouse-cell-linux.

Signed-off-by: Ralf Ramsauer <ralf.ramsauer@oth-regensburg.de>
[Jan: wrapped over-long line]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
  • Loading branch information
rralf authored and jan-kiszka committed Nov 27, 2016
1 parent 5444c1c commit c295bdb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/jailhouse-cell-linux
Expand Up @@ -509,12 +509,13 @@ class MemoryRegion:


class Config:
_HEADER_FORMAT = '8x32s4xIIIIIIIII'
_HEADER_FORMAT = '8s32s4xIIIIIIIII'

def __init__(self, config_file):
self.data = config_file.read()

(name,
(signature,
name,
self.flags,
self.cpu_set_size,
self.num_memory_regions,
Expand All @@ -525,6 +526,10 @@ class Config:
self.num_pci_caps,
self.vpci_irq_base) = \
struct.unpack_from(Config._HEADER_FORMAT, self.data)
if str(signature.decode()) != 'JAILCELL':
print('Not a cell configuration: %s' % config_file.name,
file=sys.stderr)
exit(1)
self.name = str(name.decode())

memregion_offs = struct.calcsize(Config._HEADER_FORMAT) + \
Expand Down

0 comments on commit c295bdb

Please sign in to comment.