Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp45567rwl; Thu, 30 Mar 2023 11:56:20 -0700 (PDT) X-Google-Smtp-Source: AK7set8Dv+RdAkBIWdWvbBWFZzCX5+7q45l5hUAE9MifzNPmRgvKkTiwO7FtxMUERLEzu1ZHCD5I X-Received: by 2002:a05:6a20:4c18:b0:db:10c8:4188 with SMTP id fm24-20020a056a204c1800b000db10c84188mr20242171pzb.41.1680202580154; Thu, 30 Mar 2023 11:56:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680202580; cv=none; d=google.com; s=arc-20160816; b=QNzTzycJPgIaVN10rT1EeJ8mXolwGpEdyxMZn2MFg191m5nBw2YvHJPYRtlCig4jer csKGyl8PwW76fJ4CHkXLkoZpUY/Sb94o8jXDU3y/gE2CjmuE5HGDCUfH2PZBSMx8iqbt dDehlud0NG2bNiRHTz7ygNGo3HDnE7/xWzbzm6GGXuQ6R1s9LIn194odo7fP0WaeAfT1 nbRmYOizFbicUTYRb0i5YEvjuSPcbuFh009JAKAkVao9G6dXuG0o3TdxpQ2Tg2QHBmwm 7zRlgIsAeRH8WnscnzL3Z51tbSU5YdLxFTrNu1UlPBsgjke8d6d5sIE4n7UbYiwo3F6B 6DjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=ywKN7dkwou4vU3AvuCwSVTQzDNdZMhqazGXUc4H92qc=; b=RbCd9J7LgHF9n4X+IE4WoRpk1fo2fMsHXCW/nmvzHlwUHMDSSSQyOJw7FPP+IATiM+ PNsIlQhTTBGlzM2HpBUeMQpKk+ciMdioeCOhCeVKeSvTus775W10A+Ozb2v8KrG6Bv4r 4XYESVJ6JSPNI7CMQ045McLcrT3qnY7TevhNU5jLIzGnrqKsnFQs0awa2iHoL6WLpl5Y 4dV5EJRdgKXu202liAgc4BGyAZNyIy3JpN7wX+zLexjD/dh9NgoLOstxtAH8RI9UHw0A L3QadlBZ6ky7mXHWSx7OcmG5CRhsLij8xiDS3Ns+pt1W8jfU2nfT3EpCW99WHA2dAHVK QJug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O0oLDQ59; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j70-20020a638b49000000b004d3cdf2aae7si290756pge.789.2023.03.30.11.56.04; Thu, 30 Mar 2023 11:56:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O0oLDQ59; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229943AbjC3Stf (ORCPT + 99 others); Thu, 30 Mar 2023 14:49:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231689AbjC3Stc (ORCPT ); Thu, 30 Mar 2023 14:49:32 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54DB5D314 for ; Thu, 30 Mar 2023 11:49:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 03325B829E6 for ; Thu, 30 Mar 2023 18:49:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48929C433D2; Thu, 30 Mar 2023 18:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680202168; bh=DWJJQCHfIcsajia5y4Qg+6PDpLinmL8KbsspINYnBxg=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=O0oLDQ5942oLjoDb3wPpLgOmVwRVxfQFCIj5vAU+y6XZn8dVehnOtfGchAFaf8JcS p9IH02OfpxCmvGTlp5NQLy1EHzhj/D57Nu1zkcrfX7il5AXj6lwXlymO9a43zTq6Wm IDOxW7DMbyUOp7wIK8HGK+Vc/22ECadBXxqcVNkhCj8Pjn8hX9Ts5JNtxOYyz+JAiL apd6yQ8XtjGzhoy6Qb67SKxSz8yWWle1mJxCeAW76Gk74d4lX66Ed0pAUx5XKEfp60 y9A85CgSWorfM76C5YLyAJfoMGxPms2YhLlOYyKmw8u2iwqiC2RkjLyIeGTX0uHMis DplHck/ZPtDsA== Message-ID: <12c783873abcd0f9c631e2f367cc1dd97949e0fb.camel@kernel.org> Subject: Re: [PATCH] sunrpc: only free unix grouplist after RCU settles From: Jeff Layton To: Chuck Lever III Cc: Linux NFS Mailing List , Benjamin Coddington , Zhi Li Date: Thu, 30 Mar 2023 14:49:26 -0400 In-Reply-To: <49AC9CF4-71A8-48D7-BF21-41FFFEFBE4C8@oracle.com> References: <20230330182427.19013-1-jlayton@kernel.org> <49AC9CF4-71A8-48D7-BF21-41FFFEFBE4C8@oracle.com> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Thu, 2023-03-30 at 18:31 +0000, Chuck Lever III wrote: > Hi Jeff- >=20 > > On Mar 30, 2023, at 2:24 PM, Jeff Layton wrote: > >=20 > > 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. > >=20 > > Reported-by: Zhi Li >=20 > Should we also add >=20 > Fixes: fd5d2f78261b ("SUNRPC: Make server side AUTH_UNIX use lockless loo= kups") ? >=20 >=20 Sure. That does look like when that particular bug crept in. =20 > > Link: https://bugzilla.redhat.com/show_bug.cgi?id=3D2183056 >=20 > This bug isn't publicly accessible, fwiw. >=20 Thanks. It should be now. >=20 > > Signed-off-by: Jeff Layton > > --- > > net/sunrpc/svcauth_unix.c | 17 +++++++++++++---- > > 1 file changed, 13 insertions(+), 4 deletions(-) > >=20 > > diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c > > index 50e2eb579194..4485088ce27b 100644 > > --- a/net/sunrpc/svcauth_unix.c > > +++ b/net/sunrpc/svcauth_unix.c > > @@ -416,14 +416,23 @@ static int unix_gid_hash(kuid_t uid) > > return hash_long(from_kuid(&init_user_ns, uid), GID_HASHBITS); > > } > >=20 > > -static void unix_gid_put(struct kref *kref) > > +static void unix_gid_free(struct rcu_head *rcu) > > { > > - struct cache_head *item =3D container_of(kref, struct cache_head, ref= ); > > - struct unix_gid *ug =3D container_of(item, struct unix_gid, h); > > + struct unix_gid *ug =3D container_of(rcu, struct unix_gid, rcu); > > + struct cache_head *item =3D &ug->h; > > + > > if (test_bit(CACHE_VALID, &item->flags) && > > !test_bit(CACHE_NEGATIVE, &item->flags)) > > put_group_info(ug->gi); > > - kfree_rcu(ug, rcu); > > + kfree(ug); > > +} > > + > > +static void unix_gid_put(struct kref *kref) > > +{ > > + struct cache_head *item =3D container_of(kref, struct cache_head, ref= ); > > + struct unix_gid *ug =3D container_of(item, struct unix_gid, h); > > + > > + call_rcu(&ug->rcu, unix_gid_free); > > } > >=20 > > static int unix_gid_match(struct cache_head *corig, struct cache_head *= cnew) > > --=20 > > 2.39.2 > >=20 >=20 > -- > Chuck Lever >=20 >=20 --=20 Jeff Layton