Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp658156pxv; Thu, 15 Jul 2021 12:41:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYx6lFrliuft9QoJQpoZBVb+Qjcr2X3f8ko+PMluJihmYt0AMSrJUXvFHyZCyYyJQhCTMs X-Received: by 2002:a05:6402:1488:: with SMTP id e8mr9293786edv.341.1626378101247; Thu, 15 Jul 2021 12:41:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626378101; cv=none; d=google.com; s=arc-20160816; b=jZfeEvHiP61QuFXpJgxfNwQhg6mYZmcnrO5EQt+uXpfQtUK6WUOfyZ1RFiD19VnaYz WMo4FGntm0lkZy6r0p4A7k6TN1Tge2s41tKhh44cxNhdJq6qnsL8uCLJvEyasPoz1hhp zMAqpkikMGjndXYrzPyimG/IksFn2DU288kR+M1gRM7DM1LqRziVepcdnnnGCg3TnSh3 SRrKvGWEOYF2AhimW96Yb3zSWKc81NN5T/D3f0Y+Zh6Kus2wCizvfFVTuRjQ8AtNZN42 f77IJW0kD5eQk4jwWT6LJdPQBGzRFbOvxZH/v2Mb9MnpqWSzCsFpcNQnLNpalgAc19LQ LMcw== 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=RTbJIpI0HoxiFSJOuf8aCy2/eN8xPhfTo8qxRem7E+3H7v8lJtF/7TBg5UF3XzNTsI 6e2UY+5kUvuaguyXewDXUKzwcFr1xNmA9t5Vyg9OKZVypw6Xx2hPFwXaVC/SQsvNRXYa ULJ5yh1R8zqJcs/1f/KriWT1k4nKnPaIspAEMi2ZfBeScSlof77lkRx7/wDmG1WxLfx9 9aDJKoPpiuAT0nu/GhNuEJ3RGYR8Z3N2mYb0zGMoa3JadGSTSB8tTnJnHsRYuZpp+4Sl wh2H3o/dsDNZZArS49XmNX3skaT8/u/1xz1vXXi64BXdpao2+PtkTFSvqfLbU1evEww/ Ylww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qEKJIUa0; 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 y12si8279713edd.423.2021.07.15.12.41.18; Thu, 15 Jul 2021 12:41:41 -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=qEKJIUa0; 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 S238526AbhGOTnS (ORCPT + 99 others); Thu, 15 Jul 2021 15:43:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:50954 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244604AbhGOTO6 (ORCPT ); Thu, 15 Jul 2021 15:14:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BD42B613F3; Thu, 15 Jul 2021 19:10:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376234; bh=Db9BWr13IIhpMoNlTyg48YEuC4w/VdnvUhnVfdi8Q8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qEKJIUa0lPbjysPaWYcdPbNJICWyJETgpI9KoybOa4de9isWGmWcKMM+o9rQM8u3h 1htXhmbclzMGq6k5HOodaiI9jdGBv+aaq1BvBBGFqy6mQBQevjd5j7mk+g4lyt92eX HGqC502PVjZ17mfwV/JkM3EROc1PvEiooPjkP4T8= 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.13 184/266] powerpc/powernv/vas: Release reference to tgid during window close Date: Thu, 15 Jul 2021 20:38:59 +0200 Message-Id: <20210715182643.896511000@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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);