netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] hooks: fix a missing-check bug in selinux_sb_eat_lsm_opts()
@ 2019-05-31  1:33 Gen Zhang
  2019-05-31 15:45 ` Paul Moore
  0 siblings, 1 reply; 3+ messages in thread
From: Gen Zhang @ 2019-05-31  1:33 UTC (permalink / raw)
  To: paul, sds, eparis; +Cc: selinux, linux-kernel, netdev, bpf, omosnace

In selinux_sb_eat_lsm_opts(), 'arg' is allocated by kmemdup_nul(). It
returns NULL when fails. So 'arg' should be checked.

Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
Reviewed-by: Ondrej Mosnacek <omosnace@redhat.com>
Fixes: 99dbbb593fe6 ("selinux: rewrite selinux_sb_eat_lsm_opts()")
---
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 3ec702c..5a9e959 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -2635,6 +2635,8 @@ static int selinux_sb_eat_lsm_opts(char *options, void **mnt_opts)
 						*q++ = c;
 				}
 				arg = kmemdup_nul(arg, q - arg, GFP_KERNEL);
+				if (!arg)
+					return -ENOMEM;
 			}
 			rc = selinux_add_opt(token, arg, mnt_opts);
 			if (unlikely(rc)) {

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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-31  1:33 [PATCH v2] hooks: fix a missing-check bug in selinux_sb_eat_lsm_opts() Gen Zhang
2019-05-31 15:45 ` Paul Moore
2019-06-01  1:57   ` Gen Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).