Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2858758lqt; Tue, 23 Apr 2024 04:02:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWIo1uLScFvhS0fSlHp4D4z4fHxwhZz0FM8m29NBki47p1UansYyslQQo7d23NElMa4uO1R/BaSA7lLpw/soQw3ZzaMbZESwa/zK3R41Q== X-Google-Smtp-Source: AGHT+IH50CW2mhTVByCUy+FoJoOB+R83Og/M5/ALR07zkYa434Z3tQVzl6VHartzOwhBSVoO10Vf X-Received: by 2002:a05:690c:6c86:b0:615:4f55:d06c with SMTP id is6-20020a05690c6c8600b006154f55d06cmr13684691ywb.29.1713870141838; Tue, 23 Apr 2024 04:02:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713870141; cv=pass; d=google.com; s=arc-20160816; b=LmIIAPGYFnvtMmwK9gY1Qc06nVz/mcgcWcgwsZLt97jBIy0l3a1/BN7ghoF7AmlgfH JHax0lZItsnnPxNIZMUjHWq7LJ7MiI8e0mnt2Wnws52b3YqcJF7vM4SM4BypAQ6virke +xDuIX9B3UaVRq5VxKdriXp06cAawzN5ADTkvKiD8Sp+NNHGig00Zu4pU68xAgR3PJnD eqXXNCwBSZVc9cC+iK9ohLpnpetafKy6EldDw1hXdfIEw87TafNbSh2TKnbXUBk3x9XP PD+zDX+Xr4IrjZ9rmk6LhvhpGZCXJqkwtw+NsscPuk2LzLUI1sht6JHNM+1Ok1PKlQ1d iNeg== 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=mSa2L/gvUjyMbfUcKWg0w7NoP0HQhg8yvcY14pMGA/8=; fh=YcAwmNz4oxqk24GH0R6vlSSN1FC+nTPZ8QzobDeNzRY=; b=ogRtjM/AQjN1JVLjz2dRzAEwSsZzvVoHHbzIsOmq/nqC7vmD9aQ7q+AYVCv7Fkfm7S PHV1j+rYdmW/eyII4Fv6GCCWgz7foayk0zVoE9noZC+raGUrUugKBOrg6oXbud/KlU7p QNrc18t4OuDTuRCboGSCIi9+Yjf/FuQYV5q3RoDY33OqaO/Lu+UgNDhs2k3N9xskymfc w786tqkaxMrL/Ei5eemTT3iOD/+lQhNWJXZJ9r2ath5cRSzxpWy05cZBKgGAhTErlTN0 FLnSTCWY0NgCglONyAvbwB7U0yvfXEWlpI5tUsR/EET6t/y7LlHzejd/klEZgPuF2CtE qTNw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=lnoPPGqT; arc=pass (i=1 spf=pass spfdomain=yandex.ru dkim=pass dkdomain=yandex.ru dmarc=pass fromdomain=yandex.ru); spf=pass (google.com: domain of linux-kernel+bounces-154935-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154935-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id l2-20020a9f3282000000b007e89c77687bsi1705370uab.141.2024.04.23.04.02.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 04:02:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154935-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=lnoPPGqT; arc=pass (i=1 spf=pass spfdomain=yandex.ru dkim=pass dkdomain=yandex.ru dmarc=pass fromdomain=yandex.ru); spf=pass (google.com: domain of linux-kernel+bounces-154935-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154935-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 899A71C21DEB for ; Tue, 23 Apr 2024 11:02:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D2BA075817; Tue, 23 Apr 2024 11:02:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b="lnoPPGqT" Received: from forward100b.mail.yandex.net (forward100b.mail.yandex.net [178.154.239.147]) (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 18E9C18645; Tue, 23 Apr 2024 11:02:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.154.239.147 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713870131; cv=none; b=JpiKVjh479nt6GRcCO782nqcztw7TKirR89EbQghY4+Tk0T/HuQlzzFEqDOxdWyD1cm5hzchQpS5kn9upEVYFwbywhohmqcnXOhAXNb8ptBp6cjVCyyxVkf2VW+eXcsgGetXEQjYQa/Kxr3kVYgdHFzaG2P+qzyeol/SP4wCZ4g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713870131; c=relaxed/simple; bh=dWMYgl5bt4WqkIJy1ceIMBjSNQzKYDGhm53JaH26Lws=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=q0tVPVnLSPbu/iIq7zzui8olOIDYb4KLo9MCJYnfoO2RK7gG+4FwzVaaAsHuA9NzlowEt1+hTyjMSudWdXtzd2WjqIX3/Ydio9GyZWQTWZ3al8ah8vcyoBMNKuPi3dPzq3DHuYUV/8vqassmKOAn8u7d/NfKh1QVNIeAoSNvSa4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru; spf=pass smtp.mailfrom=yandex.ru; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b=lnoPPGqT; arc=none smtp.client-ip=178.154.239.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex.ru Received: from mail-nwsmtp-smtp-production-main-42.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-42.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:141d:0:640:ccff:0]) by forward100b.mail.yandex.net (Yandex) with ESMTPS id 23DA460AD4; Tue, 23 Apr 2024 14:02:04 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-42.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id 22IG0mHOiCg0-x3jtm1mn; Tue, 23 Apr 2024 14:02:03 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1713870123; bh=mSa2L/gvUjyMbfUcKWg0w7NoP0HQhg8yvcY14pMGA/8=; h=Message-ID:Date:Cc:Subject:To:From; b=lnoPPGqTNrRLb/QaMW3ZXdTjL9CHUkEAZqN5K8MjQZkq8CkDQci7BZBDjGfSkLX2N WB4K+9iUPAkWoCjL21dJE7VijI8eCjyEY7j+Uh1DYvTtRg4xYkfKu/q78+38Do58Ax wA/dAuewPoYrdOAPadoxdhBwaB6ed0eheRNM/Z+M= Authentication-Results: mail-nwsmtp-smtp-production-main-42.myt.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Stas Sergeev To: linux-kernel@vger.kernel.org Cc: Stas Sergeev , Stefan Metzmacher , Eric Biederman , Alexander Viro , Andy Lutomirski , Christian Brauner , Jan Kara , Jeff Layton , Chuck Lever , Alexander Aring , linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, Paolo Bonzini , =?UTF-8?q?Christian=20G=C3=B6ttsche?= Subject: [PATCH v2 0/2] implement OA2_INHERIT_CRED flag for openat2() Date: Tue, 23 Apr 2024 14:01:46 +0300 Message-ID: <20240423110148.13114-1-stsp2@yandex.ru> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch-set implements the OA2_INHERIT_CRED flag for openat2() syscall. It is needed to perform an open operation with the creds that were in effect when the dir_fd was opened. This allows the process to pre-open some dirs and switch eUID (and other UIDs/GIDs) to the less-privileged user, while still retaining the possibility to open/create files within the pre-opened directory set. Changes in v2: - capture full struct cred instead of just fsuid/fsgid. Suggested by Stefan Metzmacher CC: Stefan Metzmacher CC: Eric Biederman CC: Alexander Viro CC: Andy Lutomirski CC: Christian Brauner CC: Jan Kara CC: Jeff Layton CC: Chuck Lever CC: Alexander Aring CC: linux-fsdevel@vger.kernel.org CC: linux-kernel@vger.kernel.org CC: linux-api@vger.kernel.org CC: Paolo Bonzini CC: Christian Göttsche Stas Sergeev (2): fs: reorganize path_openat() openat2: add OA2_INHERIT_CRED flag fs/internal.h | 2 +- fs/namei.c | 52 +++++++++++++++++++++++++++++------- fs/open.c | 2 +- include/linux/fcntl.h | 2 ++ include/uapi/linux/openat2.h | 3 +++ 5 files changed, 50 insertions(+), 11 deletions(-) -- 2.44.0