Mutter crashes because of invalid `monitors.xml`, that it generates itself
Description
Certain hardware vendors may have characters such as an ampersand (or
other that may need to be escaped) in their EDID data, which leads to an
invalid monitors.xml
. There are actual cases where this is happening
with existing hardware.
This is a real world example snippet after applying a configuration in the Displays panel in GNOME Settings:
<monitorspec>
<connector>HDMI-1</connector>
<vendor>BUR</vendor>
<product>B&R AP1000</product>
<serial>0x41110b51</serial>
</monitorspec>
The next time when logging in after this configuration has been
generated, Mutter will show the "Oh no! Something has gone wrong." crash
screen. This problem then can be fixed by deleting the monitors.xml
,
without starting Mutter (e.g. console login). (I didn't check if it
works to just manually escape the characters and I don't have the
hardware atm, sorry.)
Explanation
The text in none of the elements, generated in
src/backends/meta-monitor-config-store.c
, are escaped. This should
not be an issue with text that is completely controlled by Mutter such
as <x>0</x>
or <rotation>right</rotation>
but none of the elements
in the <monitorspec>
element are hard-coded string literals and fully
in control by Mutter.
EDID allows for pretty much any printable ASCII character to appear in
the Display Product Name (inserted in <product>
). The serial number
and vendor name strings though also probably should be checked if they
need to be escaped, just to be safe. I didn't check all possible
elements in the XML, maybe there are other things that may need
escaping?
Do you think that this needs to be fixed outside of Mutter as well?
Does any other application also interact with ~/.config/monitors.xml
?
I have a further concern, the monitors.xml
can be manipulated by any
user application that is not sandboxed. Mutter should probably be able
to fallback to a safe default, if the file cannot be parsed correctly
instead of crashing and leaving most users at a loss of how they may
recover.