Re: [PATCH] 9p: fix EBADF errors in cached mode

From: Christian Schoenebeck
Date: Thu Jun 16 2022 - 09:36:23 EST


On Dienstag, 14. Juni 2022 16:11:35 CEST Christian Schoenebeck wrote:
> On Dienstag, 14. Juni 2022 14:45:38 CEST Dominique Martinet wrote:
[...]
> > Please let me know how that works out, I'd be happy to use either of
> > your versions instead of mine.
> > If I can be greedy though I'd like to post it together with the other
> > couple of fixes next week, so having something before the end of the
> > week would be great -- I think even my first overkill version early and
> > building on it would make sense at this point.
> >
> > But I think you've got the right end, so hopefully won't be needing to
> > delay
>
> I need a day or two for testing, then I will report back for sure. So it
> should perfectly fit into your intended schedule.

Two things:

1. your EBADF patch is based on you recent get/put refactoring patch, so it won't apply on stable.

2. I fixed the conflict and gave your patch a test spin, and it triggers
the BUG_ON(!fid); that you added with that patch. Backtrace based on
30306f6194ca ("Merge tag 'hardening-v5.19-rc3' ..."):

[ 2.211473] kernel BUG at fs/9p/vfs_addr.c:65!
...
[ 2.244415] netfs_alloc_request (fs/netfs/objects.c:42) netfs
[ 2.245438] netfs_readahead (fs/netfs/buffered_read.c:166) netfs
[ 2.246392] read_pages (./include/linux/pagemap.h:1264 ./include/linux/pagemap.h:1306 mm/readahead.c:164)
[ 2.247120] ? folio_add_lru (./arch/x86/include/asm/preempt.h:103 mm/swap.c:468)
[ 2.247911] page_cache_ra_unbounded (./include/linux/fs.h:808 mm/readahead.c:264)
[ 2.248875] filemap_get_pages (mm/filemap.c:2594)
[ 2.249723] filemap_read (mm/filemap.c:2679)
[ 2.250478] ? ptep_set_access_flags (./arch/x86/include/asm/paravirt.h:441 arch/x86/mm/pgtable.c:493)
[ 2.251417] ? _raw_spin_unlock (./arch/x86/include/asm/preempt.h:103 ./include/linux/spinlock_api_smp.h:143 kernel/locking/spinlock.c:186)
[ 2.252253] ? do_wp_page (mm/memory.c:3293 mm/memory.c:3393)
[ 2.253012] ? aa_file_perm (security/apparmor/file.c:604)
[ 2.253824] new_sync_read (fs/read_write.c:402 (discriminator 1))
[ 2.254616] vfs_read (fs/read_write.c:482)
[ 2.255313] ksys_read (fs/read_write.c:620)
[ 2.256000] do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80)
[ 2.256764] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:115)

Did your patch work there for you? I mean I have not applied the other pending
9p patches, but they should not really make difference, right? I won't have
time today, but I will continue to look at it tomorrow. If you already had
some thoughts on this, that would be great of course.

Best regards,
Christian Schoenebeck