Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2849400lqt; Tue, 23 Apr 2024 03:40:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX0Jls4zdUB2orE+qWSe9M1J0cKMREAOxt2UgS/lkFZw3VJHAqPyUICexjyZTvix6g0X60ZgHdQSs4hlAIJKt10spvMZ22skiMXueg8zw== X-Google-Smtp-Source: AGHT+IEacfAB1Y5On/F0SnlfpcB8vQRWtHUmHpPp7YVtPzw5IBmQ30C1znbJ5Hg9m9OoLcEy3gbM X-Received: by 2002:a05:6a20:dd9d:b0:1a7:7fbb:2621 with SMTP id kw29-20020a056a20dd9d00b001a77fbb2621mr14077514pzb.48.1713868840714; Tue, 23 Apr 2024 03:40:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713868840; cv=pass; d=google.com; s=arc-20160816; b=U34Nu6UqlW3PCyrJ/hbEJLkxWRRcrg6yG2ZzBP2phQkkUMgdha5m/8rOo7/vowwdIL UkDBtAB3Ef7rJQ3TEf0hg5U9744/xTS0XgtU3UY2ZK5S0zxqZreJs3BRPU4LL9XNmiCG v10bTNmlcz9JyrFbtE+lzoZavWTwDF+aAyEjKtITXGrkmOG0PQtFntH9AvQNDEpHAFH2 OZrtA5OV7I4yzzIkkyUBghZrzbNgDkpHmiRXDTharLYstXPJ0GI9BQx4alYLhf41fu/D nENd5u8NvHr4TumbVoV04XqGJ7gnwmhNsoo3CeqkfESky3e/c5XJHCbNef60ksv8O1Qu gokw== 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=DTN8m/cCmxiNz158XvI3+KxfPWKaEUQgWEoaJc57/BQ=; fh=Wx9ka+rkxAjZiV9sz7UaMVO/giEs2rOJHJVItLV1tm8=; b=Y2YqUquf1hA9T/PX9zkY65KPELHMR3wNh6tHA2s0jmRDjvpI6b4YiCZFUoKPMlioW2 /X3/qfazUzD5GnhXnqxuyGU708WWKKkoag2dlaJDjob2Nh4Wykbg2ROTmF6y5NFi7omL TMDAaUVU6vZ+ut8leqPBYvQ4E7QFXulG39ZWmbZi5JuHS6Lqq8VhD+SaKwi+ZohOEVX5 ld1rO+OQjbODPjE8WB2AuDn+HiwYqebdmK51zliFEDxGsxB/vk8RnvK1enAZQL5/qGBX s8ZQ1+UVFlwF1fgfUuc/NH/1O1ZhcuMjXe7/PgcaU12Z6sIL+ExH2Lkg462RXsuaLR3x HozA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=F888TDTK; 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-154882-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154882-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l4-20020a635704000000b005e84291790dsi9580650pgb.581.2024.04.23.03.40.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 03:40:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154882-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=F888TDTK; 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-154882-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154882-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 23934281FA1 for ; Tue, 23 Apr 2024 10:40:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9465634EA; Tue, 23 Apr 2024 10:40:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b="F888TDTK" 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 8E54F1848 for ; Tue, 23 Apr 2024 10:40:30 +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=1713868834; cv=none; b=SSbTOGwsvXZRephuLRtDTyc3oyCeQHigyQNSE4gRF3mqQlChFp/+eHcdMvqG7MBWn/Mb7nM+9/nLFTPdng3DpcqYGL6zMoitPEGZppsExnb0PYA2LNheh221l7dm20K8oXzy6rqZFLCAhJ74boGUNRiXXgcufDvoJu4VGM/wdJM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713868834; c=relaxed/simple; bh=PnWUD+Sqv3+TieM+uGRjPKScvH7Uy5HVrA46uvF1aIE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=hMV2hUKRelq2KVTFHwW4VNkfBin5ju/eujrtiSY5yDuCzZvSBl//nvH9qZYnYnMeCaVegJl+RD91AF6aTo2k1wGHdhw7zxypyk82AxcTUd9XUsLQNvR0i34z7Y7eeSz4gC1IyCxpuItPNzGz5uNOp/nOqFy7GU/o8MvUYvltDRA= 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=F888TDTK; 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-39.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-39.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:3b13:0:640:bf9:0]) by forward100b.mail.yandex.net (Yandex) with ESMTPS id E4B9860CEF for ; Tue, 23 Apr 2024 13:40:22 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-39.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id MeHq0QCOr0U0-cNh1w8fB; Tue, 23 Apr 2024 13:40:22 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1713868822; bh=DTN8m/cCmxiNz158XvI3+KxfPWKaEUQgWEoaJc57/BQ=; h=Message-ID:Date:Cc:Subject:To:From; b=F888TDTKaJMOkqNoYUu2sfulrDHZUIsAMsMGZOBYY4E0dAafM6KNOix/MQXtwYVty fS3lj04n828fKhAKqMK4r0vQjyBI7JgPgv/mb1ehqF5lk4PbABbVoIRl3vFc9qO2P2 Tiyv5OJSpppCmTA8qMQYB8tjVE/4acotfnFGOCvc= Authentication-Results: mail-nwsmtp-smtp-production-main-39.myt.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Stas Sergeev To: linux-kernel@vger.kernel.org Cc: Stas Sergeev Subject: [PATCH v2 0/2] implement OA2_INHERIT_CRED flag for openat2() Date: Tue, 23 Apr 2024 13:40:00 +0300 Message-ID: <20240423104002.9012-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 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