Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp9680822rwl; Wed, 11 Jan 2023 08:37:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXvEfC/59OK45cxxfHhRUXgwIO5RoPuV1vEpXEKiFSl4sKdWPekqVKNKulVOqjQ1qELSPwwJ X-Received: by 2002:a17:90a:8404:b0:226:8b19:4b0f with SMTP id j4-20020a17090a840400b002268b194b0fmr33064309pjn.24.1673455038710; Wed, 11 Jan 2023 08:37:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673455038; cv=none; d=google.com; s=arc-20160816; b=N1EhV71+AtfE4wl0vL9eJjr0YUlGXDViiEe44uW/gfSBQDUk+uOr80OtzjuMQ61PX7 uoZaqn1JouqeDfFf+UfPWnHhGc74v7oCGqn0w0r5JGL/NRluKJB+AFI0wM9Vh8/SnO68 jEms7fHjoqVvjU1liJjcRIe2BnMyMmN+bKZcbWQNRcRKVs6BfAx354uVo19Tb7h493fx QGTF7F1JWOK7rKdvF3+HrmWsBy2p69xhFftKZeoFlKF6B76QaFF/jOk2MXTETIeLwtQW NLyNrK5sbb1VZOVXimiaikYFJ+fwt2kRnVOWMSvSfmoGC34Jk4KW06Ov0urUb9YqinS1 H+4Q== 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=GIyt3EygayEv+EUPap+T58I6DqK8iRxajXV5J9xTeIM=; b=Vycj7kooMMmCwfV0ZsXqtWZgvbE1n1Lw/GPuzYM6Q3HN5l9mZGVgR1qApFf5cKy6yV j2xcWkacNuV70UzcApxIMZiyUnIZEmLt/ZSTMek5UIsU2aBxStlKEtGHCWIF9KzohWZW aX5cFFYIs6q3oY3xfH7/rQTdBe2ZDIn86JQPZIp6qScU5Qhl7Yq5zJKcL7SGHbj0syC6 GfqTc5LmaRO6Yj/DIb82vrhlgGp4UsrrYmdG1hgRaWEVxLCzpLBPzVuH04owiLUYEjMF DunICBPbSpbPYmHIR5EBnC9LBFBRDBzH5kLO9Can0sfJDnEkZeXGIHHF4s0m+qqk9+kv WW1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qL6CC1Vv; 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 m25-20020a637d59000000b004a4417f12b6si14512835pgn.760.2023.01.11.08.37.04; Wed, 11 Jan 2023 08:37:18 -0800 (PST) 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=qL6CC1Vv; 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 S239350AbjAKQcO (ORCPT + 99 others); Wed, 11 Jan 2023 11:32:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234786AbjAKQbm (ORCPT ); Wed, 11 Jan 2023 11:31:42 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11544E76 for ; Wed, 11 Jan 2023 08:31:07 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 9FAD461D7F for ; Wed, 11 Jan 2023 16:31:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9242DC433EF; Wed, 11 Jan 2023 16:31:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673454666; bh=//xO8KlAvalILw2MrywtUVwHB1Cr/Cddh8z5+lnDcxw=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=qL6CC1VvQPyKQAz/56VhIcN4UVvaxBB6fOvlZu0+BcD836mPSjU5qipVfpEZSyY25 3JtpO4JL90Sh6JySG6GKu97S4ESE5Wx3Psd7u2QHC+F3JRDnfbf2eRhsSqGaqZXw09 fBcbuJcRXyiTl3ryI9Q8OZzPzaArq7Ah481jZesu1mL8UqOPgtfP4mPSeUuo6KRiFx R2O3noTN6Pyr0Od2qhgj0H5oAlIxiGt2xWjH8BPZ4pKpWtf9MDDMjq/GuFRils0cOF rL0fITviIXuj/TIaV9c0uMh0VVZyM53xue46sqxoIZK++smcsuhNCu5BNIDJ2uZk3b 2xEjKPUSZ2i8Q== Message-ID: <9153f947ee3fe7c7ab5d1ad2a6760c4485b82bea.camel@kernel.org> Subject: Re: [PATCH] NFSD: fix use-after-free in nfsd4_ssc_setup_dul() From: Jeff Layton To: Xingyuan Mo , chuck.lever@oracle.com Cc: linux-nfs@vger.kernel.org, dai.ngo@oracle.com Date: Wed, 11 Jan 2023 11:31:04 -0500 In-Reply-To: <20230111162453.8295-1-hdthky0@gmail.com> References: <20230111162453.8295-1-hdthky0@gmail.com> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.3 (3.46.3-1.fc37) MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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-01-12 at 00:24 +0800, Xingyuan Mo wrote: > If signal_pending() returns true, schedule_timeout() will not be executed= , > causing the waiting task to remain in the wait queue. > Fixed by adding a call to finish_wait(), which ensures that the waiting > task will always be removed from the wait queue. >=20 > Reported-by: Xingyuan Mo > Signed-off-by: Xingyuan Mo > --- > fs/nfsd/nfs4proc.c | 1 + > 1 file changed, 1 insertion(+) >=20 > diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c > index bd880d55f565..3fa819e29b3f 100644 > --- a/fs/nfsd/nfs4proc.c > +++ b/fs/nfsd/nfs4proc.c > @@ -1318,6 +1318,7 @@ static __be32 nfsd4_ssc_setup_dul(struct nfsd_net *= nn, char *ipaddr, > /* allow 20secs for mount/unmount for now - revisit */ > if (signal_pending(current) || > (schedule_timeout(20*HZ) =3D=3D 0)) { > + finish_wait(&nn->nfsd_ssc_waitq, &wait); > kfree(work); > return nfserr_eagain; > } Nice catch. Reviewed-by: Jeff Layton