From patchwork Tue Aug 23 09:05:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Johansen X-Patchwork-Id: 661779 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3sJPgy5QNZz9sBc; Tue, 23 Aug 2016 19:06:38 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1bc7fH-0006P9-H4; Tue, 23 Aug 2016 09:06:35 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1bc7f6-0006IH-JT for kernel-team@lists.ubuntu.com; Tue, 23 Aug 2016 09:06:24 +0000 Received: from static-50-53-49-26.bvtn.or.frontiernet.net ([50.53.49.26] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1bc7f6-0006VR-0k for kernel-team@lists.ubuntu.com; Tue, 23 Aug 2016 09:06:24 +0000 From: John Johansen To: kernel-team@lists.ubuntu.com Subject: [PATCH 05/14] UBUNTU: SAUCE: apparmor: Add missing id bounds check on dfa verification Date: Tue, 23 Aug 2016 02:05:45 -0700 Message-Id: <1471943154-14507-6-git-send-email-john.johansen@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1471943154-14507-1-git-send-email-john.johansen@canonical.com> References: <1471943154-14507-1-git-send-email-john.johansen@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com BugLink: http://bugs.launchpad.net/bugs/1615882 Signed-off-by: John Johansen --- security/apparmor/include/match.h | 1 + security/apparmor/match.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/security/apparmor/include/match.h b/security/apparmor/include/match.h index d333b34..a85bb3b 100644 --- a/security/apparmor/include/match.h +++ b/security/apparmor/include/match.h @@ -62,6 +62,7 @@ struct table_set_header { #define YYTD_ID_ACCEPT2 6 #define YYTD_ID_NXT 7 #define YYTD_ID_TSIZE 8 +#define YYTD_ID_MAX 8 #define YYTD_DATA8 1 #define YYTD_DATA16 2 diff --git a/security/apparmor/match.c b/security/apparmor/match.c index 4fe2641..68e4a26 100644 --- a/security/apparmor/match.c +++ b/security/apparmor/match.c @@ -74,6 +74,8 @@ static struct table_header *unpack_table(char *blob, size_t bsize) * it every time we use td_id as an index */ th.td_id = be16_to_cpu(*(u16 *) (blob)) - 1; + if (th.td_id > YYTD_ID_MAX) + goto out; th.td_flags = be16_to_cpu(*(u16 *) (blob + 2)); th.td_lolen = be32_to_cpu(*(u32 *) (blob + 8)); blob += sizeof(struct table_header);