From: Tetsuo Handa Date: Mon, 12 Apr 2021 13:45:50 +0000 (+0900) Subject: smackfs: restrict bytes count in smk_set_cipso() X-Git-Tag: v4.9.276~68 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5f9880403e6b71d56924748ba331daf836243fca;p=thirdparty%2Fkernel%2Fstable.git smackfs: restrict bytes count in smk_set_cipso() commit 49ec114a6e62d8d320037ce71c1aaf9650b3cafd upstream. Oops, I failed to update subject line. From 07571157c91b98ce1a4aa70967531e64b78e8346 Mon Sep 17 00:00:00 2001 From: Tetsuo Handa Date: Mon, 12 Apr 2021 22:25:06 +0900 Subject: smackfs: restrict bytes count in smk_set_cipso() Commit 7ef4c19d245f3dc2 ("smackfs: restrict bytes count in smackfs write functions") missed that count > SMK_CIPSOMAX check applies to only format == SMK_FIXED24_FMT case. Reported-by: syzbot Signed-off-by: Tetsuo Handa Signed-off-by: Casey Schaufler Signed-off-by: Greg Kroah-Hartman --- diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c index 04a53cdb409fa..966d30bf2e388 100644 --- a/security/smack/smackfs.c +++ b/security/smack/smackfs.c @@ -878,6 +878,8 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf, if (format == SMK_FIXED24_FMT && (count < SMK_CIPSOMIN || count > SMK_CIPSOMAX)) return -EINVAL; + if (count > PAGE_SIZE) + return -EINVAL; data = memdup_user_nul(buf, count); if (IS_ERR(data))