Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp644344pxv; Thu, 15 Jul 2021 12:18:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzjJ2B+5cI2qIpHrbwGUZVLAXzs/EiHjRmf6R/VH7/6dFwiodcJqFkauH2Fx78Qju0aKeJ X-Received: by 2002:a17:906:8252:: with SMTP id f18mr7107607ejx.261.1626376734969; Thu, 15 Jul 2021 12:18:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626376734; cv=none; d=google.com; s=arc-20160816; b=UQoIqxJchrVKWP213m2R01PSvrTr9Zgw6Vy7JTaAceOduW6nn5MGW8YdXpVtVm6Bz8 H3SPi3ot4nYhgyHbnMlxq3awqmYDdAu3dS3VXZaVFRwc+5V/vTpYiutSZgCxWVip4Qk/ ok22705fJ3SVaScMgJCj8JTueXwjY+7MaGu9oEiVd6EHgcpzdZksdw9LO3hYgbn+nlKP WBnAUHZKaey+N3/1tAvxY0OsE+YPm9LlnLPKV/xYyJUbTUSHKKiSXCmHLVlzGiDDoHAY xMCSN4uafCeQaAqowvzuApNGoWPO0tyBricBZLyRBPewTYfBdF4WRzAHOtF+5eZuLotv iWIg== 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=vD5wX17NiyPxWmEmcbQMm8x2bMe0DoQ5YwiaHHi5wH5hgIUVdKdK4gzR7iC6hY/UQz P5gzAdYJ/lOiHSsmjC1UEWfBIeZys0sqUhrWFTQlZ8AvHOyZw6+amv1mz/meNLSgpSD9 kaHHUoEpBH5/3qn6a/6+QQcTdKdDUlKEbXwo31Op9cSw+iO11o3jymIKhTkzkbAeTU9J K79kXo5U9dXR8ibZKkL2HSnJnPUxA3qbU01fHf0cn7o9ClD5+uU5KkfkN/a+K2uNdS6d e3dd2PLGTRMCaW7RzqrSylUCZwSAbvY8GMOhlew6zAyckqqFnUYEHKQOkLFcZ5rvznfO 3H/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=byYuw+bA; 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 ce5si8118833ejb.237.2021.07.15.12.18.31; Thu, 15 Jul 2021 12:18: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=byYuw+bA; 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 S245284AbhGOTTe (ORCPT + 99 others); Thu, 15 Jul 2021 15:19:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:39756 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240772AbhGOTEl (ORCPT ); Thu, 15 Jul 2021 15:04:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 49F77613ED; Thu, 15 Jul 2021 19:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375649; bh=Db9BWr13IIhpMoNlTyg48YEuC4w/VdnvUhnVfdi8Q8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=byYuw+bAxnWtFno03+X/oNvfTrTQGySRk1N9rSsqj00zxwMNeLjxXzFZDDU0ACUFo bW/lRacKc+zzbO9b4Hrvf+cr7rc+BHjdEF1kj4x4E2GosSWEJn2oDIw9t7F2sHd6NR WyvAMKS299MNFVXOwmIEgb3nmHANVKBNH89q7lUg= 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.12 160/242] powerpc/powernv/vas: Release reference to tgid during window close Date: Thu, 15 Jul 2021 20:38:42 +0200 Message-Id: <20210715182621.304638640@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@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);