Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3328659rwa; Tue, 23 Aug 2022 02:58:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR71hROcQfRnNllzcTsBXE0rrNShv8SzkXNcZabL+8y4quAJ+jm7huBO7cG3b3DLv9Y2Fc4k X-Received: by 2002:a17:902:db12:b0:172:9e51:64 with SMTP id m18-20020a170902db1200b001729e510064mr23540307plx.140.1661248695842; Tue, 23 Aug 2022 02:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661248695; cv=none; d=google.com; s=arc-20160816; b=1AlBHotl3V+HxKD+FPfq/lgnoE45jP+GaBE4dQX+VFtd0O0RcWDwPm7mRXhFmQJU25 o/NZqQURAJIREd2l99o+7BQH2WAD4+IOx+9uGPn8ErNSeBwzhy4w3vDptEs1dYdhVal3 IDYDCX//mwbtQi9q/+TwADSDsmvyhk40bK6O2nkKWjYck7C4bObeizmwOWCV1j/hQlog mYDXK3Av4uzZuwy5O2j71jZmMQW2fxe3IFjF9odFBz2PNb/wipWj9J/k9WqOfNzX4e34 7XGkpRsdc8KwB6Ad06it43iXFTs8eVx68qIM05FV4d3bG814xdyV2VmDctHYMleW9wMM loFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lKz3xoGLROzQLXb2QZNxcnxIl3xc6HIMosH/Okaq0lQ=; b=eareRJSYt/N0XDScjCZf1VqkbWyA0/EHAhOjay6oq1s1m41OVWsZ5QsrKFhrLE/4cV TJASnd7XAunr0avOX1JyRYjHoxPWVGDra0px4qm8mWT+9IM/gfxq3Fwxy371jjXcaqGp NPiG9XBjckd3p+TM1lL+Jlfa3y+1Y1GpdedkzusD2sZmSyYbD973/hJ70I9Fe5P3pCsv MUJtMOZHKm8Kg1h1gec+E1dOmkbDg1DsM3nVyhpL4LiTkDH9uYDhBHW293puAJ7LZEQ0 peFaMZiwD54LwMSG1iyxd/rO+jkCOXEJcPt3rFRCrdrYlRI1b8Ef1fJxwBcz49Fzfm51 uJRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=abJTtjr2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w14-20020a637b0e000000b0041bf27ac6e2si15612460pgc.730.2022.08.23.02.58.04; Tue, 23 Aug 2022 02:58:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=abJTtjr2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237443AbiHWJnT (ORCPT + 99 others); Tue, 23 Aug 2022 05:43:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351950AbiHWJkn (ORCPT ); Tue, 23 Aug 2022 05:40:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D693140BED; Tue, 23 Aug 2022 01:41:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9A649B81C4F; Tue, 23 Aug 2022 08:41:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4BA1C433D6; Tue, 23 Aug 2022 08:41:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244071; bh=BynSNA2pLc0++aOd/nVe1u0EbpDodCq+xxgBLeUp6rg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=abJTtjr2J0bjxocPwyo8CGnuMdfemCBOLT+L7XDUPuwYxlfKxaYj01IgTWbvRqvDC vU5L8iL2elr+wMC78Y3PIBhH/1sClIBXih653nzRR8rGnQYkZ98QJtH0LszSjWs6Pv yuCX+e2MGphtRG49jtnuXC+Dik9kerdWiDX1EfC4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Johansen Subject: [PATCH 5.15 032/244] apparmor: fix setting unconfined mode on a loaded profile Date: Tue, 23 Aug 2022 10:23:11 +0200 Message-Id: <20220823080100.132500494@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Johansen commit 3bbb7b2e9bbcd22e539e23034da753898fe3b4dc upstream. When loading a profile that is set to unconfined mode, that label flag is not set when it should be. Ensure it is set so that when used in a label the unconfined check will be applied correctly. Fixes: 038165070aa5 ("apparmor: allow setting any profile into the unconfined state") Signed-off-by: John Johansen Signed-off-by: Greg Kroah-Hartman --- security/apparmor/policy_unpack.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- a/security/apparmor/policy_unpack.c +++ b/security/apparmor/policy_unpack.c @@ -746,16 +746,18 @@ static struct aa_profile *unpack_profile profile->label.flags |= FLAG_HAT; if (!unpack_u32(e, &tmp, NULL)) goto fail; - if (tmp == PACKED_MODE_COMPLAIN || (e->version & FORCE_COMPLAIN_FLAG)) + if (tmp == PACKED_MODE_COMPLAIN || (e->version & FORCE_COMPLAIN_FLAG)) { profile->mode = APPARMOR_COMPLAIN; - else if (tmp == PACKED_MODE_ENFORCE) + } else if (tmp == PACKED_MODE_ENFORCE) { profile->mode = APPARMOR_ENFORCE; - else if (tmp == PACKED_MODE_KILL) + } else if (tmp == PACKED_MODE_KILL) { profile->mode = APPARMOR_KILL; - else if (tmp == PACKED_MODE_UNCONFINED) + } else if (tmp == PACKED_MODE_UNCONFINED) { profile->mode = APPARMOR_UNCONFINED; - else + profile->label.flags |= FLAG_UNCONFINED; + } else { goto fail; + } if (!unpack_u32(e, &tmp, NULL)) goto fail; if (tmp)