Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1393823imm; Thu, 5 Jul 2018 22:27:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfPNymctKcy1cnvjKa3MGeKbY3Pcsp8zFvbdfkylmfBbqaKrnZbtTv0+Nn0AIKpym9CdX9N X-Received: by 2002:a17:902:968c:: with SMTP id n12-v6mr8869142plp.15.1530854822637; Thu, 05 Jul 2018 22:27:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530854822; cv=none; d=google.com; s=arc-20160816; b=WhshnI7fjFKkfgP/mpzbHpY1xm2JftgXUNCtC7B6H/gzD7+S+xfMnxyvw0Qt4OGh3q fSO0a19mr66d3El7ddQN0wBK+nJbgz7MzoisAxF9S5D0G7c871zQ8FqGiCUhMKaq0OdW qGEbpfIHyOvXbsq9Q06NA5El4Unk1eANLNZtbxpcauKxUVEYFSFBZMR1UEpC0a2Usfok 15SP3yzih60A4woQ1oxOvrrVrdkrxt/d7xIZDSrszzdu4go5f/lVDDRQkRj0pVITDr6r kohzi1jUSyZVEF/S8IMVG/wIzSYfVJSmFm0XJ02LGzskBDEcMd0ibiK/i5WbWHtQNxHL zEJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=lCqby/Az9+Sqt0jX4zDjyJP2tF2yI5R2+J90oI7zi50=; b=b7F0LzUAUnD8OE2uL3jiyPbhysuKD3mWLO/sPZjDTjWkv7Xdc5bfPiujQSggxNprKm MEfGusyLuheArPI8hj7f//WuCZ1yqoPAgLp8xyCJ+XZpLiuUIJb2nJhFJhgaIdFps6Kt tYtAtRCbGKIx21lEDKamPfwynPdfCGpqqQ8580AB2wK78wit92RiImkZOYtsHLt+1q0E W2kfyG+23Gy2zooDO9uskp2SWXzZhuHSq5xp6b68lPnk06dp9uxwGlXCLtoqdTzSYqaI JEO+Q7nWEV6IqrzRgIoZBDvQeCA4JVmBYJl4OgKxJde8gZLM1rf2y4hHiC2emE1iZPo4 RmKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3-v6si2991086pgl.583.2018.07.05.22.26.48; Thu, 05 Jul 2018 22:27:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932569AbeGFF0B (ORCPT + 99 others); Fri, 6 Jul 2018 01:26:01 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:45695 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932197AbeGFFZ7 (ORCPT ); Fri, 6 Jul 2018 01:25:59 -0400 Received: from 162-237-133-238.lightspeed.rcsntx.sbcglobal.net ([162.237.133.238] helo=sec.l.tihix.com) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fbJFl-0001Jc-4P; Fri, 06 Jul 2018 05:25:57 +0000 From: Tyler Hicks To: John Johansen Cc: James Morris , Serge Hallyn , Seth Arnold , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] apparmor: Fully initialize aa_perms struct when answering userspace query Date: Fri, 6 Jul 2018 05:25:01 +0000 Message-Id: <1530854701-7348-3-git-send-email-tyhicks@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530854701-7348-1-git-send-email-tyhicks@canonical.com> References: <1530854701-7348-1-git-send-email-tyhicks@canonical.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fully initialize the aa_perms struct in profile_query_cb() to avoid the potential of using an uninitialized struct member's value in a response to a query from userspace. Detected by CoverityScan CID#1415126 ("Uninitialized scalar variable") Fixes: 4f3b3f2d79a4 ("apparmor: add profile permission query ability") Signed-off-by: Tyler Hicks --- security/apparmor/apparmorfs.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c index 949dd8a48164..e09fe4d7307c 100644 --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c @@ -603,7 +603,7 @@ static const struct file_operations aa_fs_ns_revision_fops = { static void profile_query_cb(struct aa_profile *profile, struct aa_perms *perms, const char *match_str, size_t match_len) { - struct aa_perms tmp; + struct aa_perms tmp = { }; struct aa_dfa *dfa; unsigned int state = 0; @@ -613,7 +613,6 @@ static void profile_query_cb(struct aa_profile *profile, struct aa_perms *perms, dfa = profile->file.dfa; state = aa_dfa_match_len(dfa, profile->file.start, match_str + 1, match_len - 1); - tmp = nullperms; if (state) { struct path_cond cond = { }; @@ -627,8 +626,6 @@ static void profile_query_cb(struct aa_profile *profile, struct aa_perms *perms, match_str, match_len); if (state) aa_compute_perms(dfa, state, &tmp); - else - tmp = nullperms; } aa_apply_modes_to_perms(profile, &tmp); aa_perms_accum_raw(perms, &tmp); -- 2.7.4