From patchwork Tue Jun 23 19:56:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 223282 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.0 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 8D874C433E0 for ; Tue, 23 Jun 2020 21:06:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D71320702 for ; Tue, 23 Jun 2020 21:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592946384; bh=fEV1kh+iUYOqs8NPj0Y16rmcmmDI9I8r/bHNRjB8MgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=cFgeOkDaiW0m8aePfyqubZW5RkaQnxR/rrYGNjeTTOXH4JH4Xdgx7Fz6iLt3EyzN2 Jn2lBN4WO42u1vUQtSxz38FPXp3LQEpc7YABoWJi1z1gvmN+KUFmWlMiobkGEZzf9I KejhPWbGzop7Jrp6axOolg3ufIdvl9MRNxTYsD0Q= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387856AbgFWVGW (ORCPT ); Tue, 23 Jun 2020 17:06:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:59078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391769AbgFWUgJ (ORCPT ); Tue, 23 Jun 2020 16:36:09 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6D49F20781; Tue, 23 Jun 2020 20:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592944570; bh=fEV1kh+iUYOqs8NPj0Y16rmcmmDI9I8r/bHNRjB8MgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y/w2uAjokqlAbBRp34iUefovVbmKuHmDc02A7W1MK2SnvYT+vKNybaAv/RcUjPUdX AnPr7g084Hof1qYSLrPM/WDdDPqW+mIeGSYuXZdHIqcVdX8Hfmdpo571UGqTMkyeI5 mssTsCleA0yUu82TvMdbfsPPasMafqOxsDCdgd98= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Johansen , Sasha Levin Subject: [PATCH 4.19 041/206] apparmor: fix introspection of of task mode for unconfined tasks Date: Tue, 23 Jun 2020 21:56:09 +0200 Message-Id: <20200623195319.006344448@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195316.864547658@linuxfoundation.org> References: <20200623195316.864547658@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 2469549842d24..6e7aa2ef8ee0f 100644 --- a/security/apparmor/label.c +++ b/security/apparmor/label.c @@ -1535,13 +1535,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)