afs: Fix potential null pointer dereference in afs_put_server
Subsystems (2)
PATCH 1/1 afs: Fix potential null pointer dereference in afs_put_server
afs_put_server() accessed server->debug_id before the NULL check, which could lead to a null pointer dereference. Move the debug_id assignment, ensuring we never dereference a NULL server pointer.
--- fs/afs/server.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/afs/server.c +2 -1
@@ -331,13 +331,14 @@ struct afs_server *afs_use_server(struct afs_server *server, bool activate,void afs_put_server (struct afs_net *net,struct afs_server *server,enum afs_server_trace reason) { -unsigned int a, debug_id = server->debug_id; +unsigned int a, debug_id;bool zero;int r;if (!server)return ; + debug_id = server->debug_id; a =atomic_read (&server->active); zero =__refcount_dec_and_test (&server->ref, &r);trace_afs_server (debug_id, r -1 , a, reason);
Signature · 1 line
2.20.1
Quoted 21 lines · Zhen Ni
afs_put_server()accessedserver->debug_idbefore the NULL check, which could lead to a null pointer dereference. Move thedebug_idassignment, ensuring we never dereference a NULL server pointer.Fixes 2757a4dc1849 ("afs: Fix access after dec in put functions")Signed-off-by Zhen Ni <[email protected]>--- fs/afs/server.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/afs/server.c +1
-1@@ -331,13 +331,14 @@ struct afs_server *afs_use_server(struct afs_server *server, bool activate,void afs_put_server (struct afs_net *net,struct afs_server *server,enum afs_server_trace reason) { -unsigned int a, debug_id = server->debug_id; +unsigned int a, debug_id;
fs/afs/server.c struct afs_server *afs_use_server(struct afs_server *server, bool activate, · line 344
Quoted 10 lines
fs/afs/server.c +1
-0bool zero;int r;if (!server)return ; + debug_id = server->debug_id; a =atomic_read (&server->active); zero =__refcount_dec_and_test (&server->ref, &r);trace_afs_server (debug_id, r -1 , a, reason);
Looks good.
Hi Christian,
Quoted 7 lines · Zhen Ni
afs_put_server()accessedserver->debug_idbefore the NULL check, which could lead to a null pointer dereference. Move thedebug_idassignment, ensuring we never dereference a NULL server pointer.Fixes 2757a4dc1849 ("afs: Fix access after dec in put functions")Signed-off-by Zhen Ni <[email protected]>
Can you pick this patch up and add:
Thanks,
David
Christian Brauner
AppliedQuoted 5 lines · Zhen Ni
afs_put_server()accessedserver->debug_idbefore the NULL check, which could lead to a null pointer dereference. Move thedebug_idassignment, ensuring we never dereference a NULL server pointer.
Applied to the vfs.fixes branch of the vfs/vfs.git tree. Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.fixes
[1/1] afs: Fix potential null pointer dereference in afs_put_server
https://git.kernel.org/vfs/vfs/c/9158c6bb2451