Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp507350lqh; Tue, 7 May 2024 06:12:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXte22PLXIub/r3VNvTBR15/UJdLPGPrkwStdFlDL5kWoy21dj+ZxrnkjEZDdTn+eMArkY+rJB5yPuE/z8WrFRAX3kby70v75kMivLopw== X-Google-Smtp-Source: AGHT+IHltVacX1/+HPtGdh8d9Hr9YvifwpX2IR0K8XIJ4iMA/M+KVQjmqF36gH3LG5az4I8ZRYl7 X-Received: by 2002:a05:6a20:9741:b0:1a7:48de:b2a4 with SMTP id hs1-20020a056a20974100b001a748deb2a4mr3726914pzc.6.1715087578438; Tue, 07 May 2024 06:12:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715087578; cv=pass; d=google.com; s=arc-20160816; b=xpHe5lqZM58bumECwYO2hsjFjJzFmhP2dxs7tYDpXlc0pdBTZmxr9KyQUqBkaaOMmm /h09qhtU3HWsJL4BjJ5Ba7tGCXIJURLGjtJjKi8dmhPuyXfWIEDfPnYKHU9FdKjHBxnv vfABGrKy2JGDJchL1KdrsdHnR1W9UhDXW4MfNZFRT/pZ5OYTPL8mS1dw4o0JuEkcfNeA ntPhTEvzmXTN9zMk3E39CXrUzWM3kgsI9g7aS1K2Cu7/lFXV8jt7/S4Dh9AZZtgE4kyT 2KuxQ6s50RRuhCppDVQ64JIg3cRksWvbRx6lEsZJWZPOVm6G8V0UEtR0Hycdq9fMZwio Ld5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=zAPclAFMPPKUlH6qpuAnNZJMeX8QiDYjKI0Oitzf9Wg=; fh=7Vvk1pvbmg6WtnRHTav15Ml8nBxHSEDLqZqxOLdRnFs=; b=lSlYc55iQT6B/FdDBmmGrIRi6ihVJP2GN1S3S5PlbkdrY5HTa64u8yOQftIH9o4KeX TpYHixVLuL8lwXv9hQ0n2X23sd+hi4IrI+EpPekCOfqVq/y2D1CRPsmSyoGPcQFNmEWg wT+igI5ScmskaBJbCiXHB35GoerrRS3pnxit5funl/cXylamOq3cMbIgM2zRLbuZzVBQ 4VKIXMB9P9ujgYEM/Hr8z/H3obJoKc+CgiJeF5I5jcDGeGw8MbBgHgFiwlYr4ejGMaCt pWAl02L6rmP51aPZiRWnymfns/jK2oZjRcFkItfYkYjAvJVLb4ZtToXvzxlj0nbRBzaT kyqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=szMkz5XQ; 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-171319-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171319-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id cd23-20020a056a00421700b006f409781aa3si3537788pfb.230.2024.05.07.06.12.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 06:12:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171319-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=szMkz5XQ; 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-171319-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171319-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 36AE8B25072 for ; Tue, 7 May 2024 12:56:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0748415D5C8; Tue, 7 May 2024 12:55:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b="szMkz5XQ" Received: from forward500a.mail.yandex.net (forward500a.mail.yandex.net [178.154.239.80]) (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 2F28015B153; Tue, 7 May 2024 12:55:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.154.239.80 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715086554; cv=none; b=lkyRw0wCtQjqgCMedezZ215X9JHBuZFdxwS9DdRtiN/iynYrJvxR/2zeO+EKyZtL+6ZQgKn8/Al4412tgHK0YNuEPBWhdBuDfgWiDTwx4BeeWCQ0B6V/in6YMe+PYwuxwumhd6FCKESr2eek33n/DIZLJRXu+fvMgcgV7r0M/ds= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715086554; c=relaxed/simple; bh=7mLQ4noYOwaZz0uIOPLa+mJodEytp0OT+zTex7p1R9I=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mR5WtHVhTbpXfW3Ql19fJiZYapBA4PEPF7fc6tO87EgnSocJx/b8bbkRI4Cru+zO/WfwfTxjfwK97rXml1iXGFjTunQPqmWhAsxthXr3jI+8AVzrqMzSz9zvRBShbUqMOsYomf+f+fPuSz1jXtC0ELRxduh8JBCl98Z1Mn7aPRM= 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=szMkz5XQ; arc=none smtp.client-ip=178.154.239.80 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-55.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-55.vla.yp-c.yandex.net [IPv6:2a02:6b8:c0d:230c:0:640:f8e:0]) by forward500a.mail.yandex.net (Yandex) with ESMTPS id 3390E61277; Tue, 7 May 2024 15:48:25 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-55.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id MmXuqmAmDqM0-G4BR5X7Q; Tue, 07 May 2024 15:48:24 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1715086104; bh=zAPclAFMPPKUlH6qpuAnNZJMeX8QiDYjKI0Oitzf9Wg=; h=From:In-Reply-To:Cc:Date:References:To:Subject:Message-ID; b=szMkz5XQXmyp2MPWrKjBmUyCNvF4aEiWBUHmeQuOvbJ+FrIwFO5zMOe5s9r3DFbuY y3OvHyeI6zCWBYm8xV4pmdhi/ldtf9ACwxzz9kUvbTK84BTzHgCL8jB+0xLQIhuhwa SIuvfx3CMflI8RM6yWMNn/teOn3X4MbK3GIdz2fk= Authentication-Results: mail-nwsmtp-smtp-production-main-55.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Message-ID: <7fcb3f51-468f-444d-9dd4-fa4028f018fc@yandex.ru> Date: Tue, 7 May 2024 15:48:22 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 0/3] implement OA2_CRED_INHERIT flag for openat2() Content-Language: en-US To: Aleksa Sarai Cc: linux-kernel@vger.kernel.org, Stefan Metzmacher , Eric Biederman , Alexander Viro , Andy Lutomirski , Christian Brauner , Jan Kara , Jeff Layton , Chuck Lever , Alexander Aring , David Laight , linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, Paolo Bonzini , =?UTF-8?Q?Christian_G=C3=B6ttsche?= References: <20240427112451.1609471-1-stsp2@yandex.ru> <20240506.071502-teak.lily.alpine.girls-aiKJgErDohK@cyphar.com> <5b5cc31f-a5be-4f64-a97b-7708466ace82@yandex.ru> <20240507.110127-muggy.duff.trained.hobby-u9ZNUZ9CW5k@cyphar.com> From: stsp In-Reply-To: <20240507.110127-muggy.duff.trained.hobby-u9ZNUZ9CW5k@cyphar.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 07.05.2024 14:58, Aleksa Sarai пишет: > On 2024-05-07, stsp wrote: >> 07.05.2024 10:50, Aleksa Sarai пишет: >>> If you are a privileged process which plans to change users, >> Not privileged at all. But I think what you say is still possible with >> userns? > It is possible to configure MOUNT_ATTR_IDMAP in a user namespace but > there are some restrictions that I suspect will make this complicated. > If you try to do something with a regular filesystem you'll probably run > into issues because you won't have CAP_SYS_ADMIN in the super block's > userns. But you could probably do it with tmpfs. Then its likely not a replacement for my proposal, as I really don't need that on tmpfs. Perhaps right now I can use the helper process and an rpc as a replacement. This is much more work and is slower, but more or less can approximate my original design decision quite precisely. Another disadvantage of an rpc approach is that the fds I get from the helper process, can not be trusted, as in this case kernel doesn't guarantee the fd actually refers to the resource I requested. I've seen a few OSes where rpc is checked by a trusted entity to avoid such problem. >>> A new attack I just thought of while writing this mail is that because >>> there is no RESOLVE_NO_XDEV requirement, it should be possible for the >>> process to get an arbitrary write primitive by creating a new >>> userns+mountns and then bind-mounting / underneath the directory. >> Doesn't this need a write perm to a >> directory? In his case this is not a threat, >> because you are not supposed to have a >> write perm to that dir. OA2_CRED_INHERIT >> is the only way to write. > No, bind-mounts don't require write permission. Oh, isn't this a problem by itself? Yes, in this case my patch needs to avoid RESOLVE_NO_XDEV, but I find this a harsh restriction. Maybe the bind mount was done before a priv drop? Then it is fully legitimate. Anyway, I don't know if I should work on it or not, as there seem to be no indication of a possible acceptance.