From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 56E3C3321DC for ; Tue, 21 Oct 2025 13:20:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761052842; cv=none; b=IEIwy+q18/mNtQ1M2CM2kwnaI+LivLdtKgW80bI4l+IMvztjquGOMXqD6Y990mW+w2D7MG4IPHQJUQTAekpI6fXMf5I7b7B8GE8cehYFtiDbJ2ilEc5SyGl6FudSEkrSlahvJLIHx3V02WTNDWdxsV+Enh7Btr2wPCTPAp4vZRQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761052842; c=relaxed/simple; bh=pUM3WkjxlvllZMSA21avgB5tS8ZLspUBiO6Y0NL2uMw=; h=From:In-Reply-To:References:To:Cc:Subject:MIME-Version: Content-Type:Date:Message-ID; b=DSEEel1jmmg+dYZfvXtHtUquZtt+QXi1/0j4+Hmoo+Hsc+cy9iJSmOMLhjJ/idm3++XOQtTuC3wNZkjtIzOoJlBLaW3VFbzB0B687NZb358hksoMhMmFXViCWAt3s8bxPpkSh6O03cVbKQkOQu1NLn4GzJivn9FMRHeqtdKtDjM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=jI8E0XVm; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jI8E0XVm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761052840; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LDMAXz3Joj1Fr7gZbdHzGwjvuqW31ZCsGZDGsi8cR5E=; b=jI8E0XVmv2WyWyy2ydPG17HvtFFPommR/v51X8VkpWsEE7QJUXllVUDLIhyOc5fwkBFd7X XA9Myg1Jh5cXsTigvP/HmZtuQtOmeeLZv4vMPbO7mJ5rF8bqryP0UMLimScixCZ6USLwiN FCukKo5ujD7ZI4PA3pClwjr3NxeFoTo= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-550-VgoTW2vuM22D-D82mMOdLA-1; Tue, 21 Oct 2025 09:20:38 -0400 X-MC-Unique: VgoTW2vuM22D-D82mMOdLA-1 X-Mimecast-MFC-AGG-ID: VgoTW2vuM22D-D82mMOdLA_1761052836 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 47727195608A; Tue, 21 Oct 2025 13:20:28 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.57]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D872C1956056; Tue, 21 Oct 2025 13:20:22 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20251021-agieren-spruch-65c107748c09@brauner> References: <20251021-agieren-spruch-65c107748c09@brauner> <20251014133551.82642-1-dhowells@redhat.com> <20251014133551.82642-2-dhowells@redhat.com> To: Christian Brauner Cc: dhowells@redhat.com, Al Viro , Christian Brauner , Marc Dionne , Jeffrey Altman , Steve French , linux-afs@lists.infradead.org, openafs-devel@openafs.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Etienne Champetier , Chet Ramey , Cheyenne Wills , Mimi Zohar , linux-integrity@vger.kernel.org Subject: Re: [PATCH 1/2] vfs: Allow filesystems with foreign owner IDs to override UID checks Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1523596.1761052821.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Tue, 21 Oct 2025 14:20:21 +0100 Message-ID: <1523597.1761052821@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Christian Brauner wrote: > > + if (unlikely(inode->i_op->have_same_owner)) { > = > Same, as above: similar to IOP_FASTPERM this should use a flag to avoid = pointer derefs. Can we do these IOP_* flags better? Surely we can determine at the point = the inode has its ->i_op assigned that these things are provided? This optimi= ses the case where they don't exist at the expense of the case where they do (= we still have to check the pointer every time). > > + if (unlikely(inode->i_op->have_same_owner)) { > = > Same, as above: similar to IOP_FASTPERM this should use a flag to avoid = pointer derefs. > = > Really, we should very properly bias this towards the common case where > the filesystem will not have a custom ownership comparison callback at a= ll. Hence the unlikely(). > > + struct dentry *parent; > > + struct inode *dir; > > + int ret; > > + > > + if (inode !=3D nd->inode) { > > + dir =3D nd->inode; > > + ret =3D inode->i_op->have_same_owner(idmap, inode, dir); > > + } else if (nd->flags & LOOKUP_RCU) { > > + parent =3D READ_ONCE(nd->path.dentry); > > + dir =3D READ_ONCE(parent->d_inode); > > + if (!dir) > > + return -ECHILD; > > + ret =3D inode->i_op->have_same_owner(idmap, inode, dir); > > + } else { > > + parent =3D dget_parent(nd->path.dentry); > > + dir =3D parent->d_inode; > > + ret =3D inode->i_op->have_same_owner(idmap, inode, dir); > > + dput(parent); > > + } > > + return ret; > > + } > = > This about as ugly as it can get and costly... I can break this out into a helper, but it should make no difference to th= e actual code generated. > > + ret =3D vfs_inode_and_dir_have_same_owner(idmap, inode, nd); > > + if (ret <=3D 0) > > + return ret; > = > Ok, so while that doesn't exactly surface the error it's still weird. > Please make that consistent. Either have those two new helper functions > return negative error codes and zero on success or have it be a proper > boolean instead so there's no possible confusion. This is just begging > for someone to do if (ret) return ret and bubble up that positive return > value. The problem is that you have three available returns: Yes they do, no they don't and some arbitrary error was encountered. The first two are not err= or cases, and potentially any error you pick to represent, say, "no" could al= so be returned by the underlying filesystem. David