Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B4AA4437F for ; Fri, 4 Oct 2024 22:04:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728079455; cv=none; b=Y5gbsFqDTH9YoRcscGayizJfTPH76O4MNF4uByMHNIcfVMn8cu33WPbDjKYTeAyb68ef1zZsCdhB8UIIEAYS5OEIZ6hhOWXLTG+zQcYBnmodDaGuiYGUb7oIKOgtCIv4zyZgDiDzdHZ+y94HSmH7+73cV+kHycJ49PYHk2H1rx4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728079455; c=relaxed/simple; bh=H6F4oisiXQH5TBReZgwJfn2qQ2ERUEF3fm/x7plkIUY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=rwOMKkkH1tNhtPjdm/Ep1Feu2QTfZE5De0jHM6SfT36wvNZuTJtPCqqw5yRW03sXdiX87oDWHIvsP0Y6iTAHFmdOy31Ebzsx7RN10DJCdLrtcgDCkdlgBeDk3eNnFBInH52gmWTQoGxJ7cgQY+1V10KhXDq7LFBPp+njNsl2W5w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=iwSbxTPC; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iwSbxTPC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728079452; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=0IGprmyyjjQzPQe4OyVSogmJi13grvMR6zOq7likQRU=; b=iwSbxTPCD00sFvU7dPAoxEdsMr5BT8xOqeWUC0//Q0S8Jx/0LdA6y4dNyCodvCOjFgFsTV E7YXwW++t4Yjjh7c6BJilR/SmeiN7dvaqsaMhgSYnuIDk4jckNyTqKynJKw8f19dllyC11 g3pWcoNfgqVnbP1MSq1KGPB3jb65LPQ= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-453-kX7D7GGiPzq4M-mge1oM_g-1; Fri, 04 Oct 2024 18:04:09 -0400 X-MC-Unique: kX7D7GGiPzq4M-mge1oM_g-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C481019560AE; Fri, 4 Oct 2024 22:04:07 +0000 (UTC) Received: from okorniev-mac.redhat.com (unknown [10.22.17.120]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 352D81956088; Fri, 4 Oct 2024 22:04:06 +0000 (UTC) From: Olga Kornievskaia To: chuck.lever@oracle.com, jlayton@kernel.org Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia , stable@vger.kernel.org Subject: [PATCH 1/1] nfsd: fix possible badness in FREE_STATEID Date: Fri, 4 Oct 2024 18:04:03 -0400 Message-Id: <20241004220403.50034-1-okorniev@redhat.com> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 When multiple FREE_STATEIDs are sent for the same delegation stateid, it can lead to a possible either use-after-tree or counter refcount underflow errors. In nfsd4_free_stateid() under the client lock we find a delegation stateid, however the code drops the lock before calling nfs4_put_stid(), that allows another FREE_STATE to find the stateid again. The first one will proceed to then free the stateid which leads to either use-after-free or decrementing already zerod counter. CC: stable@vger.kernel.org Signed-off-by: Olga Kornievskaia --- fs/nfsd/nfs4state.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index ac1859c7cc9d..56b261608af4 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -7154,6 +7154,7 @@ nfsd4_free_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, switch (s->sc_type) { case SC_TYPE_DELEG: if (s->sc_status & SC_STATUS_REVOKED) { + s->sc_status |= SC_STATUS_CLOSED; spin_unlock(&s->sc_lock); dp = delegstateid(s); list_del_init(&dp->dl_recall_lru); -- 2.43.5