Bug 207695
Summary: | [uinput] add_uevent_var: buffer size too small ("Cannot allocate memory" on udevadm trigger) | ||
---|---|---|---|
Product: | Drivers | Reporter: | Georg Grabler (ggrabler) |
Component: | Input Devices | Assignee: | drivers_input-devices |
Status: | NEW --- | ||
Severity: | normal | CC: | brchuckz, davide, domi.dumont, olekw.dev+kernel.org, phill, sascha-w-bugzilla-kernel |
Priority: | P1 | ||
Hardware: | x86-64 | ||
OS: | Linux | ||
Kernel Version: | 5.6.4 | Subsystem: | |
Regression: | No | Bisected commit-id: |
Description
Georg Grabler
2020-05-11 21:45:10 UTC
Hi I'm facing a similar issue on Debian/unstable: $ sudo udevadm trigger --action=change Failed to write 'change' to '/sys/devices/virtual/input/input30/uevent': Cannot allocate memory Here's the involved udev rule from lcdproc packages: $ cat /lib/udev/rules.d/60-lcdproc.rules KERNEL=="lcd[0-9]*" , ATTRS{idVendor}=="15c2" , SYMLINK+="lcd-imon" journalctl -k shows: Jun 02 18:36:11 frodo kernel: input: iMON Remote (15c2:0038) (lircd bypass) as /devices/virtual/input/input29 Jun 02 18:36:11 frodo kernel: input: lircd-uinput as /devices/virtual/input/input30 Jun 02 18:36:11 frodo kernel: r8169 0000:03:00.0 eth0: Link is Up - 1Gbps/Full - flow control rx/tx Jun 02 18:36:11 frodo kernel: IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready Jun 02 18:36:58 frodo kernel: synth uevent: /devices/virtual/input/input30: failed to send uevent Jun 02 18:36:58 frodo kernel: input input30: uevent: failed to send synthetic uevent $ uname -a Linux frodo 5.6.0-2-amd64 #1 SMP Debian 5.6.14-1 (2020-05-23) x86_64 GNU/Linux Hope this helps On second thought, this problem occurs when udevadm trigger is applied without restriction. I've no longer this problem when udevadm trigger is applied only on usbmisc subsystem. E.g.: udevadm trigger --action=change --subsystem-match=usbmisc Hope this helps Is the device in question the Xen virtual keyboard? That's where I am seeing this and it causes the debian installer to crash and reboot ( init exits due to set -e plus udev error, causing kernel panic ) the domU when booting it under Xen. Hi In my case, the device is an USB LCD display driven by lcdproc (see http://lcdproc.omnipotent.net/) All the best I bisected the source of the problem to this commit: commit df44b479654f62b478c18ee4d8bc4e9f897a9844 Author: Peter Rajnoha <prajnoha@redhat.com> Date: Wed Dec 5 12:27:44 2018 +0100 kobject: return error code if writing /sys/.../uevent fails Propagate error code back to userspace if writing the /sys/.../uevent file fails. Before, the write operation always returned with success, even if we failed to recognize the input string or if we failed to generate the uevent itself. With the error codes properly propagated back to userspace, we are able to react in userspace accordingly by not assuming and awaiting a uevent that is not delivered. Signed-off-by: Peter Rajnoha <prajnoha@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> So I guess that certain drivers, including the Xen virtual keyboard and your LCD display, have always been broken but it was never reported until this commit. So I have drilled down to the root cause finally. The modalias for this driver is over 2 KB in size, so the input core fails with -ENOMEM trying to shove it into the environment block for the uevent. I wonder if your device also has an unusually large modalias? In my case, the failing lcdproc driver is imon. Here's the modalias size: $ grep 'imon$' /lib/modules/`uname -r`/modules.alias | wc -c 1020 HTH This bug has a corresponding bug on Debian BTS: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983357 This Debian bug is specifically about the Xen virtual keyboard driver. In that bug report, a Debian Developer noted that the environment of a uevent is limited to 2k in the kernel, but 8k is allocated in the systemd buffer for receiving uevents. So the root cause of the bug seems to be a mismatch in these buffer sizes in the kernel and systemd. Although this implies the buffer in the kernel should be increased to 8k, he suggested as a first step that someone test and see if increasing it to 4k helps. I did the test and it seems to fix the bug for the Xen virtual keyboard driver. The patch to the kernel to implement this fix was given by the Debian developer as: --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -30,7 +30,7 @@ #define UEVENT_HELPER_PATH_LEN 256 #define UEVENT_NUM_ENVP 64 /* number of env pointers */ -#define UEVENT_BUFFER_SIZE 2048 /* buffer for the variables */ +#define UEVENT_BUFFER_SIZE 4096 /* buffer for the variables */ #ifdef CONFIG_UEVENT_HELPER /* path to the userspace helper executed on an event */ --- END --- Anyone who sees this bug with a particular kernel driver might try this patch to see if it fixes it. |