Re: [PATCH] binfmt_misc: fix leaked write-access denial on F-flag interpreter inode
From: Christian Brauner
Date: Wed Jul 22 2026 - 10:19:03 EST
On 2026-07-21 15:26 +0530, Aayush7352 wrote:
> From: Aayush Dixit <aayushdixit924@xxxxxxxxx>
>
> put_binfmt_handler() closes an F-flag (MISC_FMT_OPEN_FILE) entry's
> interpreter file without restoring the write access that open_exec()
> denied at registration. Every register/delete cycle of an F entry
> leaks one i_writecount denial on the interpreter's inode, so that
> inode returns -ETXTBSY to all writers until it is evicted from the
> inode cache or the machine reboots.
>
> The registration error path (add_entry failure) correctly calls
> exe_file_allow_write_access() before filp_close(), but the normal
> teardown path in put_binfmt_handler() was missing it.
>
> Fix by adding exe_file_allow_write_access() before filp_close() in
> put_binfmt_handler(). exe_file_allow_write_access() is NULL-safe
> and skips FMODE_FSNOTIFY_HSM files, so no imbalance is possible.
>
> Fixes: 948b701a607f ("binfmt_misc: add persistent opened binary handler for containers")
> Cc: linux-fsdevel@xxxxxxxxxxxxxxx
> Signed-off-by: Aayush7352 <aayushdixit924@xxxxxxxxx>
> ---
Sorry, there's already a fix in vfs-7.3.binfmt for this.