From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6662C2BBCA for ; Fri, 28 Jun 2024 09:45:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F21C6B00B1; Fri, 28 Jun 2024 05:45:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A2886B00B2; Fri, 28 Jun 2024 05:45:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 042B16B00B3; Fri, 28 Jun 2024 05:45:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D99C26B00B1 for ; Fri, 28 Jun 2024 05:45:24 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4622EC183E for ; Fri, 28 Jun 2024 09:45:24 +0000 (UTC) X-FDA: 82279814568.26.6ECEAB2 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf27.hostedemail.com (Postfix) with ESMTP id 0E32E40017 for ; Fri, 28 Jun 2024 09:45:20 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=KUYTxA9y; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=WUVxshvX; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=bLi52LFr; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="Whc/fUS9"; spf=pass (imf27.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719567897; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=f26nbjFyLnlYInHIRR6KDvb4r0aSsw8ifojWvt5uZhw=; b=zMFCFrrqQj3HuICQF9mMqVPsqN7kGnWcH/qYV7XUHjQ6ROQdzuUi8d3ydfMIgiwwX07UeM trvvopZueS+pTJw9LJJmlV87Wt6tTKXOWbm2xAdWeXk6wHG/U811svrN3zpg9lPhm6UHkk lBhr23FCWrs95KO7FL1dP3n4Fli0/hs= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=KUYTxA9y; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=WUVxshvX; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=bLi52LFr; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="Whc/fUS9"; spf=pass (imf27.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719567897; a=rsa-sha256; cv=none; b=aF405psV1SC4doBBN7UfPSsL26ROAW2nWNoErCqV0v5Tl977+p0lDxaLTEwliLp/LHstIX Nkm0WzUyCuKY8XfITQCKErcMV+jKQECKXdYgEVAIXL+u60e/da2Zj8TYb5G5yt1CWc46z3 b8CWntHXx8dZQdqHdsxXWwwTQWgpnTE= Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E9FB221BC9; Fri, 28 Jun 2024 09:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719567919; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=f26nbjFyLnlYInHIRR6KDvb4r0aSsw8ifojWvt5uZhw=; b=KUYTxA9yfgjQxbwI4K8stUvHGu1vsAYhUXpwJkG+ELqu86igcdg1sbLNvlKfLZUnKA3WlH RZino+8fbK2+MJfZIKhW+wF30EYWKgf46/Ra2eq+CS95dvpBo8KvAlX2AfNtqwyWxnQkNK 4yRCyob67BtYLBu14RxYJwgLcEqZiZw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719567919; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=f26nbjFyLnlYInHIRR6KDvb4r0aSsw8ifojWvt5uZhw=; b=WUVxshvXtPCGrq4IGUx4Lk1be12on57Evx2IiNVmvE84OeO4SG4zztw3ZylHAkBR1WRNoC Fc2qm8RbXgb7MXCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719567917; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=f26nbjFyLnlYInHIRR6KDvb4r0aSsw8ifojWvt5uZhw=; b=bLi52LFrNYz4r7H3P+mEUw86IXx8vzgnG+3QyHg99jKg9DF7ujgYInC2P+225v7/iifv06 nU6JAj8A7nfotAxn7yt17IQRrpbMDN0/a+8Z+X25K59tSV1tXWOhAmvNlcFaSXSciGuZ5q T2A5GpG2qx+b7csuthBsE2tgcDs2vII= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719567917; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=f26nbjFyLnlYInHIRR6KDvb4r0aSsw8ifojWvt5uZhw=; b=Whc/fUS9d3BhyO19okPfQdzkp0dnWCR3SjDCYNy5EIAMr+QN2/FQkXW0U2SXZZvifZxt6y FImH8Q/bIhkMHyDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id DC5B113A9A; Fri, 28 Jun 2024 09:45:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id T2rFNS2GfmarOQAAD6G6ig (envelope-from ); Fri, 28 Jun 2024 09:45:17 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 9ED29A088E; Fri, 28 Jun 2024 11:45:17 +0200 (CEST) Date: Fri, 28 Jun 2024 11:45:17 +0200 From: Jan Kara To: Eric Sandeen Cc: linux-fsdevel@vger.kernel.org, Christian Brauner , autofs@vger.kernel.org, "Rafael J. Wysocki" , linux-efi@vger.kernel.org, Namjae Jeon , linux-ext4@vger.kernel.org, Miklos Szeredi , linux-mm@kvack.org, Jan Kara , ntfs3@lists.linux.dev, linux-cifs@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Hans Caniullan Subject: Re: [PATCH 01/14] fs_parse: add uid & gid option option parsing helpers Message-ID: <20240628094517.ifs4bp73nlggsnxz@quack3> References: <8dca3c11-99f4-446d-a291-35c50ed2dc14@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0E32E40017 X-Stat-Signature: 6dy5haqr9yanseaakz33kpxqauw7kfed X-Rspam-User: X-HE-Tag: 1719567920-574763 X-HE-Meta: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gpYgRv/+0AkQbg+rP+Px3ct4WdYfQWJmq57zRr+rToUAefgw77jrEiKHAbouDRN2wBtSRyPLGLqA6XfoB55lZno5GCN3ZMJILDEp2lI2PC53zG0QyFzOw6w4Vz6YokKBtkkIhWOIYPJpr4Y9p9L/BZBaKLs8pQzNnJ98zm3Xegexsn64W39hkUIOdeBUbG1YJNoh7043OhQR1xjpuCuP6/i9aGaDn0x7jaDjCh09cmUlhgfXVy59dnxr2F4Jjkm0s5L0A0YEUvxCNdt3InqaXuUbPT4aujqwa9s8ezzFeurEHVCCghmhf1MmDjLAs7TNfkE7SHJoDKfFcMi3Ju+X4ONMiAN/uOout8uCus7L3W7uGCzYODbInS/YQ5L45iIbW6XSoajIzfrYqF2scmvrw0RBoTbR8ayTasRm X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu 27-06-24 19:26:24, Eric Sandeen wrote: > Multiple filesystems take uid and gid as options, and the code to > create the ID from an integer and validate it is standard boilerplate > that can be moved into common helper functions, so do that for > consistency and less cut&paste. > > This also helps avoid the buggy pattern noted by Seth Jenkins at > https://lore.kernel.org/lkml/CALxfFW4BXhEwxR0Q5LSkg-8Vb4r2MONKCcUCVioehXQKr35eHg@mail.gmail.com/ > because uid/gid parsing will fail before any assignment in most > filesystems. > > Signed-off-by: Eric Sandeen I like the idea since this seems like a nobrainer but is actually surprisingly subtle... > diff --git a/fs/fs_parser.c b/fs/fs_parser.c > index a4d6ca0b8971..24727ec34e5a 100644 > --- a/fs/fs_parser.c > +++ b/fs/fs_parser.c > @@ -308,6 +308,40 @@ int fs_param_is_fd(struct p_log *log, const struct fs_parameter_spec *p, > } > EXPORT_SYMBOL(fs_param_is_fd); > > +int fs_param_is_uid(struct p_log *log, const struct fs_parameter_spec *p, > + struct fs_parameter *param, struct fs_parse_result *result) > +{ > + kuid_t uid; > + > + if (fs_param_is_u32(log, p, param, result) != 0) > + return fs_param_bad_value(log, param); > + > + uid = make_kuid(current_user_ns(), result->uint_32); But here is the problem: Filesystems mountable in user namespaces need to use fc->user_ns for resolving uids / gids (e.g. like fuse_parse_param()). Having helpers that work for some filesystems and are subtly broken for others is worse than no helpers... Or am I missing something? And the problem with fc->user_ns is that currently __fs_parse() does not get fs_context as an argument... So that will need some larger work. Honza -- Jan Kara SUSE Labs, CR