linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] smack: fix a missing-check bug in smack_sb_eat_lsm_opts()
@ 2020-04-01  7:10 Chen Zhou
  2020-04-01 12:39 ` Tetsuo Handa
  0 siblings, 1 reply; 2+ messages in thread
From: Chen Zhou @ 2020-04-01  7:10 UTC (permalink / raw)
  To: casey, jmorris, serge; +Cc: linux-security-module, linux-kernel, chenzhou10

In smack_sb_eat_lsm_opts(), 'arg' is allocated by kmemdup_nul().
It returns NULL when fails, add check for it.

Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
---
 security/smack/smack_lsm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 2862fc3..9ec30f3 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -731,6 +731,8 @@ static int smack_sb_eat_lsm_opts(char *options, void **mnt_opts)
 		token = match_opt_prefix(from, len, &arg);
 		if (token != Opt_error) {
 			arg = kmemdup_nul(arg, from + len - arg, GFP_KERNEL);
+			if (!arg)
+				return -ENOMEM;
 			rc = smack_add_opt(token, arg, mnt_opts);
 			if (unlikely(rc)) {
 				kfree(arg);
-- 
2.7.4


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

* Re: [PATCH -next] smack: fix a missing-check bug in smack_sb_eat_lsm_opts()
  2020-04-01  7:10 [PATCH -next] smack: fix a missing-check bug in smack_sb_eat_lsm_opts() Chen Zhou
@ 2020-04-01 12:39 ` Tetsuo Handa
  0 siblings, 0 replies; 2+ messages in thread
From: Tetsuo Handa @ 2020-04-01 12:39 UTC (permalink / raw)
  To: Chen Zhou; +Cc: casey, jmorris, serge, linux-security-module, linux-kernel

On 2020/04/01 16:10, Chen Zhou wrote:
> In smack_sb_eat_lsm_opts(), 'arg' is allocated by kmemdup_nul().
> It returns NULL when fails, add check for it.

Thanks. But this check is not needed, for smack_add_opt() returns NULL if arg == NULL.

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

end of thread, other threads:[~2020-04-01 12:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-01  7:10 [PATCH -next] smack: fix a missing-check bug in smack_sb_eat_lsm_opts() Chen Zhou
2020-04-01 12:39 ` Tetsuo Handa

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).