From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AE33C433DF for ; Thu, 18 Jun 2020 01:29:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61F4C22246 for ; Thu, 18 Jun 2020 01:29:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592443796; bh=T7rMhHmYYRbKUT5PVuWAqsG0Vur76MoJMNnDuJD1djU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=LYDf4AtJgAi0azegYrEmvDTAKZOgdOln5BVITntxLVKDRT3CellfoFopRecQVfYAs BP9jWry0NjigX2DMYAIODFNQdPGfWujQqHpuIuBRBISUkcvSDJrAWYosOHuvzWuGOI vPkGupxiXoLFsaOPYC769hTTsdf0YIw/uiaUMiMA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732406AbgFRB3y (ORCPT ); Wed, 17 Jun 2020 21:29:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:34488 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731105AbgFRB0q (ORCPT ); Wed, 17 Jun 2020 21:26:46 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 03FDA20897; Thu, 18 Jun 2020 01:26:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592443605; bh=T7rMhHmYYRbKUT5PVuWAqsG0Vur76MoJMNnDuJD1djU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gkF9FRphxDX3tbrok2EOvR1ryFcTntg/b4ZFn+XULhGFJzmEWCq8qjVkX4F9iBKCb l4zgYo9kHmxZbyOzf7Rxmh2R/T94+jKQ+5RvHdB18FXZK9JOk37oEYt+n1CBsE3DM3 Cfsqk0J8UD+ZPYm6/y1uYTsR4WHPgAbu36IkhRIs= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: John Johansen , Sasha Levin , linux-security-module@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 034/108] apparmor: fix introspection of of task mode for unconfined tasks Date: Wed, 17 Jun 2020 21:24:46 -0400 Message-Id: <20200618012600.608744-34-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200618012600.608744-1-sashal@kernel.org> References: <20200618012600.608744-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Johansen [ Upstream commit dd2569fbb053719f7df7ef8fdbb45cf47156a701 ] Fix two issues with introspecting the task mode. 1. If a task is attached to a unconfined profile that is not the ns->unconfined profile then. Mode the mode is always reported as - $ ps -Z LABEL PID TTY TIME CMD unconfined 1287 pts/0 00:00:01 bash test (-) 1892 pts/0 00:00:00 ps instead of the correct value of (unconfined) as shown below $ ps -Z LABEL PID TTY TIME CMD unconfined 2483 pts/0 00:00:01 bash test (unconfined) 3591 pts/0 00:00:00 ps 2. if a task is confined by a stack of profiles that are unconfined the output of label mode is again the incorrect value of (-) like above, instead of (unconfined). This is because the visibile profile count increment is skipped by the special casing of unconfined. Fixes: f1bd904175e8 ("apparmor: add the base fns() for domain labels") Signed-off-by: John Johansen Signed-off-by: Sasha Levin --- security/apparmor/label.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/apparmor/label.c b/security/apparmor/label.c index ea63710442ae..212a0f39ddae 100644 --- a/security/apparmor/label.c +++ b/security/apparmor/label.c @@ -1536,13 +1536,13 @@ static const char *label_modename(struct aa_ns *ns, struct aa_label *label, label_for_each(i, label, profile) { if (aa_ns_visible(ns, profile->ns, flags & FLAG_VIEW_SUBNS)) { - if (profile->mode == APPARMOR_UNCONFINED) + count++; + if (profile == profile->ns->unconfined) /* special case unconfined so stacks with * unconfined don't report as mixed. ie. * profile_foo//&:ns1:unconfined (mixed) */ continue; - count++; if (mode == -1) mode = profile->mode; else if (mode != profile->mode) -- 2.25.1