Skip to content

lsmod, libkmod: handle module changes during execution #42

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SuibianP
Copy link

@SuibianP SuibianP commented Jun 7, 2024

Kernel modules may be unloaded within the time window of checking /proc/modules and /sys/module/*/*. As a result,

  • -errno is printed in place of size or reference count
  • EXIT_SUCCESS is reported despite failure

Add checks for better error reporting.

Fixes #41.

Kernel modules may be unloaded within the time window of checking
/proc/modules and /sys/module/*/*. As a result,

* -errno is printed in place of size or reference count
* EXIT_SUCCESS is reported despite failure

Add checks for better error reporting.
int first = 1;

if (holders == NULL || use_count < 0 || size < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

holders == NULL is a normal thing to have, e.g:

serio_raw              20480  0

use_count < 0 allows us to use modules in the "going" state, i.e. in the process of being unloaded.

size < 0 I believe is the only one that we should really do something.... maybe setting it to 0. Rather than exiting here, I think we should just handle the races as a normal situation and continue printing the rest of the list.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An illustration of negative use_count:

In a handful of instances (buggy/glitchy bluetooth + rmmod non-force) I have ended up with foobar 1234 -1. At which point the kernel(?) was completely foobar'd and reboot was needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SuibianP can you rebase taking this into account?

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.

Module may be unloaded before checking holders
3 participants