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.129.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 602263783BA for ; Tue, 24 Feb 2026 10:18:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771928284; cv=none; b=shDPcCaiD0vvwSONgTG5mV47YynzMWtCHy7nqMU/i7PYG8Y0+BpnjNiLMGBT+HI90js8Frxldo4z5xINldZBZcWfFA6zCb8qcmwq9NFpIGZslJPxDMeckyjVQo0KC3rrViISn2sM5inCOudLm+SEER96/g6O9mpwn4vQ0Cm7vbU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771928284; c=relaxed/simple; bh=kwirtkezUKyttq19ZuH10pyRTvZLQj8wIqqJHevs7fY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eeB9XdAkFrHZixXmdW9kwQRNLb0oDY0dYkgv6Uor5DqUQhh7eR7xMO69fwcgRc3tUHE9gaKIMz4HHgHpRxVatAtApLTOixyXo62MUjIr5XB7QTspxNe40AqT2eYH91nVANwEcTv1lg2sDbx/PCPEyLrEy6R+rJoc2r9IUdtGbI0= 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=BPHTWq6B; arc=none smtp.client-ip=170.10.129.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="BPHTWq6B" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771928282; 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: in-reply-to:in-reply-to:references:references; bh=M87QNnsSCJlVJUoKJxVdXvjbujJhFeSG308AaM5lV3o=; b=BPHTWq6BI3lJGhf0UCnvKj47rs55vxcgnVc4zPC638X8tSU8OiVvk571lhVwdivFe+zPzv jQLKIhkRS0Qa5Yfm6YuR9CsKAZIolyViBV+BkMXPwbvO8YSQxVXJ7rKvgQK490iUkoBIhb /lNzLPP640OXICoUnYOxFynLOb/fN94= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-671-lgdNJAsjPlqNYJSgqZugwA-1; Tue, 24 Feb 2026 05:17:51 -0500 X-MC-Unique: lgdNJAsjPlqNYJSgqZugwA-1 X-Mimecast-MFC-AGG-ID: lgdNJAsjPlqNYJSgqZugwA_1771928269 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 502CC18003F6; Tue, 24 Feb 2026 10:17:49 +0000 (UTC) Received: from fedora (unknown [10.44.32.38]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id A23351800465; Tue, 24 Feb 2026 10:17:45 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Tue, 24 Feb 2026 11:17:48 +0100 (CET) Date: Tue, 24 Feb 2026 11:17:43 +0100 From: Oleg Nesterov To: Christian Brauner Cc: Jann Horn , Linus Torvalds , Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: pidfd && O_RDWR Message-ID: References: <20260223-work-pidfs-autoreap-v4-0-e393c08c09d1@kernel.org> <20260223-work-pidfs-autoreap-v4-2-e393c08c09d1@kernel.org> <20260223-ziemlich-gemalt-0900475140e5@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=us-ascii Content-Disposition: inline In-Reply-To: <20260223-ziemlich-gemalt-0900475140e5@brauner> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 On 02/23, Christian Brauner wrote: > > On Mon, Feb 23, 2026 at 08:21:02PM +0100, Oleg Nesterov wrote: > > On 02/23, Oleg Nesterov wrote: > > > > > > pidfd_prepare() does pidfs_alloc_file(pid, flags | O_RDWR) and "| O_RDWR" > > > makes no sense because pidfs_alloc_file() itself does > > > > > > flags |= O_RDWR; > > > > > > I was going to send the trivial cleanup, but why a pidfs file needs > > > O_RDWR/FMODE_WRITE ? > > > > > > Actually the same question about some anon_inode_getfile_fmode(O_RDWR) > > > users, for example signalfd.c. > > > > perhaps an accidental legacy from 628ff7c1d8d8 ("anonfd: Allow making anon > > files read-only") ? > > It was always a possibility that we would support some form of > write-like operation eventually. And we have support for setting trusted > extended attributes on pidfds for some time now (trusted xattrs require > global cap_sys_admin). But why do we need O_RDWR right now? That was my question. I can be easily wrong, but I think that pidfs_xattr_handlers logic doesn't need it... OK, I won't pretend I understand fs, I'll send the trivial cleanup which just removes the unnecessary "flags | O_RDWR" in pidfd_prepare(). Oleg.