]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf: In bpf_task_fd_query use fget_task
authorEric W. Biederman <ebiederm@xmission.com>
Fri, 20 Nov 2020 23:14:22 +0000 (17:14 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Jun 2024 12:52:47 +0000 (14:52 +0200)
commitc874ec02cb8ac5edeb1b01b1df41ed23bbbea562
tree1d84eb6c7d9ffb44fbcf57844b5d0f51a03d01d2
parentfe1722255ebd9b7fa3602ea1e86cf79f8844d43e
bpf: In bpf_task_fd_query use fget_task

[ Upstream commit b48845af0152d790a54b8ab78cc2b7c07485fc98 ]

Use the helper fget_task to simplify bpf_task_fd_query.

As well as simplifying the code this removes one unnecessary increment of
struct files_struct.  This unnecessary increment of files_struct.count can
result in exec unnecessarily unsharing files_struct and breaking posix
locks, and it can result in fget_light having to fallback to fget reducing
performance.

This simplification comes from the observation that none of the
callers of get_files_struct actually need to call get_files_struct
that was made when discussing[1] exec and posix file locks.

[1] https://lkml.kernel.org/r/20180915160423.GA31461@redhat.com
Suggested-by: Oleg Nesterov <oleg@redhat.com>
v1: https://lkml.kernel.org/r/20200817220425.9389-5-ebiederm@xmission.com
Link: https://lkml.kernel.org/r/20201120231441.29911-5-ebiederm@xmission.com
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/syscall.c