Package: udev
Version: 252.4-1
Severity: important
I have encountered an issue with `udev` after upgrade from the latest Ubuntu
Impish (the issue was not experienced on it). A symlink defined in the rules
for device is not visible. The investigation has shown that it was created and
then deleted by `udev`.
When the rule of the form `ATTR{idVendor}=="VID", ATTR{idProduct}=="PID",
SYMLINK+="symlink_name-%n", MODE="0666"` is used, the following records apper
in the log
```
Successfully created symlink '/dev/symlink_name-2' to '/dev/bus/usb/XXX/YYY'
...
Removing/updating old device symlink '/dev/symlink_name-2', which is no longer
belonging to this device.
No reference left for '/dev/symlink_name-2', removing
```
Notice the number 2. Why is it using 2, where is 1, there is no `
/dev/symlink_name-1` ? Only one physical device of the same type is connected
to the PC.
The problem has encountered with a USB device emulating a serial port (I
haven't investigated which chip is used internally), but since you likely have
no such device, I have rewritten the rule to be used
against any widespread trash-tier flash drive with the identifier abcd:1234
most of you surely have access to.
The issue reproduces on both udev 252.4-1 from testing/unstable and on the one
from stable 247.3-7+deb11u1
In order to test if the issue is caused by kernel, I have tried udev version
252.4-1 on the 9 kernel images (and the corresponding 6 initrds).
From Debian:
```
linux-image-5.10.0-20-amd64/stable,now 5.10.158-2 amd64 [installed]
linux-image-5.18.0-0.deb11.4-amd64/bullseye-backports,now 5.18.16-1~bpo11+1
amd64 [installed]
linux-image-5.19.0-0.deb11.2-amd64/bullseye-backports,now 5.19.11-1~bpo11+1
amd64 [installed]
linux-image-6.0.0-6-amd64/testing,now 6.0.12-1 amd64 [installed]
```
from Ubuntu:
```
linux-image-5.13.0-35-generic/now 5.13.0-35.40~20.04.1 amd64 [installed,local]
linux-image-5.14.0-1055-oem/now 5.14.0-1055.62 amd64 [installed,local]
linux-image-5.15.0-57-generic/now 5.15.0-57.63 amd64 [installed,local]
linux-image-5.17.0-1003-oem/now 5.17.0-1003.3 amd64 [installed,local]
linux-image-5.19.0-21-generic/now 5.19.0-21.21 amd64 [installed,local]
```
The issue reproduces on all of them (including the ones there was no issue on
when I used to be using Ubuntu).
So it is likely that the issue is in udev or in some of its rules and
not in the hardware or kernel.
1. Here is the udev rule (abcd:1234 are the real IDs exposed by some flash
drives)
```
SUBSYSTEM!="usb_device", ACTION!="add", GOTO="test_rules_end"
ATTR{idVendor}=="abcd", ATTR{idProduct}=="1234", SYMLINK+="test_device-%n",
MODE="0666"
LABEL="test_rules_end"
```
2. here are the commands used to reproduce
```
udevadm control --log-priority=debug
journalctl -f | grep systemd-udevd
```
After typing them the flash drive has been attached, then ctrl+c was hit. Here
is the relevant piece of the log (sensitive info was replaces with `censored`,
irrelevant info, like date and time (except seconds), removed).
```
20: 1-1.2: Device is queued (SEQNUM=2845, ACTION=add)
20: 1-1.2: Device ready for processing (SEQNUM=2845, ACTION=add)
20: Successfully forked off 'n/a' as PID 3710.
20: 1-1.2: Worker [3710] is forked for processing SEQNUM=2845.
20: 1-1.2: Device is queued (SEQNUM=2846, ACTION=bind)
20: 1-1.2: SEQNUM=2846 blocked by SEQNUM=2845
20: 1-1.2: Processing device (SEQNUM=2845, ACTION=add)
20: 1-c.e:n.s: Device is queued (SEQNUM=2847, ACTION=add)
20: 1-c.e:n.s: SEQNUM=2847 blocked by SEQNUM=2845
20: 1-1.2: Removing watch handle -1.
20: scsi_tmf_2: Device is queued (SEQNUM=2848, ACTION=add)
20: scsi_tmf_2: Device ready for processing (SEQNUM=2848, ACTION=add)
20: 1-1.2: /usr/lib/udev/rules.d/10-test.rules:13 MODE 0666
20: 1-1.2: /usr/lib/udev/rules.d/10-test.rules:13 LINK 'test_device'
20: Successfully forked off 'n/a' as PID 3711.
20: scsi_tmf_2: Worker [3711] is forked for processing SEQNUM=2848.
20: 1-1.2: /usr/lib/udev/rules.d/50-udev-default.rules:17 Importing properties
from results of builtin command 'usb_id'
20: host2: Device is queued (SEQNUM=2849, ACTION=add)
20: host2: SEQNUM=2849 blocked by SEQNUM=2845
20: host2: Device is queued (SEQNUM=2850, ACTION=add)
20: host2: SEQNUM=2850 blocked by SEQNUM=2845
20: 1-1.2: /usr/lib/udev/rules.d/50-udev-default.rules:17 Importing properties
from results of builtin command 'hwdb --subsystem=usb'
20: 1-1.2: hwdb modalias key: "usb:vABCDp1234:UDisk "
20: 1-c.e:n.s: Device is queued (SEQNUM=2851, ACTION=bind)
20: scsi_tmf_2: Processing device (SEQNUM=2848, ACTION=add)
20: 1-1.2: /usr/lib/udev/rules.d/50-udev-default.rules:55 MODE 0664
20: 1-c.e:n.s: SEQNUM=2851 blocked by SEQNUM=2845
20: 1-1.2: /usr/lib/udev/rules.d/60-drm.rules:3 Importing properties from
results of builtin command 'path_id'
20: 1-1.2: /usr/lib/udev/rules.d/60-virtualbox.rules:2 RUN
'VBoxCreateUSBNode.sh $major $minor $attr{bDeviceClass} vboxusers'
20: 1-1.2: /usr/lib/udev/rules.d/90-libiio0.rules:1 Running PROGRAM '/bin/sh -c