Skip to content

Commit 5085e41

Browse files
jtlaytonchucklever
authored andcommitted
sunrpc: only free unix grouplist after RCU settles
While the unix_gid object is rcu-freed, the group_info list that it contains is not. Ensure that we only put the group list reference once we are really freeing the unix_gid object. Reported-by: Zhi Li <yieli@redhat.com> Link: https://bugzilla.redhat.com/show_bug.cgi?id=2183056 Signed-off-by: Jeff Layton <jlayton@kernel.org> Fixes: fd5d2f7 ("SUNRPC: Make server side AUTH_UNIX use lockless lookups") Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 15a8b55 commit 5085e41

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

net/sunrpc/svcauth_unix.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,14 +416,23 @@ static int unix_gid_hash(kuid_t uid)
416416
return hash_long(from_kuid(&init_user_ns, uid), GID_HASHBITS);
417417
}
418418

419-
static void unix_gid_put(struct kref *kref)
419+
static void unix_gid_free(struct rcu_head *rcu)
420420
{
421-
struct cache_head *item = container_of(kref, struct cache_head, ref);
422-
struct unix_gid *ug = container_of(item, struct unix_gid, h);
421+
struct unix_gid *ug = container_of(rcu, struct unix_gid, rcu);
422+
struct cache_head *item = &ug->h;
423+
423424
if (test_bit(CACHE_VALID, &item->flags) &&
424425
!test_bit(CACHE_NEGATIVE, &item->flags))
425426
put_group_info(ug->gi);
426-
kfree_rcu(ug, rcu);
427+
kfree(ug);
428+
}
429+
430+
static void unix_gid_put(struct kref *kref)
431+
{
432+
struct cache_head *item = container_of(kref, struct cache_head, ref);
433+
struct unix_gid *ug = container_of(item, struct unix_gid, h);
434+
435+
call_rcu(&ug->rcu, unix_gid_free);
427436
}
428437

429438
static int unix_gid_match(struct cache_head *corig, struct cache_head *cnew)

0 commit comments

Comments
 (0)