Change the logic in obj_sock_adjust_users()
PATCH 1/1 Change the logic in obj_sock_adjust_users()
The explicit decrement of obj->users isn't correct for all cases of SOCK_DEAD, so this patch changes it to the result of ref_users() to avoid the false positive in the leak check. I have confirmed with sockets in both SOCK_DEAD situations that we don't leak them with this change.
--- kernel/checkpoint/objhash.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/checkpoint/objhash.c +2 -2
@@ -546,7 +546,7 @@ static void ckpt_obj_users_inc(struct ckpt_ctx *ctx, void *ptr, int increment)* obj_sock_adjust_users - remove implicit reference on DEAD sockets * @obj: CKPT_OBJ_SOCK object to adjust * -* Sockets that have been disconnected from their struct file have +* Sockets that have been disconnected from their struct file may have * a reference count one less than normal sockets. The objhash's * assumption of such a reference is therefore incorrect, so we correct * it here.
@@ -556,7 +556,7 @@ static inline void obj_sock_adjust_users(struct ckpt_obj *obj)struct sock *sk = (struct sock *)obj->ptr;if (sock_flag (sk,SOCK_DEAD )) { - obj->users--; + obj->users = obj->ops->ref_users (obj->ptr);ckpt_debug ("Adjusting SOCK %i count to %i\n" , obj->objref, obj->users); }
Signature · 1 line
1.7.2.2
A message that is not in the archive (sent off-list or not yet received): 1284071121-17701-1-git-send-email-danms-r/[email protected]
Simple enough - queued for v22-dev.
Oren
Quoted 33 lines · Dan Smith
The explicit decrement of
obj->usersisn't correct for all cases ofSOCK_DEAD, so this patch changes it to the result ofref_users()to avoid the false positive in the leak check. I have confirmed with sockets in bothSOCK_DEADsituations that we don't leak them with this change.Signed-off-by Dan Smith <danms-r/[email protected]>--- kernel/checkpoint/objhash.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)kernel/checkpoint/objhash.c +2
-2@@ -546,7 +546,7 @@ static void ckpt_obj_users_inc(struct ckpt_ctx *ctx, void *ptr, int increment)* obj_sock_adjust_users - remove implicit reference on DEAD sockets * @obj: CKPT_OBJ_SOCK object to adjust * -* Sockets that have been disconnected from their struct file have +* Sockets that have been disconnected from their struct file may have * a reference count one less than normal sockets. The objhash's * assumption of such a reference is therefore incorrect, so we correct * it here. @@ -556,7 +556,7 @@ static inline void obj_sock_adjust_users(struct ckpt_obj *obj)struct sock *sk = (struct sock *)obj->ptr;if (sock_flag (sk,SOCK_DEAD )) { - obj->users--; + obj->users = obj->ops->ref_users (obj->ptr);ckpt_debug ("Adjusting SOCK %i count to %i\n" , obj->objref, obj->users); }