Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2861060lqt; Tue, 23 Apr 2024 04:05:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUy922p31EwmAA5FNzaN3bf+75rEfSzh0JT0VU082ylijA+i18CGFSoecigmmLiLjRSWWvTFoMU9j9PwTToGjeFQWoTYDjgmdL+d5UG2g== X-Google-Smtp-Source: AGHT+IHkE8LumrlibQ9Aq/bxDL7hP8Nwqnewej+ejO6HvAn6oU1wx3vJu2P+WxEQA8kG5SaE1bf1 X-Received: by 2002:a17:90a:fc90:b0:2ae:6e16:da91 with SMTP id ci16-20020a17090afc9000b002ae6e16da91mr3200763pjb.29.1713870359428; Tue, 23 Apr 2024 04:05:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713870359; cv=pass; d=google.com; s=arc-20160816; b=XL8NK1mCaf1Sty2NjRAo29j7JcQNVCqKFQdsNWdxkesc0dnQ2on4m39MnqtAeaPmCZ leHAalMvBMmCwlj2YOBazPBJpy0L3KqyQKtoxSG5WlY/uyPhGRGEppiCnkjt9kh0pGaB bmhhrzfdMC9X1lkiaqcRnLwD4V6NjCTCGLfHfXo561157/GMIvLW4IE72CrNJWoxeC+V admBzej7l5GcAiC4AcJiGU37SXdnLsQxHNuSfcs88K3z1m4iS+lAmFNA9cId1TXG+hvd 62KDPJQRLpAVWWnOkTZS+UhFHAZi9AWyktiOYdPFmg6uK8WeqAvp3o8Pyob1IjQYu0f2 M2Ew== 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=rcVAqztPFXwxu1IVvlYKhQ3ApGxSCP39aIlJfSgJu/g=; fh=g5S+5xWGh1LSoCH6S0g+mSoCWam8q4GLMeWghGKi028=; b=BV5nv/W8477stU59arJh6jXuD+BskZJbgm2PC39GuzGpUYpL1yv9ZrlEhIxpN6nSgt QywHrUoNttV5uMNKr36VLJ/IsV/YB/oMATZAyafikozDBmNnKm5vA2IvRbxZKKk7ia74 r/WRqnyStBc8AM3H7XzbJux/tBejpMahyqK/EV82M/LDLWZ4mdG3UOE6/XxXUYGHxJds HmOpk6hQWWYcw2eqMlWYI6/1SvXTNkWvOlLAZYOHl25DFGJf1mX1rwV2JoCBYZA0y//L rsvQpVvWQ00CdTwRmT9/YLh3eN1RZ8IQ6OCG/Dflrt9u/QEK68ZsyV+VZu1BTuFnPRkk vcdQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=T4yzQXio; 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-154928-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154928-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y7-20020a17090aa40700b002adad1f11desi3835549pjp.12.2024.04.23.04.05.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 04:05:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154928-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=T4yzQXio; 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-154928-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154928-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 426EF28B9C8 for ; Tue, 23 Apr 2024 10:56:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D6E77E58E; Tue, 23 Apr 2024 10:55:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b="T4yzQXio" Received: from forward201b.mail.yandex.net (forward201b.mail.yandex.net [178.154.239.156]) (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 145AD60B9C; Tue, 23 Apr 2024 10:55:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.154.239.156 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713869707; cv=none; b=L/Vgrs2u8QBqMRNbSfX7EgagmL/LgEJ13l7Ao+jK+xhGF6rs8HhyMQsdMMbtSSGhHEPOOzlQe3txU+zYe54NEl9hZIqGgSlLIZBG4KQSFaHnPFhAQ7s7HE7Hsyb0HDizuJeIlcFD+h5djNtZDkkc2NG7VDbU7r0ENbz5o0RcSWM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713869707; c=relaxed/simple; bh=kpU+YvKsOPGG4l8EOerUYySk9apiWG5KGfFDI79DrpM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=ockvQMesRvjr6VtLRdF0nnaCptMP6+TqeUSwA4qsQuXTNe6PmG+WQPLk0UHQmRfEIT9kvf6ZsP+9viPtLji1Vpot0t2L7p2TIiuBNPZY7sdd9khvc+M3P7oZTnNnWZpxeRvGKqbZ1IE44DM/xcz6CWjRJQeLB9v0se8WxzECvuU= 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=T4yzQXio; arc=none smtp.client-ip=178.154.239.156 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 forward101b.mail.yandex.net (forward101b.mail.yandex.net [IPv6:2a02:6b8:c02:900:1:45:d181:d101]) by forward201b.mail.yandex.net (Yandex) with ESMTPS id E187B64BF5; Tue, 23 Apr 2024 13:49:39 +0300 (MSK) Received: from mail-nwsmtp-smtp-production-main-85.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-85.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:b1a0:0:640:e983:0]) by forward101b.mail.yandex.net (Yandex) with ESMTPS id 9CD7B60AD7; Tue, 23 Apr 2024 13:49:31 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-85.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id TnHoiCGOm4Y0-ubiPgIUO; Tue, 23 Apr 2024 13:49:30 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1713869370; bh=rcVAqztPFXwxu1IVvlYKhQ3ApGxSCP39aIlJfSgJu/g=; h=Message-ID:Date:Cc:Subject:To:From; b=T4yzQXio8HLOtjYRtsiEmElOXSaMHqlXCxvZbHdLDSbLMBuEaXvznLM7Vdf/1aweh IUYyflegoE4dmPV09i9jfk2lnVLH9iFaYx+eQowRfDpTWuO0YfA2r14688gIqnuLeR BVFSKDQcK24iiqMVCgVXay0GZ7NOVtIK58J7tzSM= Authentication-Results: mail-nwsmtp-smtp-production-main-85.iva.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, 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 13:48:22 +0300 Message-ID: <20240423104824.10464-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: 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