Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp645505lqo; Wed, 8 May 2024 10:16:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXMb8Ky28FP6rC9Uup4kEcoxuNgF1f9nREVgMrChXo9nOerrfKLx2KiNNdUZtufY2OqNZjlQrEHPYjXiTXv2ItVyynWxFMJVmfbNbrDfw== X-Google-Smtp-Source: AGHT+IHkYS+LIkhZFQ44DP9AymSPYrTsf9UIcF/n9EbCr3rT9XPqBm/iqAE8GdM45oZUElcvzlxA X-Received: by 2002:a05:6a20:9711:b0:1ad:7ff5:cb38 with SMTP id adf61e73a8af0-1afc8dbe171mr2910672637.60.1715188596914; Wed, 08 May 2024 10:16:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715188596; cv=pass; d=google.com; s=arc-20160816; b=gfR8Ms1fjBx6ToD0v4q/70ZDFNQMe/mjZOU6mAIJ2AV82nr1pY2fmqisqFztk41y4w dyS8LzNxetQz+lUoHzeeHT8EZVWvTfJgufUoTLI7vCiTQ/YLm1vdaCezTtZogg9ijWMt OQOkv4DZkUAidI38FVrGhvQ4ecr4hWo7AkGTCCcvT9GcBi/yrIXNGiYRdaas1JYCTgww GrVLteEvKrANDRPHnjpgXcXa9zerxdGyZ/jRZfPN8wqsQ6UaUo/01sC8u1N4zlbWYkvX UF1Y45M4FAK9LFGscuAwz9ZupC1p5Ak0Xf/PUVa95Sjl3v2TE9GS68m35keyclNkk+VC 7reQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=U/4yjhmm7i2TdW/kF2dab+x944KGHXX8XGDp8OQOwgM=; fh=2ibGlUCG/VpLgrhRFjOvi0/TIzojIOgwlNMeNd1PH9E=; b=Etqz1PrRPBjyZ51UFHcf5JM2zTQV5EJ2/2/BIroMF6KHNdPkMhHjtz6GNLI2j/N9mw WF4nXS+4NlBXsZxDpv1tGZ0weSJlIDv0hMCtOO87SjvXR12DsI+biJ8m7iGwjDE1im+3 8SQJCjboohQdzzi4ihj/Rolcmbuk81IKBsIE4bbrPG3OctYKgq1a9iL9Lvi+VyA9a9m5 /ZT8LmD06DQ2hykB84Zz7fSlfyEe76FcSk23wbB75qtY06rjj9q+68SxAjdQZ7bj0MwY 3CJVpcgZuZy6KNQlTpIxSo/zjt7kaeHe1hoLQraHc9KwRnZQLaIT5xYG+UK61QegWeLR 0Bdg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=hrzHrMhf; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-173608-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173608-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c2-20020a170902aa4200b001eb4a615f18si12376428plr.433.2024.05.08.10.16.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 10:16:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173608-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=hrzHrMhf; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-173608-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173608-linux.lists.archive=gmail.com@vger.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A039D281C77 for ; Wed, 8 May 2024 17:15:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC86512B14B; Wed, 8 May 2024 17:15:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="hrzHrMhf" Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 089A54CE19 for ; Wed, 8 May 2024 17:15:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715188506; cv=none; b=lw/fE5t5Q4fWJFqbSYHxGnxsG6+rAlwb+YNVu/ymfV2jPoCxjzVD4DrvT8Kqu730QT1/8ya/EEE5TzcpnAzYisv9StPAYHrjJYXAM/WMzYSTbfEpqmnCX4MtYX1Cwe21kyRNbCJOnhKbyLaWMJYXBNtcb3nacaXXxtjfOP7p6VE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715188506; c=relaxed/simple; bh=V0bpsJ67PmT0LSDQg/VjFC4vr5TTFXyb2cnSJu3RiIc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=csDuQS2PrG3LIHQPP/vXmBe28z6H/ZCrP79iyX/cuVuCcQg4TC2goOyumvjb3f10PRL9aaIXMMCcvnfZd1UrIrCfVWC1z6t0Yn5nordk8McZRSczm1W3CA/qFRozlr2IUnYjQG0swVQlRZAooSrWAQZxPOx3Aj+YQpFXDXyD2cA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org; spf=pass smtp.mailfrom=linuxfoundation.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=hrzHrMhf; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linuxfoundation.org Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a59a0e4b773so1122140666b.2 for ; Wed, 08 May 2024 10:15:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1715188503; x=1715793303; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=U/4yjhmm7i2TdW/kF2dab+x944KGHXX8XGDp8OQOwgM=; b=hrzHrMhfk4Af2mAW+gDJ2igv5VnkcjuyqI+Jet76L6ChMrg/Ik+JcYIv1M12ARI9x1 HN8smMhRK4jjUuF8I4/645auzfr/S9I+zfXwsKneOHxNY58sW25nwrpbxW3a4VXdunTR o02wel/zSPnp8SyPfJnoRuFlkkazpUCbR3FM4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715188503; x=1715793303; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=U/4yjhmm7i2TdW/kF2dab+x944KGHXX8XGDp8OQOwgM=; b=uMjlNaUR/s/bZyw3uXPSwczSkbteGe6aTuROsNe51wJ3cj+fFbdn4d79qcwK0HMPXf pRkJQFW2iJLJ/2JRJ2GUSrwDfKifuX0hOcK+ZY12pJ76rQfg6pq6mCkq1VtwLv9TzHv4 0jr8EasrJtHYKMy4IaSq5MCQr8EReAiZ1dOkuFE1HaEElZDNpsj2bzLVooSoQ+Bt8WqH THLHTvJQ6qPjHttYRjN6jXq8WSyTKiCP+dovQpIKDS/HexuuHAyH9EnBsnZh7CUM9P42 /cqrUG8gHlvvqTE8RBatn3jKkDG1wA1FiwixE+Fkcy6P7GC1KNwRPn7MpXO5Hdftwt1Y r3Lw== X-Forwarded-Encrypted: i=1; AJvYcCWHOLjn3pSA5Ye9Dk7zP1r83dYc+A2iPYRrF8HpNMNyeiPbRIGGCoiJLAQAebn/aXQxQ/4zP7tKudUJxOh4Qt6pYB7zECwNKJ+F1HRr X-Gm-Message-State: AOJu0Yz4oASS0GsUip30yB0uXKgOflXrFLIruPjEvOctJyBTbV07xSVT u1TKc86JZwpNS6LHKdXCm8836igHQG8w89jBYAczFxavU4eMXC1VqOIazotzVM+7GGqzyz7b9kG qKT2c1A== X-Received: by 2002:a17:906:6994:b0:a59:9b75:b90 with SMTP id a640c23a62f3a-a59fb948fb3mr193949866b.2.1715188503290; Wed, 08 May 2024 10:15:03 -0700 (PDT) Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com. [209.85.218.46]) by smtp.gmail.com with ESMTPSA id mb15-20020a170906eb0f00b00a59cc6d06f2sm4099159ejb.218.2024.05.08.10.15.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 May 2024 10:15:03 -0700 (PDT) Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a59cc765c29so885956366b.3 for ; Wed, 08 May 2024 10:15:01 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCX+je2oGIJytkdRo3bacF2A0SQTYJdR7Y/e72Kn25IA/olN1biEZOI2noVF+L4g0voud8+HoB6xqJXp+YFInobOsaZGRLi8pB5Lmdfe X-Received: by 2002:a17:906:a996:b0:a59:ca9c:4de9 with SMTP id a640c23a62f3a-a59fb9f5184mr235459866b.76.1715188500986; Wed, 08 May 2024 10:15:00 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <202405031110.6F47982593@keescook> <20240503211129.679762-2-torvalds@linux-foundation.org> <20240503212428.GY2118490@ZenIV> <20240504-wohngebiet-restwert-6c3c94fddbdd@brauner> In-Reply-To: From: Linus Torvalds Date: Wed, 8 May 2024 10:14:44 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [Linaro-mm-sig] Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes To: Daniel Vetter Cc: Simon Ser , Pekka Paalanen , =?UTF-8?Q?Christian_K=C3=B6nig?= , Christian Brauner , 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 Content-Type: text/plain; charset="UTF-8" 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". Does anybody care? Do we want to extend on this "sameness"? I'm not convinced, but it might be a good idea to document this as a possibly future extension, ie *if* what you care about is "same file pointer", maybe you should make sure to only look at bit #0. Linus