Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1799149imm; Tue, 10 Jul 2018 08:05:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc8mcHq0DR7oK3SS8TxuDeiXlv3VaVkiqp5WdXAlrvyriz94jbOPS1RDzyBI6oYO/9vbepq X-Received: by 2002:a17:902:bd95:: with SMTP id q21-v6mr24750342pls.237.1531235149286; Tue, 10 Jul 2018 08:05:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531235149; cv=none; d=google.com; s=arc-20160816; b=YBa+BHBqJNoibEOKCk1KOFo+KU4tEM0SZ2KUHUpcgr5d0UqPVU0vwNoVZ9ELvoXvs4 kh+jWQZszc1MwYQUOv8IxJSQPX4huVsSMpwwjlj6vq0gN0k4Ve4zmWEbFWuZejBlnQ4h mRNnW/tMQ8bGRHrMt/s4aMKy5IzfoCxGwyrLUarJZfsF8Zo9qyATO5T2GFHew0GkQ0D3 IjynYq6BXLBcdQw7gladVNwv7BdYhLQ8Kswo4fyXxklVCwAtXfq4LnxgZssKH4txCs6I g0ZLSNsqoyjzPqjCSxBu7yJgQrYxy9ESiFOI8aoApop88Qvt/bWy3W2a0D9EmMa23Jp2 u82g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=UbVaK34QAicDKUarwRo59smEJ8Q5QQaQP8gGbIVtQ8Q=; b=gWwfDrFpXBjjqGoi7oqNsEpye6tEBEBisAtVGbOFQJjJ1WHunaGaXns5vflg2tkngD zf0L5oT6oe/AVEjjgt1sX+PZ8orcQIAwZluyPewFUXB9Hp5l5A3JA7j93iIilOCCgZl0 9YO1RlwYxhtdIucaJVW0gCaEJExGVmRew87lAuPPyse7HCrYO2qX4x2Q1MvFePCJTTjZ 2kwDZo86Rt0xb4GahyLQ/nVT+E2RbKIprw9a4ULjF17t2dFdhdOvu0qnhwIK8M6h97Dn KlTBE3uqi5m1q0/HNo3h/7P+4//CsfZPuTzed48kgsEQdQI01bZ0s9fQnp9FNfBPZ57E FDBA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 68-v6si16962283pla.505.2018.07.10.08.05.22; Tue, 10 Jul 2018 08:05:49 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934120AbeGJPEC (ORCPT + 99 others); Tue, 10 Jul 2018 11:04:02 -0400 Received: from h2.hallyn.com ([78.46.35.8]:59818 "EHLO mail.hallyn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933709AbeGJPD7 (ORCPT ); Tue, 10 Jul 2018 11:03:59 -0400 Received: by mail.hallyn.com (Postfix, from userid 1001) id 58E98120D23; Tue, 10 Jul 2018 10:03:58 -0500 (CDT) Date: Tue, 10 Jul 2018 10:03:58 -0500 From: "Serge E. Hallyn" To: Tyler Hicks Cc: John Johansen , James Morris , Serge Hallyn , Seth Arnold , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] apparmor: Fully initialize aa_perms struct when answering userspace query Message-ID: <20180710150358.GD1661@mail.hallyn.com> References: <1530854701-7348-1-git-send-email-tyhicks@canonical.com> <1530854701-7348-3-git-send-email-tyhicks@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1530854701-7348-3-git-send-email-tyhicks@canonical.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Tyler Hicks (tyhicks@canonical.com): > 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 Acked-by: Serge Hallyn > --- > 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