Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp416699lqo; Wed, 8 May 2024 04:02:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVeIHah1UZDCpqyNnHWogkSpDNtIMPaLr3NQN/VyJcVR8C1KRUuEK1KajeuQNQoyP4t1Nmeo+w1VTOmpic/fIBBrAQDmSmjWkMJYWwtrQ== X-Google-Smtp-Source: AGHT+IFHtnw0K3usNW+98xS/+4r5GRAaqXk67UAqWTzdwthPFR12eq06rLkk23FTVYCStJtpYJjX X-Received: by 2002:a05:6214:19cc:b0:6a0:c242:16d0 with SMTP id 6a1803df08f44-6a1514dc504mr35577256d6.31.1715166124054; Wed, 08 May 2024 04:02:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715166124; cv=pass; d=google.com; s=arc-20160816; b=Dc3b/WgsJ6R3l81nkLrPCHkJK4dfJSb/7DcXC8GGr1wFB0FaUOLwHrWS7yLkWo1re6 f5hAmJzLBVt5OtDi27f+fwJb/4/avU6pcSmJP1x8qgfAx+RTjQMJKl7a3/YV61TQ4EoZ 9ynxOqbnRjUCZ+g/mvTqU+9Xgp/4ffn6pa0sWKqkyppdaXtJc07rvJc8D52GXQNlAz91 nZpD0Y7rwZlWJLEvJW35EOQAGHTdX/bg9VaXUofqoK1aiCQxtaw49oux7xvHB7nt8o2x AvnXN+33gXQy4Sx1l4g3FJfXFxPiEZgIWJCu1e0OdsSUgCAq47Pi+Jzo0lGfamRlwcIP pmhQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=k+L7cVJ0RXkqS3cuApbLADzGi4qIsO/ernkhsuK+4mg=; fh=0gGq0Jl0RjcVFbekwz+dN5doIHslv7O0uvn/w0ji4Bs=; b=N/6we03yAX+yDzlKK0ZU1CtZPH4ZV3yJKOEYXZU22XH1ybdyK5faNj85RZd4/nzOVu CnekQKNuQzi89/QthcEW2HbKh3XZoRaqkdxGcIpSoEVhl+yNo6FycN1Ctdq2PCdkyS8Q wR6czfX9KVbMQYiFK0VbVOP1Gr9pxVaMXYr2i49IMpf5jg37QGDS2YvYw30/Dt4dWT9u CLv0kBeKpfILoNSRQxy9AQYjFEGl8cesd98icAnM9Dipr5KQufTQ5QSUcBxIT1pXCFr3 xyxbl6KsJrOoOsM2vxm1QoWmKirJ3VFyujw63wQMO6UWx6r/gQuBCJGqFgaywHSuq7Rr S9yw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=eaeu5qAg; arc=pass (i=1 dkim=pass dkdomain=ffwll.ch); spf=pass (google.com: domain of linux-kernel+bounces-172912-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172912-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v3-20020a05620a0f0300b00792a4fe23cdsi4757442qkl.318.2024.05.08.04.02.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 04:02:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172912-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=eaeu5qAg; arc=pass (i=1 dkim=pass dkdomain=ffwll.ch); spf=pass (google.com: domain of linux-kernel+bounces-172912-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172912-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 807C41C2198C for ; Wed, 8 May 2024 08:32:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED1BF4317A; Wed, 8 May 2024 08:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="eaeu5qAg" Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (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 91366436A6 for ; Wed, 8 May 2024 08:32:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715157134; cv=none; b=ihTiZCjyvX8eH27lQ3x8ZJsMYV2g21TD3K5JCylY4V8F7boKElEEuq8F0qKthPzjncXcsBE2BO4Un9rP49W6CcO/CgiUo2USykdDQp6EPLSZdFqXGY92EbaPJExfR1wFjGzgkOhUxYK23tqeQ4OQha4vLYnfuivt8YmtAkg6b5w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715157134; c=relaxed/simple; bh=b3DUk88N1D27ioVFvmL2iMHqSDZeX4sADmOjfnV9m+Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EXCZGwGRQR7H98/ov+iMu8RzbvalvWpONN/GSN/WXnbPkTWB1QMc4poBm3ELT7dv0IwcZ4x62Jp/rJjZnBClY3foxtxDWFtf60ZNzbcPdpWafAI8WLm9EMizN0QsyJtXxW1Qr3YbYIsz8JNmqBjmfb8xNQcRaL/N620W7vQJeg0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch; spf=none smtp.mailfrom=ffwll.ch; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b=eaeu5qAg; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ffwll.ch Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a554cf23c3eso32654066b.2 for ; Wed, 08 May 2024 01:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; t=1715157131; x=1715761931; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:from:to:cc:subject:date:message-id:reply-to; bh=k+L7cVJ0RXkqS3cuApbLADzGi4qIsO/ernkhsuK+4mg=; b=eaeu5qAglxOVyiOJOS4fHDF72gGQMJxJ+QWaAKQOEVXFSFTZwDvBysQONbDIZ/Agv9 fqJaRJkP1H0iQtf5du7qnUEqAIKnrh+t+DSPOkAV3BTXUfRfQpcMOuB7CUvtlxYDCjJK CIT5X7aN5++07AxZRP/kI/84g2pUozbqsbbFc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715157131; x=1715761931; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=k+L7cVJ0RXkqS3cuApbLADzGi4qIsO/ernkhsuK+4mg=; b=LYYDBFpgAQU9nxaF5kmq1t4C3IjbxTi8JSX7sXObtzKrAEOALRwGijO6QqrT/qI6RD Qw4IGQ6kMvUEppAb+d02jsz0BTw8rI6tdD+paEo1Wj1tc5Vnke+VOwJvW434pXawa/7T h5sxVZR8lNBW9p2cE8+iJ8TSkHTtDo4Cgo3iRVML2jG1cQJII519rr0l4yJwtN6pxyVz +CKsL1gBC8x4k9vjOHgmNCmd8Ht7NEs6cqYplkKnAOHITQpx4e3yzwj3/wXeINEY40rr Y7a/ny78znWK+Jm3/CJLff0ksFArinLEit8imeeGtfm3R2ozbE9nwtRwceVU1GYJo2HQ gkkA== X-Forwarded-Encrypted: i=1; AJvYcCVt6ryp6IglKLGihWuSOnNHl66giEelUbQ/4dzgnzRACAIMoKKrV6Gj27fTOA6kTTRBE6Y5kvsB6cqX1HEaBUgcDImgm5W5THUEH8kw X-Gm-Message-State: AOJu0Yw1JiKkBKCYSYhxkrjoxHt/93iXrPIKv2efCXIJmCoQA6SreJAb qj1mwYQqRMxiudZj9y6csI+0QVWKnYGKwnd02dbEgwvpVlGRRLt2FOpKOEpTp+Q= X-Received: by 2002:a17:906:fd17:b0:a59:7f38:8dfc with SMTP id a640c23a62f3a-a59fb9ebd21mr102078066b.5.1715157130873; Wed, 08 May 2024 01:32:10 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id uz14-20020a170907118e00b00a599adfd49dsm6073415ejb.64.2024.05.08.01.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 01:32:10 -0700 (PDT) Date: Wed, 8 May 2024 10:32:08 +0200 From: Daniel Vetter To: Christian =?iso-8859-1?Q?K=F6nig?= Cc: Linus Torvalds , Daniel Vetter , Simon Ser , Pekka Paalanen , 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 Subject: Re: [Linaro-mm-sig] Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes Message-ID: Mail-Followup-To: Christian =?iso-8859-1?Q?K=F6nig?= , Linus Torvalds , Simon Ser , Pekka Paalanen , 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 References: <20240504-wohngebiet-restwert-6c3c94fddbdd@brauner> <040b32b8-c4df-4121-bb0d-f0c6ee9e123d@gmail.com> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <040b32b8-c4df-4121-bb0d-f0c6ee9e123d@gmail.com> X-Operating-System: Linux phenom 6.6.15-amd64 On Wed, May 08, 2024 at 07:55:08AM +0200, Christian K?nig wrote: > Am 07.05.24 um 21:07 schrieb Linus Torvalds: > > On Tue, 7 May 2024 at 11:04, Daniel Vetter wrote: > > > On Tue, May 07, 2024 at 09:46:31AM -0700, Linus Torvalds wrote: > > > > > > > I'd be perfectly ok with adding a generic "FISAME" VFS level ioctl > > > > too, if this is possibly a more common thing. and not just DRM wants > > > > it. > > > > > > > > Would something like that work for you? > > > Yes. > > > > > > Adding Simon and Pekka as two of the usual suspects for this kind of > > > stuff. Also example code (the int return value is just so that callers know > > > when kcmp isn't available, they all only care about equality): > > > > > > https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/util/os_file.c#L239 > > That example thing shows that we shouldn't make it a FISAME ioctl - we > > should make it a fcntl() instead, and it would just be a companion to > > F_DUPFD. > > > > Doesn't that strike everybody as a *much* cleaner interface? I think > > F_ISDUP would work very naturally indeed with F_DUPFD. > > > > Yes? No? > > Sounds absolutely sane to me. Yeah fcntl(fd1, F_ISDUP, fd2); sounds extremely reasonable to me too. Aside, after some irc discussions I paged a few more of the relevant info back in, and at least for dma-buf we kinda sorted this out by going away from the singleton inode in this patch: ed63bb1d1f84 ("dma-buf: give each buffer a full-fledged inode") It's uapi now so we can't ever undo that, but with hindsight just the F_ISDUP is really what we wanted. Because we have no need for that inode aside from the unique inode number that's only used to compare dma-buf fd for sameness, e.g. https://gitlab.freedesktop.org/wlroots/wlroots/-/blob/master/render/vulkan/texture.c#L490 The one question I have is whether this could lead to some exploit tools, because at least the android conformance test suite verifies that kcmp isn't available to apps (which is where we need it, because even with all the binder-based isolation gpu userspace still all run in the application process due to performance reasons, any ipc at all is just too much). Otoh if we just add this to drm fd as an ioctl somewhere, then it will also be available to every android app because they all do need the gpu for rendering. So going with the full generic fcntl is probably best. -Sima -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch