]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
fscontext: do not consume log entries when returning -EMSGSIZE
authorAleksa Sarai <cyphar@cyphar.com>
Wed, 6 Aug 2025 17:55:23 +0000 (03:55 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 19 Oct 2025 14:23:05 +0000 (16:23 +0200)
commit7c1d0181211cf99f8561d140010b8c3b169b2c80
tree2e89ae61dab199e9c2010e413bb8e9f323b826f0
parentfd85fc06325167e0b2a3ca3c685320384102dbd6
fscontext: do not consume log entries when returning -EMSGSIZE

commit 72d271a7baa7062cb27e774ac37c5459c6d20e22 upstream.

Userspace generally expects APIs that return -EMSGSIZE to allow for them
to adjust their buffer size and retry the operation. However, the
fscontext log would previously clear the message even in the -EMSGSIZE
case.

Given that it is very cheap for us to check whether the buffer is too
small before we remove the message from the ring buffer, let's just do
that instead. While we're at it, refactor some fscontext_read() into a
separate helper to make the ring buffer logic a bit easier to read.

Fixes: 007ec26cdc9f ("vfs: Implement logging through fs_context")
Cc: David Howells <dhowells@redhat.com>
Cc: stable@vger.kernel.org # v5.2+
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
Link: https://lore.kernel.org/20250807-fscontext-log-cleanups-v3-1-8d91d6242dc3@cyphar.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/fsopen.c