Comment 16 for bug 829980

James Hunt (jamesodhunt) wrote :

Kay has intimated that the sanitizing of udev messages is a userspace concern (the kernel just passes the data from the device to userspace):

  http://marc.info/?l=linux-hotplug&m=131737595918135&w=2

This implies that maybe we should fix the upstart-udev-bridge to perform sanitization, but how this should be done is unclear. The batteries @smagoun and @Sascha have -- as far as I know -- are the only devices we've ever seen that have caused this problem, but we *could* modify upstart-udev-bridge to add a new switch "--sanitise" that would do the following:

- if non-printables are found in either the udev event name or the udev event environment, replace them with spaces.
  (to handle potential utf-8 characters within strings).

- if non-printables are found *at the end* of either the udev event name or the udev event environment, remove them.
  (to handle what appears to be a buggy device that that is passing junk to the kernel erroneously).

- if any non-printable characters are found, the upstart-udev-bridge will emit a warning message showing:
  - the sanitized name of the event that contained non-printables.
  - the sanitized name of the environment variable associated with the udev event that was found to contain non-printables
   (if applicable).
  - maybe a hex-encoded version of the orignal value that was found to contain non-printables.

Ubuntu would then add the "--sanitise" switch to /etc/init/upstart-udev-bridge.conf. Note that not specifying "--sanitise" would revert to performing no sanitising of any udev event names or environment variables (the current behaviour).

We could change the way the upstart-udev-bridge creates the dbus messages, but that would take time, require lots of extra tests to be written and probably isn't worth the effort as we seem to be dealing with potentially a very small set of devices sending non-printables to userspace (maybe just the device @smagoun has).