Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2388723pxj; Sun, 13 Jun 2021 19:14:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWxTJ5Xg8JR8ge5UIQabSWVGTGyQsjvF62oaiJ4+ZimpBI8ul3/BNjYkNdfQ3cXTDSIqeN X-Received: by 2002:a17:906:81da:: with SMTP id e26mr12928680ejx.370.1623636893523; Sun, 13 Jun 2021 19:14:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623636893; cv=none; d=google.com; s=arc-20160816; b=zgIUA4N2gjP/sDymuD1nPWVyON7xlZogiD7bTgmJG9wI2luE8NcF/HM7yfvUw+HQnx 5s0LRMDCe14+eQ+cRUZec4kd050PlAHWJq9cZDUD75tTuYp5kF4DS8qj2zGqLfie+AOu 5rfuboHljgpGFI/KvcI8+eogUtReaoRXPhVd7bMR3oxtgyNsNsWm1n/NRBC/0KmwT07+ NpyfSL0FS+ulpwo/0234XpDUIwHC+v/+T8tBQvViLHiywDvCvrl9ixd4ao0YVWp2yizD sumD/zhh6l/Ho5Kj3ootjZq8MjkzS3h+2UIQhsagt69bwXfARub3NznyFUCm1srltKDD 2nNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id :mime-version:in-reply-to:references:cc:to:subject:from:date :dkim-signature; bh=v4Fu4xxoDiWhZlH1o8ZlqZuR7cYM6Y8M/w4ESBKxI2k=; b=cm4yZIU6uJOnqTCUlDe7r2QUyGyu9nEJGx/FUgowhlGXlwuGS6L2sxGX9CyTLQVPVB yJIKpNMCBwRqj13x9EzYqHwk8jHYO8Rcwa/uoihX2twjobL1Inimo0nHuqmQ8spRQYVs 1RtlH7cS9GuYXtYdu+hRx4zBbIoJeVG396iWnrb04K8OX4b6I9QsqoU4oL/fxyH3duYS QvyzQBUSB/3vOuZavs95tyowXv+beAI1xqneq7HN2BrHJ40TeZL2yQUp68xHRmATWmHN Cr2RbDK6cH+VONN3DJKTM+hGJn+d4H/FJHjBrXEi3ji7amhO55TVaYDJnVBKEyKeupzk ywPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ot2i+lwA; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v22si10534242ejc.505.2021.06.13.19.14.30; Sun, 13 Jun 2021 19:14:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=@gmail.com header.s=20161025 header.b=ot2i+lwA; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232355AbhFNCOs (ORCPT + 99 others); Sun, 13 Jun 2021 22:14:48 -0400 Received: from mail-pj1-f50.google.com ([209.85.216.50]:33708 "EHLO mail-pj1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232336AbhFNCOs (ORCPT ); Sun, 13 Jun 2021 22:14:48 -0400 Received: by mail-pj1-f50.google.com with SMTP id k22-20020a17090aef16b0290163512accedso9629252pjz.0 for ; Sun, 13 Jun 2021 19:12:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:references:in-reply-to:mime-version :message-id:content-transfer-encoding; bh=v4Fu4xxoDiWhZlH1o8ZlqZuR7cYM6Y8M/w4ESBKxI2k=; b=ot2i+lwAav7/lXoGb0mcnPRLXIp3V9XIixu9sg5RpjuhXl9dX20/jtczYdpVW+TfnI T7WyuZuKMAYuZdz8G0eBvPXKI+qlSBH/We324I4lS8TQSDmL+t2eTrIwMtePnmAO+nFt 3LCrYiJL4717KDHQpGzfraX2xIgOQSXcL7vsPrxcTofPNS6iskeKi7iX4pO2PmzEk8G4 hwtXjm3CxquGFn6eplMI6MxXr9UUMK+eTNV7r3v5z6GJm3im+6F7Z5s6klcRno24jClu J/XUCwmkauW7+bkMUGx95PotYYrBbQ0UOBh2+PeWyHyX6Dv1JRRAfbBP+sEiIsLoddYI vV2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:references:in-reply-to :mime-version:message-id:content-transfer-encoding; bh=v4Fu4xxoDiWhZlH1o8ZlqZuR7cYM6Y8M/w4ESBKxI2k=; b=MJSW91K6ACEIrzpA4ZRb4g7bxIQNSjw1Vhy1M/+T/DwT9PQM14Z/1RYUogencG2hV3 Bk8C0gPszkW5kHaTQ3lWLRQwUawK19GqS2wbhvZT0U2Md7R58IdykF0fda5HZ4mqZYf2 xJTLitQEOTAzGfaq29Em+bsY4+dHDcAmnAhVOF/oiqoSm91XJH5V2oMlJHzx8EWAm7ur W9S8Hc0NickKkwhZN+pdQv32wNSFnAjft1nT/zV7MkfiIevH177KosD0rGv7aCy/twQG 6lOBsHHEGxuPsGzbcs5qvpEpJx7012Lhb5zXc+ZgclRX7rw9utHU1baU5fH7nykAaMbk k4GQ== X-Gm-Message-State: AOAM531bGGVp2w7dayvUnf76pNbnj4XDv0q1/FjWQx5kJUIvmkDO0jAw wdWAcUDqdzKnGPKNSJqjZ10= X-Received: by 2002:a17:90a:4503:: with SMTP id u3mr16743381pjg.210.1623636706302; Sun, 13 Jun 2021 19:11:46 -0700 (PDT) Received: from localhost (60-242-147-73.tpgi.com.au. [60.242.147.73]) by smtp.gmail.com with ESMTPSA id y66sm11176653pfb.91.2021.06.13.19.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 19:11:46 -0700 (PDT) Date: Mon, 14 Jun 2021 12:11:41 +1000 From: Nicholas Piggin Subject: Re: [PATCH v5 01/17] powerpc/powernv/vas: Release reference to tgid during window close To: Haren Myneni , herbert@gondor.apana.org.au, linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au Cc: haren@us.ibm.com, hbabu@us.ibm.com References: <4c769385e96a9b7022a4fd22938310550ceba5e1.camel@linux.ibm.com> In-Reply-To: <4c769385e96a9b7022a4fd22938310550ceba5e1.camel@linux.ibm.com> MIME-Version: 1.0 Message-Id: <1623636630.ja53s1iki0.astroid@bobo.none> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Excerpts from Haren Myneni's message of June 13, 2021 8:54 pm: >=20 > 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. >=20 > The current code is not releasing the tgid reference which can > cause pid leak and this patch fixes the issue. >=20 > Fixes: db1c08a740635 ("powerpc/vas: Take reference to PID and mm for user= space windows") > Cc: stable@vger.kernel.org # 5.8+ > Signed-off-by: Haren Myneni > Reported-by: Nicholas Piggin Reviewed-by: Nicholas Piggin Thanks, Nick > --- > arch/powerpc/platforms/powernv/vas-window.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) >=20 > diff --git a/arch/powerpc/platforms/powernv/vas-window.c b/arch/powerpc/p= latforms/powernv/vas-window.c > index 5f5fe63a3d1c..7ba0840fc3b5 100644 > --- 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 vasid, enum = vas_cop_type cop, > /* > * 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 =3D find_get_pid(task_tgid_vnr(current)); > /* > @@ -1339,8 +1339,9 @@ int vas_win_close(struct vas_window *window) > /* 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); > --=20 > 2.18.2 >=20 >=20 >=20