Re: [Linaro-mm-sig] Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes

2024-05-10 Thread Christian Brauner
> For the uapi issue you describe below my take would be that we should just > try, and hope that everyone's been dutifully using O_CLOEXEC. But maybe > I'm biased from the gpu world, where we've been hammering it in that > "O_CLOEXEC or bust" mantra since well over a decade. Really the only valid

Re: [Linaro-mm-sig] Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes

2024-05-10 Thread Christian Brauner
On Thu, May 09, 2024 at 08:48:20AM -0700, Linus Torvalds wrote: > On Thu, 9 May 2024 at 04:39, Christian Brauner wrote: > > > > Not worth it without someone explaining in detail why imho. First pass > > should be to try and replace kcmp() in scenarios where it's obv

Re: [Linaro-mm-sig] Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes

2024-05-09 Thread Christian Brauner
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

Re: [Linaro-mm-sig] Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes

2024-05-08 Thread Christian Brauner
On Wed, May 08, 2024 at 10:32:08AM +0200, Daniel Vetter wrote: > 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

Re: [Linaro-mm-sig] Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes

2024-05-08 Thread Christian Brauner
On Mon, May 06, 2024 at 04:29:44PM +0200, Christian König wrote: > Am 04.05.24 um 20:20 schrieb Linus Torvalds: > > On Sat, 4 May 2024 at 08:32, Linus Torvalds > > wrote: > > > Lookie here, the fundamental issue is that epoll can call '->poll()' > > > on a file descriptor that is being closed

Re: [Linaro-mm-sig] Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes

2024-05-08 Thread Christian Brauner
On Tue, May 07, 2024 at 07:45:02PM +0200, Christian König wrote: > Am 07.05.24 um 18:46 schrieb Linus Torvalds: > > On Tue, 7 May 2024 at 04:03, Daniel Vetter wrote: > > > It's really annoying that on some distros/builds we don't have that, and > > > for gpu driver stack reasons we _really_ need

Re: [Linaro-mm-sig] Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes

2024-05-08 Thread Christian Brauner
On Tue, May 07, 2024 at 12:07:10PM -0700, Linus Torvalds wrote: > 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

Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes

2024-05-06 Thread Christian Brauner
On Mon, May 06, 2024 at 02:47:23PM +0200, Daniel Vetter wrote: > On Sun, May 05, 2024 at 01:53:48PM -0700, Linus Torvalds wrote: > > On Sun, 5 May 2024 at 13:30, Al Viro wrote: > > > > > > 0. special-cased ->f_count rule for ->poll() is a wart and it's > > > better to get rid of it. > > > >

Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes

2024-05-06 Thread Christian Brauner
On Mon, May 06, 2024 at 11:27:04AM +0200, Christian Brauner wrote: > On Mon, May 06, 2024 at 10:45:35AM +0200, Christian Brauner wrote: > > > The fact is, it's not dma-buf that is violating any rules. It's epoll. > > > > I agree that epoll() not taking a reference

Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes

2024-05-06 Thread Christian Brauner
On Mon, May 06, 2024 at 10:45:35AM +0200, Christian Brauner wrote: > > The fact is, it's not dma-buf that is violating any rules. It's epoll. > > I agree that epoll() not taking a reference on the file is at least > unexpected and contradicts the usual code patterns for the sake o

Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes

2024-05-06 Thread Christian Brauner
> The fact is, it's not dma-buf that is violating any rules. It's epoll. I agree that epoll() not taking a reference on the file is at least unexpected and contradicts the usual code patterns for the sake of performance and that it very likely is the case that most callers of f_op->poll() don't

Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes

2024-05-05 Thread Christian Brauner
On Sat, May 04, 2024 at 08:40:25AM -0700, Linus Torvalds wrote: > On Sat, 4 May 2024 at 08:32, Linus Torvalds > wrote: > > > > Now, during this TOTALLY INNOCENT sock_poll(), in another thread, the > > file closing completes, eventpoll_release() finishes [..] > > Actually, Al is right that

Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes

2024-05-04 Thread Christian Brauner
On Sat, May 04, 2024 at 12:39:00AM +0100, Al Viro wrote: > On Fri, May 03, 2024 at 04:16:15PM -0700, Linus Torvalds wrote: > > On Fri, 3 May 2024 at 15:07, Al Viro wrote: > > > > > > Suppose your program calls select() on a pipe and dmabuf, sees data to be > > > read > > > from pipe, reads it,

Re: get_file() unsafe under epoll (was Re: [syzbot] [fs?] [io-uring?] general protection fault in __ep_remove)

2024-05-04 Thread Christian Brauner
On Fri, May 03, 2024 at 12:59:52PM -0700, Kees Cook wrote: > On Fri, May 03, 2024 at 01:35:09PM -0600, Jens Axboe wrote: > > On 5/3/24 1:22 PM, Kees Cook wrote: > > > On Fri, May 03, 2024 at 12:49:11PM -0600, Jens Axboe wrote: > > >> On 5/3/24 12:26 PM, Kees Cook wrote: > > >>> Thanks for doing

Re: get_file() unsafe under epoll (was Re: [syzbot] [fs?] [io-uring?] general protection fault in __ep_remove)

2024-05-04 Thread Christian Brauner
On Fri, May 03, 2024 at 11:26:32AM -0700, Kees Cook wrote: > On Fri, May 03, 2024 at 06:54:22PM +0700, Bui Quang Minh wrote: > > [...] > > Root cause: > > AFAIK, eventpoll (epoll) does not increase the registered file's reference. > > To ensure the safety, when the registered file is deallocated

Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes

2024-05-04 Thread Christian Brauner
On Fri, May 03, 2024 at 02:33:37PM -0700, Linus Torvalds wrote: > On Fri, 3 May 2024 at 14:24, Al Viro wrote: > > > > Can we get to ep_item_poll(epi, ...) after eventpoll_release_file() > > got past __ep_remove()? Because if we can, we have a worse problem - > > epi freed under us. > > Look at

Re: [PATCH] epoll: try to be a _bit_ better about file lifetimes

2024-05-04 Thread Christian Brauner
On Fri, May 03, 2024 at 04:41:19PM -0700, Linus Torvalds wrote: > On Fri, 3 May 2024 at 16:23, Kees Cook wrote: > > > > static bool __must_check get_dma_buf_unless_doomed(struct dma_buf *dmabuf) > > { > > return atomic_long_inc_not_zero(>file->f_count) != 0L; > > } > > > > If we end up

Re: [PATCH 5/5] fs: Convert struct file::f_count to refcount_long_t

2024-05-03 Thread Christian Brauner
On Fri, May 03, 2024 at 12:36:14PM +0200, Peter Zijlstra wrote: > On Fri, May 03, 2024 at 11:37:25AM +0200, Christian Brauner wrote: > > On Thu, May 02, 2024 at 05:41:23PM -0700, Kees Cook wrote: > > > On Fri, May 03, 2024 at 01:14:45AM +0100, Al Viro wrote: > > > >

Re: [PATCH 5/5] fs: Convert struct file::f_count to refcount_long_t

2024-05-03 Thread Christian Brauner
On Thu, May 02, 2024 at 05:41:23PM -0700, Kees Cook wrote: > On Fri, May 03, 2024 at 01:14:45AM +0100, Al Viro wrote: > > On Thu, May 02, 2024 at 05:10:18PM -0700, Kees Cook wrote: > > > > > But anyway, there needs to be a general "oops I hit 0"-aware form of > > > get_file(), and it seems like

Re: [PATCH 1/5] fs: Do not allow get_file() to resurrect 0 f_count

2024-05-03 Thread Christian Brauner
On Thu, May 02, 2024 at 04:03:24PM -0700, Kees Cook wrote: > On Fri, May 03, 2024 at 12:53:56AM +0200, Jann Horn wrote: > > On Fri, May 3, 2024 at 12:34 AM Kees Cook wrote: > > > If f_count reaches 0, calling get_file() should be a failure. Adjust to > > > use atomic_long_inc_not_zero() and

Re: [PATCH v2 2/4] eventfd: simplify eventfd_signal()

2024-02-08 Thread Christian Brauner
On Wed, Feb 07, 2024 at 03:34:59PM +0100, Paolo Bonzini wrote: > On Wed, Nov 22, 2023 at 1:49 PM Christian Brauner wrote: > > > > Ever since the evenfd type was introduced back in 2007 in commit > > e1ad7468c77d ("signal/timer/event: eventfd core") the eventfd_

Re: [PATCH v2 0/4] eventfd: simplify signal helpers

2023-11-23 Thread Christian Brauner
On Wed, 22 Nov 2023 13:48:21 +0100, Christian Brauner wrote: > Hey everyone, > > This simplifies the eventfd_signal() and eventfd_signal_mask() helpers > significantly. They can be made void and not take any unnecessary > arguments. > > I've added a few more simplifica

Re: [PATCH v2 2/4] eventfd: simplify eventfd_signal()

2023-11-23 Thread Christian Brauner
> > * eventfd_signal - Adds @n to the eventfd counter. > > This still refers to @n here, and in patch 4. Fixed and folded. Thanks!

Re: [PATCH v2 1/4] i915: make inject_virtual_interrupt() void

2023-11-23 Thread Christian Brauner
> > + if (!vgpu->msi_trigger) > > + return; > > + eventfd_signal(vgpu->msi_trigger, 1); > > } > > I think it's a little simpler to write as > if (vgpu->msi_trigger) > eventfd_signal(vgpu->msi_trigger, 1); Good point. I folded that suggestion into the patch.

[PATCH v2 4/4] eventfd: make eventfd_signal{_mask}() void

2023-11-22 Thread Christian Brauner
No caller care about the return value. Signed-off-by: Christian Brauner --- fs/eventfd.c| 40 +++- include/linux/eventfd.h | 16 +++- 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/fs/eventfd.c b/fs/eventfd.c index

[PATCH v2 3/4] eventfd: simplify eventfd_signal_mask()

2023-11-22 Thread Christian Brauner
The eventfd_signal_mask() helper was introduced for io_uring and similar to eventfd_signal() it always passed 1 for @n. So don't bother with that argument at all. Signed-off-by: Christian Brauner --- fs/eventfd.c| 7 --- include/linux/eventfd.h | 5 ++--- io_uring/io_uring.c

[PATCH v2 2/4] eventfd: simplify eventfd_signal()

2023-11-22 Thread Christian Brauner
Ever since the evenfd type was introduced back in 2007 in commit e1ad7468c77d ("signal/timer/event: eventfd core") the eventfd_signal() function only ever passed 1 as a value for @n. There's no point in keeping that additional argument. Signed-off-by: Christian Brauner --- arch/x86/kv

[PATCH v2 1/4] i915: make inject_virtual_interrupt() void

2023-11-22 Thread Christian Brauner
The single caller of inject_virtual_interrupt() ignores the return value anyway. This allows us to simplify eventfd_signal() in follow-up patches. Signed-off-by: Christian Brauner --- drivers/gpu/drm/i915/gvt/interrupt.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff

[PATCH v2 0/4] eventfd: simplify signal helpers

2023-11-22 Thread Christian Brauner
Hey everyone, This simplifies the eventfd_signal() and eventfd_signal_mask() helpers significantly. They can be made void and not take any unnecessary arguments. I've added a few more simplifications based on Sean's suggestion. Signed-off-by: Christian Brauner Changes in v2: - further

Re: [PATCH v3] fs: clean up usage of noop_dirty_folio

2023-08-29 Thread Christian Brauner
On Tue, 29 Aug 2023 12:00:29 +0800, Xueshi Hu wrote: > In folio_mark_dirty(), it can automatically fallback to > noop_dirty_folio() if a_ops->dirty_folio is not registered. > > In anon_aops, dev_dax_aops and fb_deferred_io_aops, replacing .dirty_folio > with NULL makes them identical to default

Re: [PATCH 0/2] eventfd: simplify signal helpers

2023-07-14 Thread Christian Brauner
On Thu, Jul 13, 2023 at 11:10:54AM -0600, Alex Williamson wrote: > On Thu, 13 Jul 2023 12:05:36 +0200 > Christian Brauner wrote: > > > Hey everyone, > > > > This simplifies the eventfd_signal() and eventfd_signal_mask() helpers > > by removing the count arg

Re: [PATCH 2/2] eventfd: simplify eventfd_signal_mask()

2023-07-13 Thread Christian Brauner
On Thu, Jul 13, 2023 at 07:33:05AM -0700, Sean Christopherson wrote: > On Thu, Jul 13, 2023, Christian Brauner wrote: > > diff --git a/fs/eventfd.c b/fs/eventfd.c > > index dc9e01053235..077be5da72bd 100644 > > --- a/fs/eventfd.c > > +++ b/fs/eventfd.c > > @@ -

[PATCH 1/2] eventfd: simplify eventfd_signal()

2023-07-13 Thread Christian Brauner
Ever since the evenfd type was introduced back in 2007 in commit e1ad7468c77d ("signal/timer/event: eventfd core") the eventfd_signal() function only ever passed 1 as a value for @n. There's no point in keeping that additional argument. Signed-off-by: Christian Brauner --- arch/x86/kv

[PATCH 2/2] eventfd: simplify eventfd_signal_mask()

2023-07-13 Thread Christian Brauner
The eventfd_signal_mask() helper was introduced for io_uring and similar to eventfd_signal() it always passed 1 for @n. So don't bother with that argument at all. Signed-off-by: Christian Brauner --- drivers/gpu/drm/i915/gvt/interrupt.c | 2 +- fs/eventfd.c | 9

[PATCH 0/2] eventfd: simplify signal helpers

2023-07-13 Thread Christian Brauner
Hey everyone, This simplifies the eventfd_signal() and eventfd_signal_mask() helpers by removing the count argument which is effectively unused. --- --- base-commit: 6be357f00aad4189130147fdc6f568cf776a4909 change-id: 20230713-vfs-eventfd-signal-0b0d167ad6ec

Re: [RFC v3 8/8] selftests: Add binder cgroup gpu memory transfer test

2022-03-22 Thread Christian Brauner
On Mon, Mar 14, 2022 at 05:43:40PM -0700, Todd Kjos wrote: > On Wed, Mar 9, 2022 at 8:53 AM T.J. Mercier wrote: > > > > This test verifies that the cgroup GPU memory charge is transferred > > correctly when a dmabuf is passed between processes in two different > > cgroups and the sender specifies

Re: [PATCH 03/11] security: commoncap: fix -Wstringop-overread warning

2021-03-22 Thread Christian Brauner
> Add a separate NULL check to tell gcc about it as well. > > Signed-off-by: Arnd Bergmann > --- Seems reasonable, Acked-by: Christian Brauner ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 2/9] fs: add an argument-less alloc_anon_inode

2021-03-10 Thread Christian Brauner
On Tue, Mar 09, 2021 at 04:53:41PM +0100, Christoph Hellwig wrote: > Add a new alloc_anon_inode helper that allocates an inode on > the anon_inode file system. > > Signed-off-by: Christoph Hellwig > --- Looks good! Reviewed-by: Ch

Re: [PATCH 1/9] fs: rename alloc_anon_inode to alloc_anon_inode_sb

2021-03-10 Thread Christian Brauner
kernel.org/lkml/20210310083040.ga5...@lst.de) Reviewed-by: Christian Brauner > arch/powerpc/platforms/pseries/cmm.c | 2 +- > drivers/dma-buf/dma-buf.c| 2 +- > drivers/gpu/drm/drm_drv.c| 2 +- > drivers/misc/cxl/api.c | 2 +- > drivers/mi

Re: [PATCH] staging: android: ion: Skip sync if not mapped

2020-04-21 Thread Christian Brauner
gt; +++ b/drivers/staging/android/ion/ion.c > > > > > > Now that we have the dma-buff stuff in the tree, do we even need the > > > ion code in the kernel anymore? Can't we delete it now? > > > > > > > I agree that we shouldn't be taking further (non-s

[PATCH net-next] br_netfilter: prevent UAF in brnf_exit_net()

2019-06-20 Thread Christian Brauner
bot+43a3fa52c0d9c5c94...@syzkaller.appspotmail.com Fixes: 22567590b2e6 ("netfilter: bridge: namespace bridge netfilter sysctls") Signed-off-by: Christian Brauner --- net/bridge/br_netfilter_hooks.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/bridge/br_netfilter_hooks.c