Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

needs-restarting: "Regular files" are often on 00:xx devices #559

Conversation

evan-goode
Copy link
Member

needs-restarting currently checks the major:minor device of each mmapped file and ignores files from devices with major version 0, considering them "not regular files". According to the kernel docs [1], a major version of 0 is for "unnamed devices, e.g. non-device mounts".

But ignoring files on 00:xx devices seems to not be a valid strategy. From my testing, in containers and in virtual machines especially, "regular files" managed by DNF are often on these devices. For example:

docker run -it --rm fedora:40 stat /usr/bin/sleep
  File: /usr/bin/sleep
  Size: 36864     	Blocks: 72         IO Block: 4096   regular file
Device: 0,100	Inode: 2403790     Links: 1
...

This patch removes this filter so that we just check that a file has a corresponding file path. There are files that have (something that looks like) a file path but are not "regular files", for example:

7283/maps:7f7f3f0d2000-7f7f3f0e0000 rw-s 00000000 00:01 7224                       /memfd:mozilla-ipc (deleted)

We should be able to ignore these since they would not be in the RPM database anyway.

[1] https://www.kernel.org/doc/Documentation/admin-guide/devices.txt

needs-restarting currently checks the major:minor device of each mmapped
file and ignores files from devices with major version 0, considering
them "not regular files". According to the kernel docs [1], a major
version of 0 is for "unnamed devices, e.g. non-device mounts".

But ignoring files on 00:xx devices seems to not be a valid strategy. From my
testing, in containers and in virtual machines especially, "regular files"
managed by DNF are often on these devices. For example:

```
docker run -it --rm fedora:40 stat /usr/bin/sleep
  File: /usr/bin/sleep
  Size: 36864     	Blocks: 72         IO Block: 4096   regular file
Device: 0,100	Inode: 2403790     Links: 1
...
```

This patch removes this filter so that we just check that a file has a
corresponding file path. There are files that have (something that looks
like) a file path but are not "regular files", for example:
7283/maps:7f7f3f0d2000-7f7f3f0e0000 rw-s 00000000 00:01 7224                       /memfd:mozilla-ipc (deleted)
We should be able to ignore these since they would not be in the RPM database
anyway.

[1] https://www.kernel.org/doc/Documentation/admin-guide/devices.txt
We can no longer detect that block devices like /dev/dri/card0 are not
"regular files", since they have device IDs matching 00:xx, just like
other legitimate files on some systems. This should be fine since no
package should provide a file like /dev/dri/card0.

Instead, we add a test that smap entries like

```
556d60d52000-556d60e1c000 rw-p 00000000 00:00 0                          [heap]
```

are not treated as regular files (since the file path doesn't contain a /).
@kontura kontura merged commit bc50a84 into rpm-software-management:master Oct 14, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants