Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp1089090lqo; Thu, 9 May 2024 04:39:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWoIqkSGEvgYgZbFBoYJ5c6fckiEfD7fKCT/nB/ZPV4+xm3mfjOZgk5fwgf7piOSJWK7QVF1Vt6jBW/m0GcTEwsro0S0QyOSdAAFcpXHg== X-Google-Smtp-Source: AGHT+IHfHzGJ3iGQXA4XsUVwtGR/KZX2DUEB/hDxN4q0kmMni19mM5ZI6EEFWZheO91wev99HWWk X-Received: by 2002:a05:6a00:3987:b0:6ed:9760:9ba7 with SMTP id d2e1a72fcca58-6f49c292bd7mr7422993b3a.22.1715254769356; Thu, 09 May 2024 04:39:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715254769; cv=pass; d=google.com; s=arc-20160816; b=f7PfZ2n39PPgz2OFniM9gFu8rOUHUnF9FNuU09lCEY/0xDBA/51t05rlMqJLi8Mvpv dMImQnY+MxC9edC5zJX06FTNGAuptGWUUsdI5mpid9/hnNDB7hyXi9pkub3POmB1xe84 GhxS1AlmRb7x4flltRT0xwvtdBf0Flve31SwLIuoAGeeygvw/ou9krUOSz35IlihJTpU tQtRFlqOKSV773IR6bZv5MNbrKT2afwnyHYHPlK4Vpaps9ASr1gMbYB0fq/VessUATYx tjrk5yHRDjjlOcGN06NyzbcUG4yPeNRT17ZweCPfyKlKbHqZmf13Q0Y8W/iKy72rSF7x Yt/A== 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=Azx/VWgVvaTWS8NdbkdBeOnoDnR3teRomm8uH+fwDi0=; fh=GYwExkYgyJWZNKe8uLUADIte747Ale7hL+fw+znN9wQ=; b=iBnVApyGKtyhWlnOCkMKMW7L4fnY2Su+PrDOq+CSXPzWJVtRaJ4LcxEems7/2o8jjg u4Be1FaFpICkuweE8nvwkwA0qs0ITA750BLNQVi2bc903ZJsv98ZvHdLp9IX5yW9p5+2 EG4f7DsHhXCCMaYqklqg5YYo2/yxsCtuxuEkOsMEbJ1CNrsJcv/Td0vzQ0wQKFpHp37q i3zq/3hxb9PpBu1CwZ89CZaAx/x/0FEY2DgYnByNxREmf0zLeu48WyJMLQ8sjQ/dC/V8 aGSfFv2Nqq50VTDNHSRCm53PcyzW0XdKGdc7/HhKNgEurIn3BPFm0tRc4OW8KrQVq0Yn sihQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b6oJLrKg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-174448-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174448-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-63409e82760si1306395a12.52.2024.05.09.04.39.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 04:39:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174448-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b6oJLrKg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-174448-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174448-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id DF9D0B21396 for ; Thu, 9 May 2024 11:39:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B8C4714A4EB; Thu, 9 May 2024 11:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="b6oJLrKg" 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 CA2FE13172A; Thu, 9 May 2024 11:39:00 +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=1715254740; cv=none; b=uYETSHc9rDQvRAGBPG/o40TiMZYqmgct1PPk0rHL8Rt8YRWH04ega2ewlHAv38r0ytSpKFTrRnOORkBt5uEQNwFQoqeLCseZR35x91mmUTmDpNziPXkD8LKtyu9UKVzStRvm/QtEtYd0EiReaHQfn4MaOkpbz7VELXJfKYx32sM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715254740; c=relaxed/simple; bh=ziw08gHcd8mjdUarjJlC5MxDSSrwq+SNZaIBS6tHOrk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ffRKvGTVlcCsQiihZM2sSUHmCNytRGVi39D9cO/+PgivZBPyhFawMCEvcPSLiEX4bsi0ARjGRa+SaNhDH/ztQLOpXOJxzdSz4mKuYft2TidT8VQnZjWLOHZXXQX1vRXYIrZTK17Qp4Z2QRjlh7rzcfoR9RpIfeqT+lerMLK1D4o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b6oJLrKg; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E980C116B1; Thu, 9 May 2024 11:38:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715254740; bh=ziw08gHcd8mjdUarjJlC5MxDSSrwq+SNZaIBS6tHOrk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=b6oJLrKgWptVKfS1b1DJld2kF473qcRQlYA9NcglxVQ3muP9XFveN76SPmN4h0W/q NtuRMy302BNatpVrMjzy+J4i2PGajKdd8X7yLnVS5aPgyB9cB3k2SQlym7AmJBtxVJ KwZKFNH1145vKFZGaBVPfwBsQtQqbJPwX0vrIbL1M6b9L/9vg3XpgjB5Ecpu6Wn0qs n5S+yKpK5ZdFiq8Ms5VkVDikYeWo+2/jla9RqHZA9C3ODKbkhq6tc8y2/ZU9HpzQBU MAP4RUarW1r2oACdn0WMre9CPv0H5pS1yjNETR0xZt45kIBnasjBrwt5ML1ySGfTnS S7pDSxU6Dq/eA== Date: Thu, 9 May 2024 13:38:52 +0200 From: Christian Brauner To: Linus Torvalds Cc: Daniel Vetter , Simon Ser , Pekka Paalanen , Christian =?utf-8?B?S8O2bmln?= , Al Viro , keescook@chromium.org, axboe@kernel.dk, christian.koenig@amd.com, dri-devel@lists.freedesktop.org, io-uring@vger.kernel.org, jack@suse.cz, laura@labbott.name, linaro-mm-sig@lists.linaro.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, minhquangbui99@gmail.com, sumit.semwal@linaro.org, syzbot+045b454ab35fd82a35fb@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com Subject: Re: [Linaro-mm-sig] Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes Message-ID: <20240509-kutschieren-tacker-c3968b8d3853@brauner> References: <20240504-wohngebiet-restwert-6c3c94fddbdd@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: On Wed, May 08, 2024 at 10:14:44AM -0700, Linus Torvalds wrote: > On Wed, 8 May 2024 at 09:19, Linus Torvalds > wrote: > > > > So since we already have two versions of F_DUPFD (the other being > > F_DUPFD_CLOEXEC) I decided that the best thing to do is to just extend > > on that existing naming pattern, and called it F_DUPFD_QUERY instead. > > > > I'm not married to the name, so if somebody hates it, feel free to > > argue otherwise. > > Side note: with this patch, doing > > ret = fcntl(fd1, F_DUPFD_QUERY, fd2); > > will result in: > > -1 (EBADF): 'fd1' is not a valid file descriptor > -1 (EINVAL): old kernel that doesn't support F_DUPFD_QUERY > 0: fd2 does not refer to the same file as fd1 > 1: fd2 is the same 'struct file' as fd1 > > and it might be worth noting a couple of things here: > > (a) fd2 being an invalid file descriptor does not cause EBADF, it > just causes "does not match". > > (b) we *could* use more bits for more equality > > IOW, it would possibly make sense to extend the 0/1 result to be > > - bit #0: same file pointer > - bit #1: same path > - bit #2: same dentry > - bit #3: same inode > > which are all different levels of "sameness". Not worth it without someone explaining in detail why imho. First pass should be to try and replace kcmp() in scenarios where it's obviously not needed or overkill. I've added a CLASS(fd_raw) in a preliminary patch since we'll need that anyway which means that your comparison patch becomes even simpler imho. I've also added a selftest patch: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/log/?h=vfs.misc ?