Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1060084lqd; Thu, 25 Apr 2024 05:09:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWnk9+3zQohKW4asX7fINMxSHkzPGkECBg3u/maxUTSX/Mtas34K8+LESC98VQuWPxuEWr3u2x96OZRPcGmTDdHqwzT3UXseVK0w0Ln2w== X-Google-Smtp-Source: AGHT+IEoe6KKFmODH8URZEYtAn8tK4rBAaaWAc2Bv8GcK6Kgtu4dAjefGtO46bUAJXpQnt3pgbpQ X-Received: by 2002:ac8:7fca:0:b0:43a:45da:192a with SMTP id b10-20020ac87fca000000b0043a45da192amr2186646qtk.66.1714046947085; Thu, 25 Apr 2024 05:09:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714046947; cv=pass; d=google.com; s=arc-20160816; b=p7brDWnw4NMpGlXnQfPJ1msldHS9fj+Cc0jdrPAY+vIO1i7lRiZHG+AvwCEWvnIOAU kR3/elr5EgIgOPECILGYOREccO1v32a47uEryEXdhObQtrYrvlQmfKoBfKzHyO0by/pf Ea4I0tz3G5XAElUm+z+ssWfp6KH9/IziVIJvhZydEH2RiqKqgD8HnoJ/UyjcelpTIWuN Ig/Mu6k64izu/TvLx83asVuxVguCwndGBHF/PQY2pIxOJrl0XjwM9Mi6gVch2C4nQ/S7 7f2rzjF6KbCVkMN5NKzZGx7DlPFei1R7g2Uejpd0CjYe3U0J0xlO8DgDe67UqrI2wTAT 2afQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=QJ/+TaI7LYFNkVXAUM2e6kETsZ4oE7E3AR7EDPAymsw=; fh=sNWPPTrp8jqGmI5M4YAkYbXL8VBO5cJYNzMHekgu4Ek=; b=qVY28BKfzs7zWARol0aJUISBkEtEqFVVpSTZc8DxOwZQ4id/3e9/b2lYy8Pyv+RszA peKr6oAxjDlYp2+tRnHTp7woSg5ZCU5U/uFEJzhFW/FK/jwHiHesugNqH/fZ/Mnz+Ulo 060mG7dJi1LwKAokSaFlRJvVho6vEHW7n9/txXA1V3d+OG2kU8Swjg29tGzMw2aNPVwy Qt6ZGRSsqI64DQAjaDdmL4FZeipo02o1SkaN4d8tl7/NnvEw4DJRk3f/o7Vz9yzFmjwa 4E5p+i2iLvcWbt3/zcjJlvK/wnKMOnwTiv0AduKuHoi1Ra4opvJ/kUOSilYi3iNSNnyS zMsA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bOlIw5E4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-158506-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158506-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ge26-20020a05622a5c9a00b00439755ce804si12859671qtb.231.2024.04.25.05.09.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 05:09:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158506-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=@kernel.org header.s=k20201202 header.b=bOlIw5E4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-158506-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158506-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C740E1C20C95 for ; Thu, 25 Apr 2024 12:09:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A3C112BF15; Thu, 25 Apr 2024 12:08:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bOlIw5E4" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8164712B159; Thu, 25 Apr 2024 12:08:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714046915; cv=none; b=QWqdNrGscKe2IglXrq23o3IRj64wOkFGP5ANY87zKCS93kGCYPj9iJWXlMcG5PwCiAu5+iY+IcJoawmoKU2VLTZSUMSejj15cQf+9rNNddz1n2AmexrFtqYVdrZXE2xCCAoJORuO+IiJt7QgGWkDYMeaQuPNmfXgf6PIKYO1ICI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714046915; c=relaxed/simple; bh=QJ/+TaI7LYFNkVXAUM2e6kETsZ4oE7E3AR7EDPAymsw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=m/tobfTsLJfzLUqz6vvT7+5wW9Q1Mvf96a9j1y/CjzDpFOozgNd/mi3DDWPeSkgzMIvhXXua8d61F3rvLl1Zyn+dODRBvZLzXG+GW01JcS6/EalyZlCw5hLGOMASFe5yEAa1IMqEy+XYJRllugiU4ciKy0EVsBl3z4yiG+3Cydg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bOlIw5E4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 906E8C113CC; Thu, 25 Apr 2024 12:08:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714046915; bh=QJ/+TaI7LYFNkVXAUM2e6kETsZ4oE7E3AR7EDPAymsw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bOlIw5E4WknFvh5vVANsGtX1zP9GNXAj6BdyeFZYv8CKMxB183hLztSJqBenWQ/BQ VuHJIcAAWKPbrFGOKmH59x+jTcyKdR4pqdOgTjLulMKF0SxVx3SrTz1s3L1O1UTE4v 9sse07Qg4KSV1x/h+1dhdbZKaGCsltSz6MA16Ywe4tnbEYmmvQyD2uHpwHFzJ7jaKY 6D9GRcLCnD2PCnyrzC86OEdS6CJ+NQFUkkYeR2bjI1nT1q1QVBVP3BmLOpJpynYMGC QG2x92cZrbHu+RASqcDR9fqkM7Z5j7LEwpYLQ3vrnOmUXOR6ErVKqVX63QDErb5ZBY 84HK+TIsDyZhA== Date: Thu, 25 Apr 2024 14:08:24 +0200 From: Christian Brauner To: stsp Cc: linux-kernel@vger.kernel.org, Stefan Metzmacher , Eric Biederman , Alexander Viro , Andy Lutomirski , Jan Kara , Jeff Layton , Chuck Lever , Alexander Aring , David Laight , linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, Paolo Bonzini , Christian =?utf-8?B?R8O2dHRzY2hl?= Subject: Re: [PATCH v4 0/2] implement OA2_INHERIT_CRED flag for openat2() Message-ID: <20240425-loslassen-hexen-a1664a579ea1@brauner> References: <20240424105248.189032-1-stsp2@yandex.ru> <20240424-schummeln-zitieren-9821df7cbd49@brauner> <6b46528a-965f-410a-9e6f-9654c5e9dba2@yandex.ru> <20240425-ausfiel-beabsichtigen-a2ef9126ebda@brauner> 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-Disposition: inline In-Reply-To: > But I am sure you still don't understand > what exactly the patch does, so why not > to ask instead of asserting? > You say uid/gid can be stolen, but no, > it can't: the creds are reverted. Only > fsuid/fsgid (and caps in v2 of the patch) > actually affect openat2(), but nothing is > "leaked" after openat2() finished. I say "stolen" because the original opener has no say in this. You're taking their fsuid/fsgid and groups and overriding creds for the duration of the lookup and open. Something the original opener never consented to. But let's call it "borrowed" if you're hung up on terminology here. But ultimately it's the same complaint: the original opener has no way of controlling this behavior. Once ignored in my first reply, and now again conveniently cut off again. Let alone all the other objections. And fwiw, the same way you somehow feel like I haven't read your patch it seems you to consistently underestimate the implications of this change. Which is really strange because it's pretty obvious. It's effectively temporary setuid/setgid with some light limitations. Leaking directory descriptors across security boundaries becomes a lot more interesting with this patch applied. Something which has happened multiple times already and heavily figures in container escapes. And the RESOLVE_BENEATH/IN_ROOT restrictions only stave off symlink (and magic link) attacks. If a directory fd is leaked a container can take the fsuid/fsgid/groups from the original opener of that directory and write to disk with whatever it resolves to in that namespace's idmapping. It's basically a nice way to puzzle together arbitrary fsuid/fsgid and idmapping pairs in whatever namespace the opener happens to be in. And again it also messes with LSMs because you're changing credentials behind their back. And to the "unsuspecting userspace" point you dismissed earlier. Providing a dirfd to a lesser privileged process isn't horrendously dangerous right now. But with this change it sure is. For stuff like libpathrs or systemd's fdstore this change has immediate security implications.