Message ID | 20240219190345.2928627-1-mic@digikod.net |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-71862-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1487288dyc; Mon, 19 Feb 2024 11:22:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWkEFpDUG3bPbAwPYjnMdKTyjB/EjqCDgjcoHt6pWvCPI3gK+G5p6/ZVLHmd6gCNsPxxW3KQguOVy81sJ/OjfsqASReIQ== X-Google-Smtp-Source: AGHT+IEFuPjnU9BmHN+fdWJlfz+VjF5OtlFm5quAC5QsiO9ye8n/GgCik9YQpJhddfv33eI8HjU9 X-Received: by 2002:aa7:c610:0:b0:564:5ed6:5ac2 with SMTP id h16-20020aa7c610000000b005645ed65ac2mr3214803edq.36.1708370552412; Mon, 19 Feb 2024 11:22:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708370552; cv=pass; d=google.com; s=arc-20160816; b=yarv2BmVHFD6ootM5kVHzlufeQvRsznr9hfFGlLIs+QA67VCePqvM/4L4++VKbcg2y ouob8mE+Fwx+D1Vcd2S+pdUy3JOeoEqEilGzGYd95ZbcDMne2lGEtMFLQlu6BnVoorLu XiEQgXa4fxuCRD96XwLcew1bPy2ru3ZqZB6OH/2/Bq+TINznVTbBL2CtEVQX+7pEyBVU +ovsjrHOv9ZwYFw7rABsyI0+Kb5HVkizdUK5LQdoumt4YvnwjIdzv6mdZNJfmTxb4sLp TExqSg2HZd8sqhDxFta9kPeVHLH3wx7vR47EPN1GZvpeziwUC6ap8FYTfj8SWCG/y2B7 N7zw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=lStFc/jOLXluSDksA1X2bwl745EY+ayYp77myY2/f+s=; fh=RD9RXf5W8TUhgnEUGDkhSw4CBQCC7N8cn5VDBQJJCm4=; b=GO5/jgrJxgG07VFAb08e5v5JGTbRsZQYYBZVcF/DkARcujmZu6MN5KyH5djwdLAeoA 4EiDi5SOsFS79SKYv+R0xN2Yz8kUSol9aolI5ih4HWqzhkmF/KROXXdJ79r+SyKy/Awz pUeDdauTksiDiOppkdLi386SoguLPSPjgE4Z+rOs0GuG7ka1uXE8REs09RaE52ut5QE6 dNkrOgTpfdAV5g9g/qE/2hiF6XVFeKd9oH2fd8EUrBksBsm2Mu6KP/ER2UIEwswu5GlX +reVnvW8Yg2y7FLR9EncaoAWzWSfOwsPcZOkElixzVwdJyXlUAFabgAqcmnigElNHs9k lxdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=oYEBpSyH; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-71862-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71862-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id w15-20020a056402268f00b005645c29f309si1612818edd.592.2024.02.19.11.22.32 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:22:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71862-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=oYEBpSyH; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-71862-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71862-ouuuleilei=gmail.com@vger.kernel.org" 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0ADAA1F217A8 for <ouuuleilei@gmail.com>; Mon, 19 Feb 2024 19:22:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1686C5101A; Mon, 19 Feb 2024 19:22:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="oYEBpSyH" Received: from smtp-190a.mail.infomaniak.ch (smtp-190a.mail.infomaniak.ch [185.125.25.10]) (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 4F17944C86 for <linux-kernel@vger.kernel.org>; Mon, 19 Feb 2024 19:22:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.25.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708370532; cv=none; b=GjigZix2Jl3kFEkF3onLDbC5DsOgh0PSeR/D1sWciGsMQE4siR6qdJXIqbB00tJ0gxOYZkTWNSrklXA2ALgSGXiE0Qr445D6cSlLWSsAQTnPShjrjUEfHiixfg2WNSc8/fTZsdy6zv7IChNc6hPegzEcTc58zy962MtvzQGbTgA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708370532; c=relaxed/simple; bh=2Hj9UWhrDgzjOkOL5rsGTh1N6ZOemj+WfIpokHEQmEQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=jSjpXxn65YcPbjjU0q81G88ZY02mVxftFXMWNADPgzxT8ZFkoDAwYPnZI2GU1GV++9B+nsd74LeKTKMYBxVQIvhbjRpRfb1evSxUq5MXz2qLDyoDtBzTJDgT1BoNOZAnfzbt6WRZsvinJxPT3dLtp5cnfBeQS+WnFWTs9j1qm4E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=oYEBpSyH; arc=none smtp.client-ip=185.125.25.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Received: from smtp-4-0001.mail.infomaniak.ch (unknown [10.7.10.108]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4TdsQN4czSzMq2jt; Mon, 19 Feb 2024 20:03:56 +0100 (CET) Received: from unknown by smtp-4-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4TdsQM6BKYzHc4; Mon, 19 Feb 2024 20:03:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1708369436; bh=2Hj9UWhrDgzjOkOL5rsGTh1N6ZOemj+WfIpokHEQmEQ=; h=From:To:Cc:Subject:Date:From; b=oYEBpSyHPf3yCOV1oKVMu8oMFvPoQCSBIkNLD+IxvPoRrocGTlH6/8tVFY6grA/4c HrGPkpJHLNPY4iMEKl0tx04ZbxKvFox0qZDC43+cqxrcm7kdx5k9AWmXmBj0QePO/+ gDw7Cba472cs3BaH1+HVVVML+M4YsWMtlhVpbagM= From: =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= <mic@digikod.net> To: Arnd Bergmann <arnd@arndb.de>, Christian Brauner <brauner@kernel.org>, =?utf-8?q?G=C3=BCnther_Noack?= <gnoack@google.com>, Jann Horn <jannh@google.com> Cc: =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= <mic@digikod.net>, Kees Cook <keescook@chromium.org>, Konstantin Meskhidze <konstantin.meskhidze@huawei.com>, Paul Moore <paul@paul-moore.com>, "Serge E . Hallyn" <serge@hallyn.com>, Shervin Oloumi <enlightened@chromium.org>, linux-fsdevel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] landlock: Fix asymmetric private inodes referring Date: Mon, 19 Feb 2024 20:03:45 +0100 Message-ID: <20240219190345.2928627-1-mic@digikod.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Infomaniak-Routing: alpha X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791356360417992004 X-GMAIL-MSGID: 1791356360417992004 |
Series |
landlock: Fix asymmetric private inodes referring
|
|
Commit Message
Mickaël Salaün
Feb. 19, 2024, 7:03 p.m. UTC
When linking or renaming a file, if only one of the source or
destination directory is backed by an S_PRIVATE inode, then the related
set of layer masks would be used as uninitialized by
is_access_to_paths_allowed(). This would result to indeterministic
access for one side instead of always being allowed.
This bug could only be triggered with a mounted filesystem containing
both S_PRIVATE and !S_PRIVATE inodes, which doesn't seem possible.
The collect_domain_accesses() calls return early if
is_nouser_or_private() returns false, which means that the directory's
superblock has SB_NOUSER or its inode has S_PRIVATE. Because rename or
link actions are only allowed on the same mounted filesystem, the
superblock is always the same for both source and destination
directories. However, it might be possible in theory to have an
S_PRIVATE parent source inode with an !S_PRIVATE parent destination
inode, or vice versa.
To make sure this case is not an issue, explicitly initialized both set
of layer masks to 0, which means to allow all actions on the related
side. If at least on side has !S_PRIVATE, then
collect_domain_accesses() and is_access_to_paths_allowed() check for the
required access rights.
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Günther Noack <gnoack@google.com>
Cc: Jann Horn <jannh@google.com>
Cc: Shervin Oloumi <enlightened@chromium.org>
Cc: stable@vger.kernel.org
Fixes: b91c3e4ea756 ("landlock: Add support for file reparenting with LANDLOCK_ACCESS_FS_REFER")
Signed-off-by: Mickaël Salaün <mic@digikod.net>
---
security/landlock/fs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/security/landlock/fs.c b/security/landlock/fs.c index 90f7f6db1e87..f243c6a392ee 100644 --- a/security/landlock/fs.c +++ b/security/landlock/fs.c @@ -1093,8 +1093,8 @@ static int current_check_refer_path(struct dentry *const old_dentry, bool allow_parent1, allow_parent2; access_mask_t access_request_parent1, access_request_parent2; struct path mnt_dir; - layer_mask_t layer_masks_parent1[LANDLOCK_NUM_ACCESS_FS], - layer_masks_parent2[LANDLOCK_NUM_ACCESS_FS]; + layer_mask_t layer_masks_parent1[LANDLOCK_NUM_ACCESS_FS] = {}, + layer_masks_parent2[LANDLOCK_NUM_ACCESS_FS] = {}; if (!dom) return 0;