Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp633204pxv; Thu, 15 Jul 2021 12:02:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSYF3pFTglJsa8X2Io/1XC+gozzNx5t5uXuEp0piYMhHXuAs/5bv0bwsKliup1wxyZKGX1 X-Received: by 2002:a02:cf31:: with SMTP id s17mr5381270jar.46.1626375774189; Thu, 15 Jul 2021 12:02:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375774; cv=none; d=google.com; s=arc-20160816; b=PM6NkN3BlVANcg0ZoqOa/mm04e8lGyrJQfXcHhVvufrWX/PMS3cDdKU90jWmRLdqvz 3gVXLZVji82by3+p0KsqZf4HyAzyOmzg5xiyAdTw9mSfeXEtm1lX73m87FuVq8V3qBuy xm0uJWp95wpD/lctWvjkbIxty8VhR4ANHyprJaXXgg0GCUaEbdJ7EXAcaUMiJNNNffId 71P06EFxsRILS5LGUzg91jGgj+DGxjvOetmVhJowwolhTdtVuiKkVs6COJADCNlq2x+I WJDi3P1//FOeUdRWa6AOM5tGLl7M7/O/fpP3D6YjJy0xj7ML7TNxPzvrzzs7AFpOrRc3 opMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wMuH8teu8M9vDAdRO7tbtI2VCgGfUCLdNjn8hu33rek=; b=Ji4/lavypb6qHhRFUqVAD73PTTPFKzzMMdWWqFniqfkoLrL/DxEXoiZj9TddZR0nQ2 QsL+eb35DAIOacF790xv+Y07hxYiG0EPXjZUhLYuEGuaI9vzQIdQzCnlNqN1v3s+KBF6 /FwPoncoadFPvudFkKuN8NsJC4ibIlggwxGO5cOuY2XTv8xjnDJAWTiVdbx+N/MXfZu9 xlU9xulOItNqs5BkhHDAsTCBWCnlDPWWENmJtdeNyIAZXhP+Oje5ocB42C+0QP6ausWn 6V6ZhGKANY6L0BUBg3YrloN+Tb7UNx89d/vsmaTWvkir+S+otpXlEy/mCyNnphar2VDe ny7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=veqORtke; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s17si7571373jaj.68.2021.07.15.12.02.38; Thu, 15 Jul 2021 12:02:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=veqORtke; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243491AbhGOTE1 (ORCPT + 99 others); Thu, 15 Jul 2021 15:04:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:59368 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239301AbhGOSzM (ORCPT ); Thu, 15 Jul 2021 14:55:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D43E7610C7; Thu, 15 Jul 2021 18:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375137; bh=Db9BWr13IIhpMoNlTyg48YEuC4w/VdnvUhnVfdi8Q8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=veqORtke8VIcP59pKpyeBhTuI9RGv5IUOJnDUOmiPn+recZFaa67BNWwXq3XiQP5a tlZYkivj75uzIfSxhorhIJO52PsuyePRgcSAMjEnifvt/htnpVsLIlheR63JO/3EUL V+iWelM4p6CeMCSgAM0Np3qcnfkcDcnTisxTrtUQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Piggin , Haren Myneni , Michael Ellerman Subject: [PATCH 5.10 148/215] powerpc/powernv/vas: Release reference to tgid during window close Date: Thu, 15 Jul 2021 20:38:40 +0200 Message-Id: <20210715182625.796429330@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Haren Myneni commit 91cdbb955aa94ee0841af4685be40937345d29b8 upstream. The kernel handles the NX fault by updating CSB or sending signal to process. In multithread applications, children can open VAS windows and can exit without closing them. But the parent can continue to send NX requests with these windows. To prevent pid reuse, reference will be taken on pid and tgid when the window is opened and release them during window close. The current code is not releasing the tgid reference which can cause pid leak and this patch fixes the issue. Fixes: db1c08a740635 ("powerpc/vas: Take reference to PID and mm for user space windows") Cc: stable@vger.kernel.org # 5.8+ Reported-by: Nicholas Piggin Signed-off-by: Haren Myneni Reviewed-by: Nicholas Piggin Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/6020fc4d444864fe20f7dcdc5edfe53e67480a1c.camel@linux.ibm.com Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/platforms/powernv/vas-window.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/arch/powerpc/platforms/powernv/vas-window.c +++ b/arch/powerpc/platforms/powernv/vas-window.c @@ -1093,9 +1093,9 @@ struct vas_window *vas_tx_win_open(int v /* * Process closes window during exit. In the case of * multithread application, the child thread can open - * window and can exit without closing it. Expects parent - * thread to use and close the window. So do not need - * to take pid reference for parent thread. + * window and can exit without closing it. so takes tgid + * reference until window closed to make sure tgid is not + * reused. */ txwin->tgid = find_get_pid(task_tgid_vnr(current)); /* @@ -1339,8 +1339,9 @@ int vas_win_close(struct vas_window *win /* if send window, drop reference to matching receive window */ if (window->tx_win) { if (window->user_win) { - /* Drop references to pid and mm */ + /* Drop references to pid. tgid and mm */ put_pid(window->pid); + put_pid(window->tgid); if (window->mm) { mm_context_remove_vas_window(window->mm); mmdrop(window->mm);