Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7341865rdb; Wed, 3 Jan 2024 12:28:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IENnJoqgcZwIX+tD5DrxpsuiRs5BVv7MQLLLv/E5IlOzyz0XfegFaTzmBo6bTVE5zq8wdrd X-Received: by 2002:a17:903:234d:b0:1d4:bcf6:cb55 with SMTP id c13-20020a170903234d00b001d4bcf6cb55mr2858084plh.127.1704313691197; Wed, 03 Jan 2024 12:28:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704313691; cv=none; d=google.com; s=arc-20160816; b=JXBsMy07q1ZmWFG9OwX8IHqKnsFv0mmwOCsVTghvMUt+Pyq3C2XQoJO63CBe1ciXg6 dNTGhJ6Trp4yWTUOddIqaDR28QDR4/m8djy7C0r1z6emd0z5hcfbbzFgQbL/OLvYodZ+ SQpWZM0wTb4zvRPeqUMH/lsnz3zLnodzBHPuLPPsZQt/fMlWgtXWvFG2KYOOFP+3y+QS drGB54j5c4xdW12QRaz9f9jsOWBDJA8INd0CSFKtGLtYwbCgumOh891LM1AqY/UH00ph sPpRJ5t9Q2UP8OUHza4vfXrDTxPFbL1C89Lav8OUl0uv0EGS1w1QamKCmsBPfwfwyzWF YOAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:organization:autocrypt:content-language :cc:to:subject:from:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=gujZVJVMpl06CEwjpYkzgXTz5Wv2wosy7hx4wRR1cC0=; fh=YOjN7xfy5lIOs/wek/SBTJgHUiPN29fWO4r9aCwO8Vo=; b=CMz59mGmt0c8rLthzT8wW+BKB4B3rn9M/nK3FP84SaqCzjDZul4BnjHUmhPlJIeH55 fGEzk5iMjlKlzaAmKi7V12L3IjpHuRdCtlALYQp+kRD+QiHUvlbB/5FaN03xgy+1mfD4 kLFv0YsaR35+CJJEVe3vnR0ne+sZBeZBdVSVVnxd6dkkStbVbIX9ajf95MtPSbPP/frd WTh6jajV7DW9ANnOOYw2MZACBaJABKjorg1yVn5JlIUrQiWdqDwvNO5w6ZTP3Hzv/n9s 2BexWRIz1l2LKoRuYJOqHTjV9Evg5M/A/l7gNOLP/7aQ2mcKXCoWRL410GwBm/w7+1DO OyVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=fvcrFrwp; spf=pass (google.com: domain of linux-kernel+bounces-15983-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15983-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id jc22-20020a17090325d600b001d4d7730bf9si631013plb.42.2024.01.03.12.28.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 12:28:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15983-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=fvcrFrwp; spf=pass (google.com: domain of linux-kernel+bounces-15983-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15983-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 90A52B244F9 for ; Wed, 3 Jan 2024 20:26:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3739F1D540; Wed, 3 Jan 2024 20:26:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="fvcrFrwp" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E1D71D522; Wed, 3 Jan 2024 20:26:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Received: from [192.168.192.85] (unknown [50.39.103.33]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id E2C443F2A3; Wed, 3 Jan 2024 20:26:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1704313591; bh=gujZVJVMpl06CEwjpYkzgXTz5Wv2wosy7hx4wRR1cC0=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:Content-Type; b=fvcrFrwpWS2flgwIesbsjz/FmAuzawLg3cBse8OI3bFhMZ96qMA4jbiI3ZQKUk8rh oh0HFaAqZ6G5FMKxcNSPKPKgFcEVw2NDt73oRgIypj0hPPFkJcidNNV+MqocAtAXk+ ORSpDRPJznic64gfpSDJbqhGWeMUHn+Ei7kFCel8fPHWiF88vPZE85yvGS64BeRdV4 w4llPvTngGFYaVyKYiUOZB2rktmfe4EVTZ/iKthf1CyfOdXBGD71F03Zaq3iNE9YML Q5qYyvZhJXsZnbRYklTNGYJPiqiDuYmPxOpBYaqiHaarlhOqOH+hGFbMYjHRlJMKO/ g/jIt1y5USJYg== Message-ID: <94b09a9a-4e2d-43d4-9230-f72662817086@canonical.com> Date: Wed, 3 Jan 2024 12:26:25 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: John Johansen Subject: [GIT PULL] apparmor: Final fix for v6.7-rc8 To: Linus Torvalds Cc: LKLM , "open list:SECURITY SUBSYSTEM" Content-Language: en-US Autocrypt: addr=john.johansen@canonical.com; keydata= xsFNBE5mrPoBEADAk19PsgVgBKkImmR2isPQ6o7KJhTTKjJdwVbkWSnNn+o6Up5knKP1f49E BQlceWg1yp/NwbR8ad+eSEO/uma/K+PqWvBptKC9SWD97FG4uB4/caomLEU97sLQMtnvGWdx rxVRGM4anzWYMgzz5TZmIiVTZ43Ou5VpaS1Vz1ZSxP3h/xKNZr/TcW5WQai8u3PWVnbkjhSZ PHv1BghN69qxEPomrJBm1gmtx3ZiVmFXluwTmTgJOkpFol7nbJ0ilnYHrA7SX3CtR1upeUpM a/WIanVO96WdTjHHIa43fbhmQube4txS3FcQLOJVqQsx6lE9B7qAppm9hQ10qPWwdfPy/+0W 6AWtNu5ASiGVCInWzl2HBqYd/Zll93zUq+NIoCn8sDAM9iH+wtaGDcJywIGIn+edKNtK72AM gChTg/j1ZoWH6ZeWPjuUfubVzZto1FMoGJ/SF4MmdQG1iQNtf4sFZbEgXuy9cGi2bomF0zvy BJSANpxlKNBDYKzN6Kz09HUAkjlFMNgomL/cjqgABtAx59L+dVIZfaF281pIcUZzwvh5+JoG eOW5uBSMbE7L38nszooykIJ5XrAchkJxNfz7k+FnQeKEkNzEd2LWc3QF4BQZYRT6PHHga3Rg ykW5+1wTMqJILdmtaPbXrF3FvnV0LRPcv4xKx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6S77g6gzYYHmcQOWP7ZMX+MtD4SKlf0+Q8li/F9GUL p0rw8op9f0p1+YAhyAd+dXWNKf7zIfZ2ME+0qKpbQnr1oizLHuJX/Telo8KMmHter28DPJ03 lT9Q Organization: Canonical Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Linus, Please pull the following fix for the apparmor move_mount regression - detect that the source mount is not in the namespace and if it isn't don't use it as a source path match. This prevent apparmor from applying the attach_disconnected flag to move_mount() source which prevents detached mounts from appearing as / when applying mount mediation, which is not only incorrect but could result in bad policy being generated. The following changes since commit 610a9b8f49fbcf1100716370d3b5f6f884a2835a: Linux 6.7-rc8 (2023-12-31 12:51:25 -0800) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/jj/linux-apparmor tags/apparmor-pr-2024-01-03 for you to fetch changes up to 8026e40608b4d552216d2a818ca7080a4264bb44: apparmor: Fix move_mount mediation by detecting if source is detached (2024-01-03 12:10:29 -0800) ---------------------------------------------------------------- + Bug Fix - Fix move_mount mediation regression when source is detached ---------------------------------------------------------------- John Johansen (1): apparmor: Fix move_mount mediation by detecting if source is detached security/apparmor/apparmorfs.c | 1 + security/apparmor/mount.c | 4 ++++ 2 files changed, 5 insertions(+) --------------------------- diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c index 38650e52ef57..2d9f2a4b4519 100644 --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c @@ -2373,6 +2373,7 @@ static struct aa_sfs_entry aa_sfs_entry_policy[] = { static struct aa_sfs_entry aa_sfs_entry_mount[] = { AA_SFS_FILE_STRING("mask", "mount umount pivot_root"), + AA_SFS_FILE_STRING("move_mount", "detached"), { } }; diff --git a/security/apparmor/mount.c b/security/apparmor/mount.c index fb30204c761a..49fe8da6fea4 100644 --- a/security/apparmor/mount.c +++ b/security/apparmor/mount.c @@ -499,6 +499,10 @@ int aa_move_mount(const struct cred *subj_cred, error = -ENOMEM; if (!to_buffer || !from_buffer) goto out; + + if (!our_mnt(from_path->mnt)) + /* moving a mount detached from the namespace */ + from_path = NULL; error = fn_for_each_confined(label, profile, match_mnt(subj_cred, profile, to_path, to_buffer, from_path, from_buffer,