From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D65C92DF68 for ; Tue, 16 Jun 2026 00:28:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781569687; cv=none; b=iZbjOuxg9KdtzTxCTZvn50O44eSkbu7Na/edD2dhAHLBiMQpRtBY3VgkhAYrxFpnMsPmBR/a1KStbuL22toNTrr3JIGunYLCx+M3HPl5md8vErBbsZVphhWd3cl0izp99ptm2oSOlHBMcgLl7S2lHHwfeewPY+DMNnykaKNdgts= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781569687; c=relaxed/simple; bh=Fz7DRDx/ys8/9DEE57BDgxgsaZw6Dt+6ycduI4iFjS0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FMp6jbEcdi7HwqMTseIvPDggJW0qrQs8KeC33YbK7402N1iBw7SeoNqSBpbCbd+0m2iNCGIHXkatjxAFbr5vuPPc112xJvok7weTC1wkPSVlxTqhMVfj9jfED/3EDiwUGrzKgLjsTd8GzHey3Mjgg5uaHzR5J+Kqds5kycgOLOA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=J7oCtNih; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="J7oCtNih" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2c67ea316caso12305ad.1 for ; Mon, 15 Jun 2026 17:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781569684; x=1782174484; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=A2aERsjGF0PDWk2sO+FNhRojIc+YeRBYDcFVxz8BN5c=; b=J7oCtNihOlP/7QK7gbmjqj5hOTb7AJ8mzQtDyWulUp0Gfny8BSZ/NoPIA+2ho3wlR0 0vJdxSwmSKdNfgYEhZZqOauFYlxSjeQ0L5fv2cHAzJqOY8pJX3f6m1zc0tq0iUFQI/nn xE1KCQYLXAOluu1zsU/Tz6h+3+htZ84ftXQY4htNU9xCBy/VEdeYFeKBJsoEh2TsfH6r F8u0ujvWc0D4jKzEaDkbFIbYWWbkxkR0JE6tAKIO22w7I1SAhAHz78slBrqhtXAIU332 PfIQ0ssYVabEsnbO4e4gs2q4GN5vmhFnt54CC91fMOMKrnEtVQpp7XA85Dm2QlTlP42r mWKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781569684; x=1782174484; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A2aERsjGF0PDWk2sO+FNhRojIc+YeRBYDcFVxz8BN5c=; b=AnQY/663IxdbHTfGnxTrJfLgktm4tb0UyPhvZTMM7BlZ5auVQ0lR5+WWzMYCmrnF2s dKdqnXK9a6RRFHCBbRSiLilGTYQy7rQQB4YdF4J5WJwvZjh/XRACevS3+9WCSeVodytB dUA8D5Gd4XvsrgF/j00kWrhUc2t07plwY7cncPIOA+ca6e/9ZT+amiYFqN2FvHtSuQOI rOZHHVIIqPYnvL1KkTzMqvrtWzya5CK0r4pV3e/s57IKEXRpUy9G1fyAOChtNEn/WXP+ mbggfMAXNpIpEI1Xkz3q5j2OLYZ9DQvD/l3ovcpSvuwQPM+EYAiPS8SEStNSv20taccq oWpQ== X-Forwarded-Encrypted: i=1; AFNElJ+g84mO6ocMg796IMMQQ6x/OIB3yIIBy63QyySWtxXeVAvCRockgLezY915xBKqvGW7vnEDSu/+p2Zjtek=@vger.kernel.org X-Gm-Message-State: AOJu0YwH1eGF4CLQepRj75hYmWfH+FBZrrgmK+V5J0lD0Q6izU1tK2UU D8XnQ3bh8OWtMAV9w0523MQCGV1AMB057wJyWmB3yNtLD/gT4IiWsx3S5xOhLk2PQg== X-Gm-Gg: Acq92OHH4tq3tCvMjF2P6xkahBUuF+XdAGBov4fIzYG/8AXItR5fMxMk2UCTUsDG4F3 Pi9/Uf9EV1UjH5IS31PnKQlAti+6VXLDjLjIMC256EyXF8/tClEgb6ibeT1Tmr24LB8D1yUT5CH bUfjCwT9gLtPZ4sJKFjGGXGobPOw9+UNATHYeqm/3rViWfsI5opUegXjxkUXTwEnVDJAfCO55CW rBpFTjdScObd13eOkKjDARt3yIXXE/xUNr/NZfwnlKcGWWcMpYRgfViMhQA0a19fcSPjkPVKB9x Z8oPn7BDFGhIS/2y+P+5AWbj9z+aNsOL81LESphCjBiKuw3CfpIQfd8lnyXgKNp1CRR1EpmNQFp 9zACx2OtVlzSy+CrT6bJ8yKO+UR3IellXbPSJ9WGj1OJKc1XdY9kbZpOsGkcT7DBq5sSrUCfKB5 yL+GagX9nIDpBhPq7pGqOlTol+cEfP173sjx1Zb1HyLvsrL5iXyPXlpQ1938L7sTgSjkbmH4gA1 GFypNkKm+2NOYSsBp4= X-Received: by 2002:a17:902:ef02:b0:2b4:641a:6b7c with SMTP id d9443c01a7336-2c69c1d4b35mr670855ad.13.1781569683615; Mon, 15 Jun 2026 17:28:03 -0700 (PDT) Received: from google.com (25.75.145.34.bc.googleusercontent.com. [34.145.75.25]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c8663164a0fsm9890419a12.8.2026.06.15.17.28.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2026 17:28:03 -0700 (PDT) Date: Tue, 16 Jun 2026 00:27:59 +0000 From: Samiullah Khawaja To: Maoyi Xie Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Daniel Borkmann , Nikolay Aleksandrov , David Wei , Stanislav Fomichev , Dragos Tatulea , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH net] netdev-genl: report NAPI thread PID in the caller's pid namespace Message-ID: References: <20260615171736.1709318-1-maoyixie.tju@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20260615171736.1709318-1-maoyixie.tju@gmail.com> On Tue, Jun 16, 2026 at 01:17:36AM +0800, Maoyi Xie wrote: >netdev_nl_napi_fill_one() reports the NAPI kthread PID in NETDEV_A_NAPI_PID >using task_pid_nr(), which returns the PID in the initial pid namespace. > >NETDEV_CMD_NAPI_GET does not have GENL_ADMIN_PERM and the netdev genl family >is netnsok, so a caller in a child pid namespace can issue it. That caller >then sees the kthread's global PID, even though the kthread is not visible >in its pid namespace, where the value should be 0. > >Translate the PID through the caller's pid namespace, the same way commit >3799c2570982 ("io_uring/fdinfo: translate SqThread PID through caller's >pid_ns") did for the io_uring SQPOLL thread. The doit and dumpit paths both >run synchronously in the caller's context, so task_active_pid_ns(current) is >the caller's pid namespace. > >Fixes: db4704f4e4df ("netdev-genl: Add PID for the NAPI thread") >Cc: stable@vger.kernel.org >Signed-off-by: Maoyi Xie >--- > net/core/netdev-genl.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > >diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c >index b8f6076d8007..4c23e985cc01 100644 >--- a/net/core/netdev-genl.c >+++ b/net/core/netdev-genl.c >@@ -2,6 +2,7 @@ > > #include > #include >+#include > #include > #include > #include >@@ -189,7 +190,8 @@ netdev_nl_napi_fill_one(struct sk_buff *rsp, struct napi_struct *napi, > goto nla_put_failure; > > if (napi->thread) { >- pid = task_pid_nr(napi->thread); >+ pid = task_pid_nr_ns(napi->thread, >+ task_active_pid_ns(current)); > if (nla_put_u32(rsp, NETDEV_A_NAPI_PID, pid)) > goto nla_put_failure; > } >-- >2.43.0 > Reviewed-by: Samiullah Khawaja