Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3456775rwi; Sun, 16 Oct 2022 11:11:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM68ToGWeJjDnravOzdPFGNtTfBjPkOG5+4zmT/sBuvKKevJoKmRR9RRHYCEFWBP85NfB8A6 X-Received: by 2002:a17:903:244a:b0:184:586e:8864 with SMTP id l10-20020a170903244a00b00184586e8864mr8118019pls.113.1665943918806; Sun, 16 Oct 2022 11:11:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665943918; cv=none; d=google.com; s=arc-20160816; b=xVD7QHIbHFU+WItVi+hPih2GDzgaHvxkjCKINYlptShEC7R8E5Gsi/jK78ZQZ9E3U1 otMP3AiU4CPf0K7sij5jJAyLUKhnPQZtTPfkKhNc6/wOSpQZzH4MCStw1acGTEyboLaR 496VGPWhK4Z9bEyITTu+9Tgb9yaRn0m3g1bnguxCTnAuz4qmaySYvJVKrlxWw84bCnzA OSuu4aZ2iCt0hdKn+oe5jwliwIQeCY9XX+OrFLEwE0nzw9cIQFM6lllyZSG/PcpEiG/C TGcaWnOGp0jyx0i+x5TiL2WerHn7Jtsxf08qFl11mknoVM8qjI+u9X2+16HgycwZyyxk I7xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=/QSZlP10x6sKv7h8Gtd9mwjASy+NA/rKPLXm4tqQL28=; b=i7/GGNXd/xXSWnUoZ3gcr2bksX0KckFpp+z4x157oJIUV4qz9gGxTA8HusGar+tnsM WYBTgFYA8KAchq0IF3uaf8m4Jr+F1ikoR+C6z+olezvigcyXhuCZYOQ2WsLL8MaXexSH mrtYxG7BeyJEMafiFs5MZ9rS/ojVF8BfXQacDvCGqLVs+QtT1dIiipyNCkyBCl53GRDq Y6w5w9vJaFzCMLnd1lRbfKd6M5T9prFdpUFtbnbDZthysJwMj1M2p+9Qzu6jYuXnAr+o Q/8RGq6qgOckIr7FJKxEjyGpRv/swGmBoX2hm/38+CSOEZCikhKXc+xnAO/dNw3UXBwo sl6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=ro9lCKsc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j13-20020a170903024d00b0017a0530a2dbsi10622175plh.58.2022.10.16.11.11.44; Sun, 16 Oct 2022 11:11:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=ro9lCKsc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229712AbiJPRxF (ORCPT + 99 others); Sun, 16 Oct 2022 13:53:05 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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