commit: 3b9fc37280c521b086943f9aedda767f5bf3b2d3 From: Alan Cox <[email protected]> Date: Thu, 26 Jul 2012 14:47:11 -0700 Subject: smack: off by one error
Consider the input case of a rule that consists entirely of non space symbols followed by a \0. Say 64 + \0 In this case strlen(data) = 64 kzalloc of subject and object are 64 byte objects sscanfdata, "%s %s %s", subject, ...) will put 65 bytes into subject. Signed-off-by: Alan Cox <[email protected]> Acked-by: Casey Schaufler <[email protected]> Cc: [email protected] Signed-off-by: James Morris <[email protected]> --- security/smack/smackfs.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c index d31e6d9..b1b768e 100644 --- a/security/smack/smackfs.c +++ b/security/smack/smackfs.c @@ -323,11 +323,11 @@ static int smk_parse_long_rule(const char *data, struct smack_rule *rule, int datalen; int rc = -1; - /* - * This is probably inefficient, but safe. - */ + /* This is inefficient */ datalen = strlen(data); - subject = kzalloc(datalen, GFP_KERNEL); + + /* Our first element can be 64 + \0 with no spaces */ + subject = kzalloc(datalen + 1, GFP_KERNEL); if (subject == NULL) return -1; object = kzalloc(datalen, GFP_KERNEL); -- 1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
