Repository navigation
Sync with systemd-udev up to a446e8ff2c (v262+) - #300
Merged
Merged
Conversation
The log_*_errno() macros are meant to be used as
return log_error_errno(r, "...: %m");
and code ported from systemd relies on that returning -abs(r) and on
%m printing the passed error. eudev only did so when the message was
filtered out by the log level. When it was actually logged,
log_internal() returned the number of log targets written to (0 or 1)
and %m printed whatever errno happened to be, often "Success".
Callers therefore reported success for failures at the default log
level, e.g. the keyboard builtin could end up using 0 or 1 as the
device file descriptor after a failed open().
Do what systemd does: return -abs(error) in all cases and set errno to
the passed error while formatting the message.
Devices like the "Microsoft Microsoft® 2.4GHz Transceiver v9.0 Mouse" contain characters higher than 127. That ® is correctly stored in the hwdb and passed into the search field during query, but the comparison fails. Our search string is a const char *, trie_string() returns a const char * but the current character is cast to uint8_t. This causes anything over 127 to fail the match. Fix this, we're dealing with characters everywhere here after all. systemd-commit: dc4b6f8d2c84fc1dcbbb250c573ab5902bbf3990
...
uint8_t c;
struct trie_node *child;
for (p = 0; (c = trie->strings->buf[node->prefix_off + p]); p++) {
_cleanup_free_ char *s = NULL;
ssize_t off;
_cleanup_free_ struct trie_node *new_child = NULL;
if (c == search[i + p])
continue;
...
When '®' is present in search, c is 194, search[i + p] is -62, c is not
equal to search[i + p], but c should be equal to search[i + p].
systemd-commit: b53a80966e8a2d68b66bf1b47c2ee633a71fad49
It is not legal to use hard-coded types to calculate offsets. We must always use the offsets of the hwdb header to calculate those. Otherwise, we will break horribly if run on hwdb files written by other implementations or written with future extensions. systemd-commit: 8bf9763656c9209f74cda460225da5a9939494cc
If we find duplicates in a property-lookup, make sure to order them by their origin. That is, matches defined "later" take precedence over earlier matches. The "later"-order is defined by file-priority + line-number combination. That is, if a match is defined below another one in the same hwdb file, it takes precedence, same as if it is defined in a file ordered after another one. To do this, extend the hwdb to store the source file-name, file-priority and line-number for each property. We simply extend the stored value struct with the new information (trie_value_entry2_f, as used by systemd-hwdb since systemd 233). It is backwards compatible and readers which honour value_entry_size will continue to work. We cannot compare filenames directly, because paths are not sortable lexicographically, e.g. /etc/udev is "later" (has higher priority) than /usr/lib/udev. The on-disk format therefore has a separate field for "file priority", which is stored when writing the binary file, and then loaded and used in comparisons. For data in the previous v2 format (as generated by systemd 232), this information is not available, and the offset into the string table is used as a proxy for priority. Without this, which of the duplicate properties won depended on the order in which the trie was walked, e.g. the generic Acer KEYBOARD_KEY_ee= brightnessup mapping in 60-keyboard.hwdb overrode the model specific screenlock mapping for "svnAcer*:pn*5210*". eudev's libudev keeps the properties in a udev_list, so the offset of the value entry is remembered in the list entry number to be able to compare the origin of duplicates. systemd-commit: 698c5a176ead078e7c86c541be714ccb464dae95 systemd-commit: 3a04b789c6f17dff2000a3cdbeaaf86baa604524 systemd-commit: 389be927b485ceb7351963986232fb6975860680 systemd-commit: d8646d05724a658cc60fb03f105db8ead454eba3
TAG==, TAGS== and SYMLINK== compared each device tag or symlink with the pattern. TAG and TAGS used a plain string comparison, so neither shell glob patterns nor alternatives separated by '|' worked for them, e.g. TAG=="uaccess|xaccess-*" as used by the systemd seat rules never matched. For the '!=' operator, TAG!= did not reject a device with a matching tag, and SYMLINK!= succeeded as soon as any symlink did not match, instead of only if no symlink matched. Match every tag and symlink with the same pattern matching as the other match keys, and make the '!=' operator return true only if no tag or symlink matched. While at it, fix TAGS== to use the value of its own token, rather than of the first token of the parent match sequence. Based on the following upstream commits: - "Support OP_NOMATCH for TAG key" - "udev: modernize udev-rules.c" (TAG/TAGS glob and alternatives) - "udev-rules: fix negative match rule for SYMLINK and TAG" systemd-commit: 4302857b31a8e89ddeba0921fee06a1ff0237996 systemd-commit: 25de7aa7b90c23d33ea50ada1e50c5834a414237 systemd-commit: 2b43ab00b08a052fc0077dd20f111c474730ad52
…n OPTIONS="string_escape=replace" is set
Strictly speaking, this breaks backward compatibility, as previously
`ENV{key}="val"` ignored `string_escape=` option. But, introducing
a new option such as `string_escape=hoge` sounds overkill for me.
The default escape mode is `ESCAPE_UNSET`, so I hope this merely break
existing rules.
This is used by the nvme rules in 60-persistent-storage.rules, which
set ENV{ID_SERIAL} with OPTIONS="string_escape=replace".
Also update the description of "string_escape=" in the man page.
systemd-commit: ea0f4578a7e90f5227817058bfb11bb91dbb1431
systemd-commit: 91c27ac686261fcca913ac6e3fe1520f38440dcb
Let's use proc_cmdline_get_key() instead of some strstr() logic to find
a kernel command line key. Using strstr() gets confused by similarly
named keys, and we should reuse our own code as much as we can anyway...
E.g. IMPORT{cmdline}="nomodeset" (as used by 71-seat.rules) also matched
"radeon.nomodeset" or "i915.nomodeset".
eudev does not have proc_cmdline_get_key() in its shared code, hence a
minimal version of it, built on proc_cmdline() and unquote_first_word(),
is added to udev-rules.c. As with parse_proc_cmdline(), arguments
starting with "rd." are ignored when not running in the initrd.
systemd-commit: 88b013b26d91bf48cbeda47165a5c107083a00e7
For some (corner) cases, it might be desirable to disable the generation of
some persistent storage symlinks that 60-persistent-storage.rules creates.
For example on big setups with a high number of partitions which uses the same
label name, this can result in a noticeable slow-down in the (re)start of the
udevd as there are many contenders for the symlink /dev/disk/by-partlabel.
However it's currently pretty hard to overwrite just some specific part of the
rule file. Indeed one need to copy and modify the whole rule file in /etc but
will lost any upcoming updates/fixes that the distro might release in the
future.
With this simple patch, one can now disable the generation of the
"by-partlabel" symlinks (for example) with the following single rule:
$ cat /etc/udev/rules.d/99-no-by-partlabel.rules
ENV{ID_PART_ENTRY_NAME}=="?*", SYMLINK-="disk/by-partlabel/$env{ID_PART_ENTRY_NAME}"
systemd-commit: aeefa4d248279a259cdf53036e4bd4ff5dfa1525
* Existing valid rule files written with KEY="value" are not affected * Now, KEY=e"value\n" becomes valid. Where `\n` is a newline character * Escape sequences supported by cunescape() are supported The unescaping is done by cunescape_length(), which is added to the shared utility code on top of the existing cunescape_one(). Also document the escaped string syntax in udev(7). systemd-commit: aea3253e7121ecc91754d1d39cd7842a621f55bc systemd-commit: bc117ec35957f698db4d92bc670605e04f85ccf4
This introduces 'i' prefix for match string. When specified, string or
pattern will match case-insensitively.
The prefix can be combined with the 'e' prefix for escaped strings, and
can be used only for match ('==') or unmatch ('!=') rules. It is refused
for PROGRAM, IMPORT and TEST.
Upstream co-author: Ryan Wilson <ryantimwilson@meta.com>
systemd-commit: 5f5c5c48b9edd3f2aa634d0d8e40ff77e116879e
The value of RUN= was formatted only when the programs were executed
after all rules had been processed, hence substitutions like $env{KEY}
used the value at the end of the rule processing instead of the value at
the time the rule was applied.
Format the value when the rule is applied, as other keys do.
systemd-commit: 1448820aadd138882232f169157de133a8f407b0
udev_build_argv() splits a command line into an argv array of fixed size
(128 entries) provided by the callers, udev_event_spawn() and
udev_builtin_run(), without any bounds check. A command with more
arguments, e.g. PROGRAM= or IMPORT{program}= with substituted values
containing many spaces, overflowed the array on the stack.
Upstream fixed this by replacing udev_build_argv() with strv_split_full(),
which allocates the argument array dynamically. As eudev still uses
udev_build_argv(), stop splitting when the array is full, and ignore the
remaining arguments.
systemd-commit: feaa6db7ac287b34887f75c27a7efc2107a7b691
The formatted command lines of PROGRAM=, IMPORT{program}= and RUN= were
truncated at 1024 characters. Use the line size (16k) for them, as well
as for the copy that is split into the argument array when spawning the
program.
The command line of built-in commands is still limited by the built-in
command dispatcher.
systemd-commit: c3613ee51e3aff61dfea22501c48d19c20cb7b71
systemd-commit: 4f985bd80278972912b80df1390f84d7a89f8d51
Since "udev-rules: evaluate formatting in RUN= key earlier", the substitutions in RUN= values are performed while the rule is processed, like for all other keys, and no longer right before the program is executed. Update udev(7) accordingly (the upstream man page still has the stale description). systemd-commit: 1448820aadd138882232f169157de133a8f407b0
…y used by udevd Refuse rules which try to set properties that are set by the kernel or internally used by udevd, e.g. SEQNUM, MODALIAS, DEVMODE, DISKSEQ, INTERFACE, USEC_INITIALIZED, or SYNTH_ARG_*, as upstream does. systemd-commit: 7a2093236b58da9c7b2e8b0ff59f22a6c9843236 systemd-commit: 1707b41e7648dc2f43bf53f52112cc7092b988c6
A message shorter than the wire structure (or a truncated one) was processed, e.g. with a string that is not NUL terminated for UDEV_CTRL_SET_ENV. Ignore such messages. systemd-commit: 3ad7f7902354e8e05ea315fb51688b8fcf00305d
This is especially for the case that the path contains "..". Such a path may be the result of substitutions of values which are controlled by the device, and could be used to create or replace symlinks outside of /dev. This also makes SYMLINK= gracefully handle paths prefixed with "/dev/". Upstream does the check in sd-device's device_add_devlink(), which eudev does not have; do it when applying SYMLINK= in the rules instead. systemd-commit: 2c5f119c3cc78bd7da0c7c56b57eca43bac464c1
All tags are managed under /run/udev/tags, and the directories there are named with tags. Hence, each tag must be a valid filename. This also makes all validity check moved to libudev side, and makes failure caused by setting invalid tags non-critical. Previously, the rules only logged an error about an invalid tag name, but still added it, e.g. TAG+="../foo" created the tag index outside of /run/udev/tags. With this change, an empty string cannot be assigned to TAG=. systemd-commit: 0b4c70b47a6dea1841a3be5c132d562d71efe182
… the same device node
This combines several upstream fixes for the detection of events which
must not be processed in parallel:
- "udevd: always block follwoing events with same devpath"
Originally commented as "devices names might have changed/swapped in
the meantime", but may not. For safety, let's block the following
events with same devpath.
- "udevd: save the result of devnum or ifindex blocker"
- "udev: make newer event also blocked by DEVPATH_OLD"
Previously, a device has DEVPATH_OLD is blocked by a previous event
whose devpath is equivalent to the DEVPATH_OLD. This extends the
condition:
1. an event has DEVPATH_OLD is blocked by a previous event whose
devpath is a parent of, child of, or equivalent to the DEVPATH_OLD.
2. an event is blocked by a previous event whose DEVPATH_OLD is a
parent of, child of, or equivalent to the devpath of the new event.
- "udev: also make uevent blocked by events for the same device node"
Even if the device node is the same, devnum and syspath may be
different. If a 'remove' and 'add' events for the same device node but
with different devnum and syspath are queued, previously, we might
process them in parallel. And, udev_watch_end() for the 'remove' event
and udev_watch_begin() for the 'add' event may interfere each other.
systemd-commit: baa461fc05934d02ece3abd7666c144549c695cf
systemd-commit: 8671411668e9b15bc3dadcb4e48ff43f6a8461d3
systemd-commit: a1af9668ec78fc11a2e7ac942397eac0c8fceced
systemd-commit: 34458dbbe795c20442f6262875c74a679c5957e0
An invalid udev.log-priority= on the kernel command line made util_log_priority() return a negative error, which was passed to log_set_max_level() and triggered its assertion. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1245293 systemd-commit: e00f5bddde0daff900cbd93e1ee0530ad1ae06ce
If worker is running, kill worker may lead uevent unprocessed. Workers are killed e.g. on reload of the rules, or when the log level or a global property is changed via "udevadm control". Mark running workers and kill them only after they have finished processing their event. On exit, all workers are still killed immediately. systemd-commit: f257a8fc13b2a617d845132eb61aefde47921198
Some udev rule may erroneously set inotify watch on remove event. For safety, silently ignore such an inotify watch enablement. Otherwise, the database of the removed device was written again after it had been deleted. Also do not try to watch devices without a device node. systemd-commit: 0d77bc4a18efa21022fe90cf8d6051a7b5b039f3
…/watch Previously, watch handle is saved in the udev database. But in most cases, the handle saved in the database is not updated. Especially, when udevd is restarted, the inotify watch is restarted, but the database is not updated. Then, udev_watch_end() removed the inotify watch and the symlink of a handle which may be owned by another device, and that device lost its watch. Moreover, it is not necessary to save watch handle in the database, as the handle is only take a effect during udevd is running, and the value is meaningless when udevd is restarted. So, this makes the opposite map from device ID to watch handle is saved in /run/udev/watch as a symbolic link, and the handle not saved in the database anymore. Before removing symlinks that stores watch handles, check if the symlink is owned by the processing device, to avoid TOCTOU. IN_IGNORED is not handled by the main process anymore. It should be handled by worker in 'remove' uevent. Also make udev_watch_end() noop when device does not have devname, and do not try to remove an invalid watch handle. systemd-commit: e7f781e473f5119bf9246208a6de9f6b76a39c5d systemd-commit: 691a596da15cb4171a86c5f95b30ad5ba91b6745 systemd-commit: 5e0d05106747d2ee25ce19a51ed8a5669ea93bf9 systemd-commit: b3b442062045eac61a9dd3ed73b650dfb5be0b46
devices with the db_persist property won't be deleted during database cleanup. This applies to dm and md devices in particular. For such devices, we should also keep the files under /run/udev/links, /run/udev/tags, and /run/udev/watch, to make sure that after restart, udevd has the same information about the devices as it did before the cleanup. If we don't do this, a lower-priority device that is discovered in the coldplug phase may take over symlinks from a device that persisted. Not removing the watches also enables udevd to resume watching a device after restart. Also, do not remove /run/udev/watch at all. It will be handled by udevd well on restart, and should not be removed by external program when udevd is running. systemd-commit: 7ec624147a41d80f8e492c9fe19a24e2cda58c25 systemd-commit: bd97980193a32c4b87c64dd4a041d25c7f841d5e
…am result
When the output of IMPORT{program} is too long and truncated, the last
line of the result is incomplete. Drop it, instead of importing a
property with a truncated value.
systemd-commit: 6b6e471a325bf149839c5c822b4ae3e66cb1d9a3
systemd-commit: 9095da896fc1bdd86b5b749d71bd2aebc585e236
It is possible to specify only one quote in udev.conf or in imported
properties, which is not detected as an invalid quoting (" instead of ""
for empty string).
Technically this doesn't lead to a bug, because the string ends in two
terminating nul characters at this position, but a user should still be
reminded that his configuration is invalid.
systemd-commit: cd05bb8bafa808f0a40feaaa0e8cc564c0f203a7
…erencing Fixes a family of OOB reads in the trie walker where offsets are loaded from a (possibly corrupted or hostile) hwdb.bin and added to hwdb->map without first checking that the resulting pointer stays inside the mapping: - node offsets, including the arrays of children and values appended to each node, are checked to be within the file, - strings are checked to be within the file and NUL terminated, - the prefix position used by trie_fnmatch_f() is checked, - the recursion depth of trie_fnmatch_f() is capped, so that cyclic children offsets cannot exhaust the stack, - an overlong fnmatch key is rejected, instead of passing NULL to fnmatch(). A corrupted hwdb.bin now makes the lookup fail with EBADMSG, instead of crashing the process. systemd-commit: b45a897edc1a11b8cf2f876f00dbb73f82fe5b6a systemd-commit: 73fea38cf1344e08213bb10bfc1e1a98382aee78 systemd-commit: 3db89cbf0e27e3ef38a060c3c765367a700ad7f7
The tag-match loop emits 6 instructions per tag into a fixed 512-entry stack array without a bounds check (unlike the subsystem loop below, which only checks after the instructions were written), so enough tags overflow the stack. Refuse with -E2BIG instead. Also refuse jump offsets which do not fit into the 8 bit jt/jf fields of struct sock_filter, which happened with more than 42 tags, and made the filter branch to the wrong instruction. systemd-commit: 2f72db10d9a0cdf3c1b22044df44c2e9fd61ff1b
xHCI host controller may register two (or more?) USB root hubs for USB 2.0 and USB 3.0, and devices under the hubs may have same ID_PATH. So, to avoid the conflict, let's introduce ID_PATH_WITH_USB_REVISION that includes the USB revision. Closes #19406. [eudev: only the path_id part; the corresponding rules changes are synced separately.] systemd-commit: 873be895ed1fe65010fb84c6b71e2ec0a6b6fc91
Prompted by #27391. systemd-commit: 39a39f18f2bd2b1ef7b4fa4823472d129c514030
Some kernel SAS drivers (e.g. smartpqi) expose ports with num_phys = 0. udev shouldn't treat these ports as wide ports. SAS wide ports always have num_phys > 1. See comments for sas_port_add_phy() in the kernel sources. Sample data from a smartpqi system to illustrate the issue below. Here the phy device is attached to port 0:0, which has no end devices attached and the SAS end device (where sda is attached) is associated with SAS port 0:1, which has no associated phy device. Thus num_phys for port-0:1 is 0. This is arguably wrong, but it's how smartpqi has always set up its devices in sysfs. /sys/class/sas_phy/phy-0:0 -> ../../devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/phy-0:0/sas_phy/phy-0:0 /sys/devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/port-0:0/phy-0:0 -> ../phy-0:0 /sys/devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/phy-0:0/port -> ../port-0:0 /sys/class/sas_device/end_device-0:1 -> ../../devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/port-0:1/end_device-0:1/sas_device/end_device-0:1 /sys/class/block/sda -> ../../devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/port-0:1/end_device-0:1/target0:0:0/0:0:0:0/block/sda Signed-off-by: Martin Wilck <mwilck@suse.com> systemd-commit: 7f6674624eedc95db2a9877edc6ff424f4453531
This cannot actually happen, but add a safety check nonetheless. Reported on yeswehack.com as: YWH-PGM9780-43 Follow-up for d7867b3 [eudev: here the composed path is not length limited, so a path longer than UTIL_NAME_SIZE could actually overflow the tag buffer.] systemd-commit: 45a200cd751fae382f4145760cf84fd181db1319
Some drivers expose sub-functions (SFs) of a PCI Physical or Virtual Function as auxiliary devices that carry a stable 'sfnum' sysfs attribute — the user-defined sub-function number (e.g. the value passed to "devlink port add ... sfnum N"). The SF's leaf devices (uverbs, infiniband, net, ...) sit below this aux device in sysfs: /sys/devices/.../<PF or VF BDF>/<sf aux>/.../<leaf> Currently path_id walks straight past the aux device, so all leaf devices below an SF end up sharing ID_PATH=pci-<BDF> with their parent PF or VF. For uverbs this causes a /dev/infiniband/by-path/ symlink collision, and for any other consumer of ID_PATH/ID_PATH_TAG it makes PF and SF (or VF and VF-SF) indistinguishable. Recognise the 'auxiliary' subsystem in path_id's walk: when the aux device exposes 'sfnum', prepend an 'sf-<N>' token; otherwise leave it untokenised. The result for an SF whose parent PF is at PCI 0000:c1:00.0 and which was added with "sfnum 88" is: ID_PATH=pci-0000:c1:00.0-sf-88 ID_PATH_TAG=pci-0000_c1_00_0-sf-88 This is parallel to how net_id's NAMING_SUBFUNC scheme appends 'S<N>' on top of the PF base name. Aux devices without 'sfnum' keep the pre-patch behaviour: the walk skips over them with no token. Existing ID_PATH values for PF and VF leaf devices are therefore unchanged, the change is purely additive, and there is no need to gate it behind a naming scheme (path_id itself is unversioned). systemd-commit: 477f84cf9191c0b5a139786de0c569bb918d0286
PNP devices may represent ACPI-enumerated hardware but do not have a parent type supported by path_id. Consequently, importing path_id fails even when the PNP device exposes a stable ACPI firmware_node. This also prevents later assignments in rules such as the systemd-backlight activation rule from taking effect. Resolve the PNP device's firmware_node and use its ACPI sysname for the path component. This gives PNP-backed devices the same stable identity as their firmware representation. [eudev: the upstream regression test is not ported. The firmware_node symlink is resolved with realpath(), as libudev does not resolve it.] systemd-commit: 6044c31038a2c24294f29df40a0cae9c19cc5e9b
Let's in particular log an even if a device name is too long for the btrfs ioctl structure, instead of truncating it (which could theoretically reference a different device). systemd-commit: eee056443bf1855b3dff0156bcbd2dc1913fd898
…n in test mode [eudev: test mode means 'udevadm test-builtin' here.] systemd-commit: 73a2912092c8749237932720bbd300486b9a783d
If btrfs builtin command is called, then check if the specified device node is owned by the device. This also allows the command is called specifying any device node. systemd-commit: 6cfb5866fef7e7e6dccef9f9a886aec2863f65a0
Currently the ID_NET_DRIVER is set in net_setup_link builtin. But this is called pretty late in the udev processing chain. Right now in some custom rules it was workarounded by calling ethtool binary directly, which is ugly. So let's split this code to a separate builtin. This also includes the follow-up "udev-builtin-net_driver: use correct interface name", which uses the INTERFACE property instead of the sysname, as '!' in the latter is replaced by '/'. [eudev: eudev has neither net_setup_link nor the ethtool helpers, so the builtin carries a minimal ETHTOOL_GDRVINFO query itself. The 50-udev-default.rules change is synced separately.] systemd-commit: 2b5b25f123ceb89b3ff45b2380db1c8a88b046d9 systemd-commit: e3bc8d3449d5b7259556227526c4ba58ecf7feef
This fixes CID#1292782. systemd-commit: e448a1c3a3eac4d73261bf8648110fc9f7aae806
Use the _cleanup_blkid_free_probe_ to guarantee that the blkid_probe will be freed when builtin_blkid exits. [eudev: previously the probe was leaked on all error paths. eudev has no blkid-util.h, hence the cleanup helper is defined locally.] systemd-commit: a1bb2402cb6edc4b46f6bf2bc3ed2773bb213919
Running "udevadm test-builtin path_id /sys/devices/platform/" results in a segmentation fault. The problem is that udev_device_get_subsystem(dev) might return NULL in a streq() call. Solve this problem by using streq_ptr() instead. systemd-commit: 5181ab917d6407cb57043e98955f0de1614366ea
/dev/disk/by-path total 0 lrwxrwxrwx. 1 root root 9 Sep 4 10:02 pci-0000:00:1f.2-ata-2 -> ../../sr0 lrwxrwxrwx. 1 root root 9 Sep 4 10:02 pci-0000:00:1f.2-ata-3 -> ../../sdd lrwxrwxrwx. 1 root root 10 Sep 4 10:02 pci-0000:00:1f.2-ata-3-part1 -> ../../sdd1 lrwxrwxrwx. 1 root root 10 Sep 4 10:02 pci-0000:00:1f.2-ata-3-part2 -> ../../sdd2 lrwxrwxrwx. 1 root root 10 Sep 4 10:02 pci-0000:00:1f.2-ata-3-part3 -> ../../sdd3 lrwxrwxrwx. 1 root root 9 Sep 4 10:02 pci-0000:03:00.0-ata-4 -> ../../sda lrwxrwxrwx. 1 root root 10 Sep 4 10:02 pci-0000:03:00.0-ata-4-part1 -> ../../sda1 lrwxrwxrwx. 1 root root 10 Sep 4 10:02 pci-0000:03:00.0-ata-4-part2 -> ../../sda2 lrwxrwxrwx. 1 root root 9 Sep 4 10:02 pci-0000:08:00.0-ata-1 -> ../../sdc lrwxrwxrwx. 1 root root 10 Sep 4 10:02 pci-0000:08:00.0-ata-1-part1 -> ../../sdc1 lrwxrwxrwx. 1 root root 10 Sep 4 10:02 pci-0000:08:00.0-ata-1-part2 -> ../../sdc2 systemd-commit: ba86822db70d9ffd02ad78cd02b237ff8c569c7a
ATA devices should use the ATA ids like port number and (possibly) master/slave or multiplier id, not the generic SCSI ID. Currently only port number is included in the link. With this patch the link would be able to support more cases, which are a) when the device is behind a port multiplexer b) the distinction between master and slave (distinguished by target id). I tried to verify scenario a) with this patch, but I failed to find a machine with PMP SATA devices attached. But the link below systemd/systemd#3943 could show what's the difference. Here is my test for scenario b) Current version: linux-ql21:~ # ll /sys/class/block/sd[ab] lrwxrwxrwx 1 root root 0 May 8 20:46 /sys/class/block/sda -> ../../devices/pci0000:00/0000:00:01.1/ata4/host3/target3:0:0/3:0:0:0/block/sda lrwxrwxrwx 1 root root 0 May 8 20:46 /sys/class/block/sdb -> ../../devices/pci0000:00/0000:00:01.1/ata4/host3/target3:0:1/3:0:1:0/block/sdb linux-ql21:~ # ll /dev/disk/by-path/pci-0000\:00\:01.1-ata-1 lrwxrwxrwx 1 root root 9 May 8 20:44 /dev/disk/by-path/pci-0000:00:01.1-ata-1 -> ../../sdb linux-ql21:~ # udevadm info /sys/class/block/sda |grep by-path S: disk/by-path/pci-0000:00:01.1-ata-1 E: DEVLINKS=/dev/disk/by-id/ata-VBOX_HARDDISK_VB3649e885-3e0cdd64 /dev/disk/by-id/scsi-0ATA_VBOX_HARDDISK_VB3649e885-3e0cdd64 /dev/disk/by-id/scsi-1ATA_VBOX_HARDDISK_VB3649e885-3e0cdd64 /dev/disk/by-path/pci-0000:00:01.1-ata-1 /dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VB3649e885-3e0cdd64 linux-ql21:~ # udevadm info /sys/class/block/sdb |grep by-path S: disk/by-path/pci-0000:00:01.1-ata-1 E: DEVLINKS=/dev/disk/by-id/ata-VBOX_HARDDISK_VBc53b2498-d84ae8de /dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VBc53b2498-d84ae8de /dev/disk/by-id/scsi-1ATA_VBOX_HARDDISK_VBc53b2498-d84ae8de /dev/disk/by-id/scsi-0ATA_VBOX_HARDDISK_VBc53b2498-d84ae8de /dev/disk/by-path/pci-0000:00:01.1-ata-1 After patch applied: linux-ql21:~ # ll /sys/class/block/sd[ab] lrwxrwxrwx 1 root root 0 May 8 21:07 /sys/class/block/sda -> ../../devices/pci0000:00/0000:00:01.1/ata4/host3/target3:0:0/3:0:0:0/block/sda lrwxrwxrwx 1 root root 0 May 8 21:07 /sys/class/block/sdb -> ../../devices/pci0000:00/0000:00:01.1/ata4/host3/target3:0:1/3:0:1:0/block/sdb linux-ql21:~ # ll /dev/disk/by-path/pci-0000\:00\:01.1-ata-* lrwxrwxrwx 1 root root 9 May 8 21:07 /dev/disk/by-path/pci-0000:00:01.1-ata-1.0 -> ../../sda lrwxrwxrwx 1 root root 9 May 8 21:07 /dev/disk/by-path/pci-0000:00:01.1-ata-1.1 -> ../../sdb linux-ql21:~ # udevadm info /sys/class/block/sda |grep by-path S: disk/by-path/pci-0000:00:01.1-ata-1.0 E: DEVLINKS=/dev/disk/by-id/scsi-1ATA_VBOX_HARDDISK_VB3649e885-3e0cdd64 /dev/disk/by-id/scsi-0ATA_VBOX_HARDDISK_VB3649e885-3e0cdd64 /dev/disk/by-id/ata-VBOX_HARDDISK_VB3649e885-3e0cdd64 /dev/disk/by-path/pci-0000:00:01.1-ata-1.0 /dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VB3649e885-3e0cdd64 linux-ql21:~ # udevadm info /sys/class/block/sdb |grep by-path S: disk/by-path/pci-0000:00:01.1-ata-1.1 E: DEVLINKS=/dev/disk/by-id/scsi-0ATA_VBOX_HARDDISK_VBc53b2498-d84ae8de /dev/disk/by-id/ata-VBOX_HARDDISK_VBc53b2498-d84ae8de /dev/disk/by-id/scsi-1ATA_VBOX_HARDDISK_VBc53b2498-d84ae8de /dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VBc53b2498-d84ae8de /dev/disk/by-path/pci-0000:00:01.1-ata-1.1 Changelog: v5: add another parameter compat_link in handle_scsi() v4: comment for ID_PATH_ATA_COMPAT get string length with pointer difference (suggested by Franck Bui<fbui@suse.com>) v3: creating compatible link from env variables type change v2: remove udev rules modification for compatible link setup a test scenario of master/slave ATA devices v1: initial patch systemd-commit: 9b3278d90704416bfe51a05d5681caf99445fb2f
The builtin path id for virtio block devices has been changed to use the bus id without a prefix "virtio-pci" to be compatible with all virtio transport types. In order to not break existing setups, the by-path symlinks for virtio block devices on the PCI bus are reintroduced by udev rules. The virtio-pci symlinks are considered to be deprecated and should be replaced by the native PCI symlinks. Example output for a virtio disk in PCI slot 7: $ ls /dev/disk/by-path pci-0000:00:07.0 pci-0000:00:07.0-part1 virtio-pci-0000:00:07.0 virtio-pci-0000:00:07.0-part1 See also [1] https://lists.freedesktop.org/archives/systemd-devel/2017-February/038326.html [2] https://lists.freedesktop.org/archives/systemd-devel/2017-March/038397.html This reverts f073b1b but keeps the same symlinks for compatibility. [eudev: eudev never had f073b1b ("path_id: reintroduce by-path links for virtio block devices"), so this directly adds the final form. The legacy virtio-pci by-path rules are already in 60-persistent-storage.rules, but had no effect as ID_PATH was never set for virtio block devices.] systemd-commit: fb92fbb1b171ef94207a1ebc111ef0e414d49b4c systemd-commit: f073b1b3c0f4f0df1b0bd61042ce85fb5d27d407
Since the port of systemd commit 7f6674624eedc95db2a9877edc6ff424f4453531
("udev-builtin-path_id: SAS wide ports must have num_phys > 1"), SAS ports
reporting num_phys=0 (e.g. smartpqi) are no longer treated as wide ports,
and a num_phys value that cannot be parsed results in no ID_PATH. This
changes the by-path names of disks behind such ports from
sas-<0xADDRESS>-lun-<N> to sas-phy<PHY>-lun-<N> or
sas-exp<0xADDRESS>-phy<PHY>-lun-<N>.
Keep the new naming as the default, but allow restoring the previous
eudev naming with "sas_legacy_path=yes" in udev.conf: then every port
with num_phys other than 1, including 0 and unparsable values, is handled
as a wide port again.
The option is parsed by udev_new() and made available to the builtin via
the private udev_get_sas_legacy_path(); it is not part of the public
libudev API.
The USB revision detection added for ID_PATH_WITH_USB_REVISION uses the USB_HUB_PR_* hub protocol values from <linux/usb/ch11.h>. Define them when the kernel headers do not, so that builds with older kernel headers keep working. The values are fixed by the USB specification.
Pass the remaining buffer size to strpcpyl() when appending the USB configuration and interface numbers, instead of the full size of usb_ports[]. Otherwise a long USB port chain may write past the end of the buffer. systemd-commit: 5660e68d651545b43e13a51b068e64022637a6c6
…ernel The PCI onboard 'label' attribute comes from firmware. Refuse it when it is not valid UTF-8 or contains control characters, instead of exporting it in ID_NET_LABEL_ONBOARD. eudev does not use phys_port_name, so only the label check applies here. utf8_is_printable_newline() is used in place of utf8_is_valid() and string_has_cc(). systemd-commit: 16325b35fa6ecb25f66534a562583ce3b96d52f3
When vsnprintf() truncated output, dest was advanced by the entire size of dest leaving it just past the end. Then the fall-through \0 termination scribbled one past the end. The explicit null termination is not necessary since vsnprintf() always includes the terminator even when truncated. Additionally these functions encourage calling with zero-length sizes, while assuming non-zero sizes with potential buffer overflows. Simply short-circuit the relevant functions when size == 0. Fixes systemd/systemd#6252 systemd-commit: 9e5bd85a5fc5d80cc8706d2b8bac520f2c6a8149
When udev_device_new_from_syspath() fails, report errno instead of the uninitialized r.
udev_build_argv() bounds the number of arguments by UDEV_ARGV_MAX, so use the same constant for the array that udev_builtin_run() passes to it instead of a separate literal.
Merge up to commit a446e8ff2ccb76a8719cb5f06a7fcf785dc116e2
- keep eudev's local choices: video group and mode 0666 for render and
kfd nodes (and now accel), mode 0620 for ttys, {{ROOTBINDIR}} in
64-btrfs.rules.in
- do not assign the 'clock' group (created by systemd-sysusers) to rtc
and ptp devices
- do not import path_id for all pci/usb/platform devices, that line only
keeps compatibility with a systemd regression eudev never had
- drop the HAVE_BLKID jinja conditional from 60-persistent-storage.rules,
the whole file is only installed with blkid support
- drop TAG+="systemd" from 60-dmi-id.rules
- add
60-dmi-id.rules (moved out of 50-udev-default.rules)
60-gpiochip.rules
60-infiniband.rules
60-persistent-hidraw.rules
60-persistent-media-controller.rules
65-integration.rules
- skip rules only relevant to systemd components
60-tpm2-id.rules, 70-power-switch.rules, 70-uaccess.rules,
71-seat.rules, 73-seat-late.rules, 80-net-setup-link.rules,
81-net-bridge.rules, 82-net-auto-link-local.rules,
90-image-dissect.rules, 90-iocost.rules, 90-vconsole.rules,
99-systemd.rules
The Response Code is contained in the first byte of the SCSI Sense Data. Bit number 7 is reserved or has a different meaning for some Response Codes and is set to 1 for some drives. systemd-commit: 2be1ae54badf7a3a12908a8094ebaba8f91887ca
If the peripheral device type is that of a host managed zone block device (0x14), the device supports the same identification mechanisms as conventional disks (0x00). (This predates the last eudev sync point but was never picked up; it is a prerequisite for exporting ID_ATA_PERIPHERAL_DEVICE_TYPE for ZAC devices.) systemd-commit: 06654d1225157ef2031559e47109730111514be2
…erved for it (#30459) Export ID_ATA_PERIPHERAL_DEVICE_TYPE, so that the rules can create the disk/by-id/scsi-* symlink for ZAC (host-managed zoned, type 0x14) disks. (The rules part of the upstream commit is not included here.) Co-authored-by: wangyuhang <wangyuhang27@huawei.com> systemd-commit: 8a86e15f07dd7030bfc31fb4944c24fb9a481fc5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This brings eudev in sync with systemd main at commit a446e8ff2ccb76a8719cb5f06a7fcf785dc116e2 (2026-09-25, after v262). The previous sync point was 5674b74c4f99e433fd8e7242e9f16f6ddfece94c (2022-04-06, before v251).
Only pertinent changes are included: the hardware database, the rules, fixes and features of the builtins and helper programs, and the parts of the udev core, udevadm and libudev that eudev needs to handle current rules and hwdb files. systemd-internal refactors, the sd-device/sd-event rework and systemd-only functionality are left out.
Every port names its upstream commit(s) in a
systemd-commit:trailer and keeps the upstream author. eudev specific adaptations are described in the commit messages.Commit layout
log: return the negative error from log_*_errno() and map %m to itMerge hwdb from systemdMerge suitable rules changes from systemdEvery commit builds on its own, so the branch stays bisectable.
Part 9 comes deliberately after the rules merge. The ata_id changes alter ID_SERIAL/ID_BUS for some disks, and the rules that keep the existing by-id links (the
usb-$ID_USB_SERIALand ZACscsi-links) must be in place first. Upstream shipped these in the opposite order, which caused systemd issue #25179. Following upstream, each of those rules lines is carried in the same commit as the code that needs it.User-visible changes
Changed /dev/disk/by-path names
num_phys=0, e.g. HPE Smart Array controllers driven by smartpqi, change fromsas-0x<ADDRESS>-lun-<N>tosas-phy<PHY>-lun-<N>(orsas-exp0x<ADDRESS>-phy<PHY>-lun-<N>behind an expander), as in systemd. The newsas_legacy_path=yeskey in udev.conf restores the old names.New links
No existing link is removed.
ata-<PORT>.<DEVICE>, plus theata-<PORT>name that systemd also keeps.ID_PATH_WITH_USB_REVISIONvariants.ID_USB_*properties from usb_id).hwdb
hwdb_format=key in udev.conf:1, keeps the format every libudev can read, which is what upstreamudevadm hwdbwrites too.2stores the origin of every property, so that later files and lines win, as withsystemd-hwdb. That also lets local overrides in /etc/udev/hwdb.d win reliably.--root, the key is read from the udev.conf under the root.udevadm hwdb --strictis now accepted (as upstream), and the source file names stored in hwdb.bin no longer contain the--rootprefix.IMPORT{builtin}. Userevdev:name:*overrides are therefore no longer shadowed by an earlier generic match.Rules syntax and semantics
TAG==/TAGS==accept patterns and|alternatives.SYMLINK-=removes a link.e"..."escaped strings andi"..."case-insensitive matches.SECLABELvalues are substituted.RUNvalues are expanded when the rule is processed, not when the program starts.ENV{}assignments to kernel- or udevd-owned properties (MODALIAS, SEQNUM, DEVPATH, ...) are refused...or other invalid paths, and tags that are not valid file names, are rejected with an error.OPTIONS="string_escape=replace"also applies toENV{}assignments.IMPORT{cmdline}matches whole words, with-and_treated as equal; explicitrd.*keys keep matching outside the initrd.IMPORT{program}output is dropped.Programs and builtins
--allowlisted/--denylisted;--whitelisted/--blacklistedstill work, including in scsi_id.config;ID_ATA_PERIPHERAL_DEVICE_TYPE;lseek()fix;--hint=support, filesystem info tags, and a probe leak fix.kmod loadwithout arguments loads$MODALIAS.net_driverbuiltin: setsID_NET_DRIVER.udevd, udevadm and libudev
set_sysattr_value()handles write-only attributes and now returns -ENOENT for missing attributes, as upstream does;/↔!translation fix;udevadm info --cleanup-dbkeeps the links and tags ofdb_persistdevices.log_*_errno(): it returned 0 or 1 instead of the negative error whenever the message was actually logged, and%mprinted "Success". Code relying onreturn log_error_errno(r, ...), both existing and ported, reported success for failures at the default log level.eudev specific choices kept
videowith mode 0666; the newaccelsubsystem gets the same;{{ROOTBINDIR}}stays.clockgroup, which only systemd-sysusers creates.Deliberately not synced
end*/wld*),enu*names for non-PCI USB hosts,firmware_node/sunslot names, SR-IOV representors, MCTP, sub-functions andID_NET_NAME_INCLUDE_DOMAIN. eudev has nonet.naming_schemegate, so each of these would rename existing interfaces on upgrade. Only buffer-overflow and label-validation fixes are included; interface names are unchanged (verified on real and synthetic devices).MAX_SERIAL_LEN256→512 (3c586354aae6): it can pick a VPD descriptor that yields an ID_SERIAL longer than a file name, and the existing by-id link would be lost.CURRENT_TAGS);CONST{arch,virt,cvm};OPTIONS="log_level=|dump";tpm2_id,factory_resetanddissect_imagebuiltins.UDEV_VERSIONstays at 251; a bump can follow separately.