Skip to contentSkip to conversation

smack: fix a missing-check bug in smack_sb_eat_lsm_opts()

PATCH In review Chen Zhou 2 participants 2 messages Apr 1, 2020

Subsystems (2)
lore
Share & tools
lore

Chen Zhou

author
#0 lore raw

PATCH 1/1 smack: fix a missing-check bug in smack_sb_eat_lsm_opts()

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

---
 security/smack/smack_lsm.c | 2 ++
 1 file changed, 2 insertions(+)
security/smack/smack_lsm.c +2 -0
index 2862fc3..9ec30f3 100644
@@ -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);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 2 lines · Chen Zhou

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.