From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Jakub Kicinski <kubakici@wp.pl>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [bisected] Re: Module removal-related regression?
Date: Tue, 12 Sep 2017 11:52:11 -0700 [thread overview]
Message-ID: <20170912185211.GB6654@dtor-ws> (raw)
In-Reply-To: <20170912140041.1e960388@cakuba.netronome.com>
On Tue, Sep 12, 2017 at 02:00:41PM +0200, Jakub Kicinski wrote:
> On Mon, 11 Sep 2017 11:29:26 -0700, Dmitry Torokhov wrote:
> >
> > That is an option, but maybe we could have the patch below for a year or
> > 2 instead?
> >
> > Jakub, can you try and see if that works for you?
>
> Unfortunately this doesn't seem to solve it :(
>
> # modprobe nfp; lsmod | grep nfp; modprobe -r nfp; lsmod | grep nfp
> nfp 1101824 0
> nfp 1101824 1
Well, I should have tested it before sending out. How about this one?
--
Dmitry
driver core: suppress sending MODALIAS in UNBIND uevents
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
The current udev rules cause modules to be loaded on all device events save
for "remove". With the introduction of KOBJ_BIND/KOBJ_UNBIND this causes
issues, as driver modules that have devices bound to their drivers get
immediately reloaded, and it appears to the user that module unloading doe
snot work.
The standard udev matching rule is foillowing:
ENV{MODALIAS}=="?*", RUN{builtin}+="kmod load $env{MODALIAS}"
Given that MODALIAS data is not terribly useful for UNBIND event, let's zap
it from the generated uevent environment until we get userspace updated
with the correct udev rule that only loads modules on "add" event.
Reported-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
lib/kobject_uevent.c | 49 +++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 41 insertions(+), 8 deletions(-)
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index e590523ea476..f237a09a5862 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -294,6 +294,26 @@ static void cleanup_uevent_env(struct subprocess_info *info)
}
#endif
+static void zap_modalias_env(struct kobj_uevent_env *env)
+{
+ static const char modalias_prefix[] = "MODALIAS=";
+ int i;
+
+ for (i = 0; i < env->envp_idx;) {
+ if (strncmp(env->envp[i], modalias_prefix,
+ sizeof(modalias_prefix) - 1)) {
+ i++;
+ continue;
+ }
+
+ if (i != env->envp_idx - 1)
+ memmove(&env->envp[i], &env->envp[i + 1],
+ sizeof(env->envp[i]) * env->envp_idx - 1);
+
+ env->envp_idx--;
+ }
+}
+
/**
* kobject_uevent_env - send an uevent with environmental data
*
@@ -409,16 +429,29 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
}
}
- /*
- * Mark "add" and "remove" events in the object to ensure proper
- * events to userspace during automatic cleanup. If the object did
- * send an "add" event, "remove" will automatically generated by
- * the core, if not already done by the caller.
- */
- if (action == KOBJ_ADD)
+ switch (action) {
+ case KOBJ_ADD:
+ /*
+ * Mark "add" event so we can make sure we deliver "remove"
+ * event to userspace during automatic cleanup. If
+ * the object did send an "add" event, "remove" will
+ * automatically generated by the core, if not already done
+ * by the caller.
+ */
kobj->state_add_uevent_sent = 1;
- else if (action == KOBJ_REMOVE)
+ break;
+
+ case KOBJ_REMOVE:
kobj->state_remove_uevent_sent = 1;
+ break;
+
+ case KOBJ_UNBIND:
+ zap_modalias_env(env);
+ break;
+
+ default:
+ break;
+ }
mutex_lock(&uevent_sock_mutex);
/* we will send an event, so request a new sequence number */
next prev parent reply other threads:[~2017-09-12 18:52 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-09 17:41 Module removal-related regression? Jakub Kicinski
2017-09-09 19:27 ` [bisected] " Jakub Kicinski
2017-09-09 19:55 ` Dmitry Torokhov
2017-09-09 20:10 ` Jakub Kicinski
2017-09-09 20:17 ` Jakub Kicinski
2017-09-09 20:59 ` Dmitry Torokhov
2017-09-09 22:03 ` Jakub Kicinski
2017-09-10 16:21 ` Dmitry Torokhov
2017-09-10 18:00 ` Jakub Kicinski
2017-09-10 18:12 ` Dmitry Torokhov
2017-09-10 18:39 ` Jakub Kicinski
2017-09-10 18:50 ` Dmitry Torokhov
2017-09-10 19:09 ` Greg Kroah-Hartman
2017-09-10 19:13 ` Jakub Kicinski
2017-09-10 21:22 ` Dmitry Torokhov
2017-09-11 15:23 ` Greg Kroah-Hartman
2017-09-11 18:29 ` Dmitry Torokhov
2017-09-12 12:00 ` Jakub Kicinski
2017-09-12 18:52 ` Dmitry Torokhov [this message]
2017-09-13 11:35 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170912185211.GB6654@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=kubakici@wp.pl \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox