From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F6FFC43217 for ; Sun, 16 Oct 2022 17:53:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229774AbiJPRxG (ORCPT ); Sun, 16 Oct 2022 13:53:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229738AbiJPRxB (ORCPT ); Sun, 16 Oct 2022 13:53:01 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5AA932066 for ; Sun, 16 Oct 2022 10:52:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=MIME-Version:Content-Transfer-Encoding: Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=/QSZlP10x6sKv7h8Gtd9mwjASy+NA/rKPLXm4tqQL28=; t=1665942779; x=1667152379; b=ro9lCKsceVbmoK/R+y5zBUibyzlEswGUT+pfewgvQB3+V2j HCm1Qg9Nwc4qmFIVxSnxPui41jGXcLIqp6qIFPQsh3JOpXhB/i7OT2Znfs1lXY+A2OyayrhM7Hbpa O2PIHw534T0T7YZJBG4hISuEtDME8yLeVywGe3ZPpxt/0MJrlNuJtbaa584FwNbX9T+NfKznPGs+k pTFGfUn8zXEoAmDvMi88ePUJeaQfvN+T2om6gjEwsbo9rhxPYo5MAtLEQEjudqj0+2q3H1oFNz9Vo VXOl4odMLPswM4QC2zaK6v8fhJSswZxdiGjjojOzx76BiArXHQM12KAibNFAUYjw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1ok7of-008UHd-2S; Sun, 16 Oct 2022 19:52:49 +0200 Message-ID: Subject: Re: [PATCH] um: protect find_task_by_pid_ns() with rcu lock From: Johannes Berg To: Dawei Li , richard@nod.at, anton.ivanov@cambridgegreys.com Cc: linux-um@lists.infradead.org, linux-kernel@vger.kernel.org Date: Sun, 16 Oct 2022 19:52:48 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-malware-bazaar: not-scanned Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2022-10-16 at 23:10 +0800, Dawei Li wrote: > find_task_by_pid_ns() is safe if and only if it's under protection > from rcu read lock, implements the protection. >=20 > base-commit: 193cb8372424184dde28088a4230a5fed0afb0ad >=20 > Signed-off-by: Dawei Li > --- > arch/um/drivers/mconsole_kern.c | 3 +++ > 1 file changed, 3 insertions(+) >=20 > diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_k= ern.c > index 5026e7b9adfe..6b80e766ae80 100644 > --- a/arch/um/drivers/mconsole_kern.c > +++ b/arch/um/drivers/mconsole_kern.c > @@ -683,7 +683,10 @@ void mconsole_stack(struct mc_request *req) > return; > } > =20 > + rcu_read_lock(); > to =3D find_task_by_pid_ns(pid_requested, &init_pid_ns); > + rcu_read_unlock(); > + > if ((to =3D=3D NULL) || (pid_requested =3D=3D 0)) { > mconsole_reply(req, "Couldn't find that pid", 1, 0); > return; This can't be right - the 'to' pointer is used later in the code (not in the existing context), so the protection, if needed, would have to include the later "with_console()" call? johannes