All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kobject: fix suppressing modalias in uevents delivered over netlink
@ 2017-12-13 23:21 Dmitry Torokhov
  2017-12-14 20:15 ` Casey Leedom
  2017-12-19  8:48 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 23+ messages in thread
From: Dmitry Torokhov @ 2017-12-13 23:21 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Eric Dumazet, Eric Dumazet, Tariq Toukan, David S . Miller,
	Komali Katari, Luis R. Rodriguez, Casey Leedom, linux-kernel

The commit 4a336a23d619 ("kobject: copy env blob in one go") optimized
constructing uevent data for delivery over netlink by using the raw
environment buffer, instead of reconstructing it from individual
environment pointers. Unfortunately in doing so it broke suppressing
MODALIAS attribute for KOBJ_UNBIND events, as the code that suppressed this
attribute only adjusted the environment pointers, but left the buffer
itself alone. Let's fix it by making sure the offending attribute is
obliterated form the buffer as well.

Reported-by: Tariq Toukan <tariqt@mellanox.com>
Reported-by: Casey Leedom <leedom@chelsio.com>
Fixes: 4a336a23d619 ("kobject: copy env blob in one go")
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 lib/kobject_uevent.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index f237a09a5862..ae47cc732ba6 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -297,7 +297,8 @@ static void cleanup_uevent_env(struct subprocess_info *info)
 static void zap_modalias_env(struct kobj_uevent_env *env)
 {
 	static const char modalias_prefix[] = "MODALIAS=";
-	int i;
+	size_t len;
+	int i, j;
 
 	for (i = 0; i < env->envp_idx;) {
 		if (strncmp(env->envp[i], modalias_prefix,
@@ -306,11 +307,18 @@ static void zap_modalias_env(struct kobj_uevent_env *env)
 			continue;
 		}
 
-		if (i != env->envp_idx - 1)
-			memmove(&env->envp[i], &env->envp[i + 1],
-				sizeof(env->envp[i]) * env->envp_idx - 1);
+		len = strlen(env->envp[i]) + 1;
+
+		if (i != env->envp_idx - 1) {
+			memmove(env->envp[i], env->envp[i + 1],
+				env->buflen - len);
+
+			for (j = i; j < env->envp_idx - 1; j++)
+				env->envp[j] = env->envp[j + 1] - len;
+		}
 
 		env->envp_idx--;
+		env->buflen -= len;
 	}
 }
 
-- 
2.15.1.504.g5279b80103-goog


-- 
Dmitry

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2017-12-31 10:55 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-13 23:21 [PATCH] kobject: fix suppressing modalias in uevents delivered over netlink Dmitry Torokhov
2017-12-14 20:15 ` Casey Leedom
2017-12-14 20:32   ` Dmitry Torokhov
2017-12-14 21:38     ` Casey Leedom
2017-12-14 21:44       ` Dmitry Torokhov
2017-12-14 22:08         ` Casey Leedom
2017-12-15 18:17           ` Casey Leedom
2017-12-15 18:53             ` Dmitry Torokhov
2017-12-15 19:17               ` Casey Leedom
2017-12-18 19:45                 ` Casey Leedom
2017-12-18 20:06                   ` Casey Leedom
2017-12-19 21:20                     ` Casey Leedom
2017-12-21  5:13                       ` Dmitry Torokhov
2017-12-21 20:26                         ` Casey Leedom
2017-12-28  1:56                           ` Casey Leedom
2017-12-31 10:28                         ` Tariq Toukan
2017-12-31 10:39                           ` Greg Kroah-Hartman
2017-12-31 10:55                             ` Tariq Toukan
2017-12-17 15:29     ` Tariq Toukan
2017-12-17 16:48       ` Tariq Toukan
2017-12-19  8:48 ` Greg Kroah-Hartman
2017-12-19  9:12   ` Eric Dumazet
2017-12-19 15:41     ` Tariq Toukan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.