All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hooks: fix a missing-check bug in selinux_add_mnt_opt()
@ 2019-05-30  8:06 Gen Zhang
  2019-05-30  8:30 ` Ondrej Mosnacek
  2019-05-30  9:11 ` [PATCH] " Sergei Shtylyov
  0 siblings, 2 replies; 9+ messages in thread
From: Gen Zhang @ 2019-05-30  8:06 UTC (permalink / raw)
  To: paul, sds, eparis, ccross; +Cc: selinux, linux-kernel, netdev

In selinux_add_mnt_opt(), 'val' is allcoted by kmemdup_nul(). It returns
NULL when fails. So 'val' should be checked.

Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
---
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 3ec702c..4797c63 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -1052,8 +1052,11 @@ static int selinux_add_mnt_opt(const char *option, const char *val, int len,
 	if (token == Opt_error)
 		return -EINVAL;
 
-	if (token != Opt_seclabel)
-		val = kmemdup_nul(val, len, GFP_KERNEL);
+	if (token != Opt_seclabel) {
+			val = kmemdup_nul(val, len, GFP_KERNEL);
+			if (!val)
+				return -ENOMEM;
+	}
 	rc = selinux_add_opt(token, val, mnt_opts);
 	if (unlikely(rc)) {
 		kfree(val);

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

end of thread, other threads:[~2019-06-01  1:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-30  8:06 [PATCH] hooks: fix a missing-check bug in selinux_add_mnt_opt() Gen Zhang
2019-05-30  8:30 ` Ondrej Mosnacek
2019-05-30  8:54   ` [PATCH v2] " Gen Zhang
2019-05-31 15:55     ` Paul Moore
2019-06-01  1:54       ` Gen Zhang
2019-05-30  9:11 ` [PATCH] " Sergei Shtylyov
2019-05-30  9:18   ` Gen Zhang
2019-05-30  9:22     ` Sergei Shtylyov
2019-05-30  9:24       ` Gen Zhang

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.