mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Balbir Singh <balbirs@nvidia.com>
To: Yiyang Chen <cyyzero16@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Dr . Thomas Orgis" <thomas.orgis@uni-hamburg.de>
Subject: Re: [PATCH 1/2] taskstats: return -EBADF when cgroupstats receives an invalid fd
Date: Mon, 27 Jul 2026 10:40:38 +1000	[thread overview]
Message-ID: <03a98114-ed40-419f-a2c4-11e042c74c26@nvidia.com> (raw)
In-Reply-To: <b4fd9e288e4a48efebaf41b4ffcdb204b06675c4.1783713230.git.cyyzero16@gmail.com>

On 7/11/26 6:07 AM, Yiyang Chen wrote:
> cgroupstats_user_cmd() returns 0 without sending a reply or a netlink
> error when the fd passed via CGROUPSTATS_CMD_ATTR_FD does not resolve
> to an open file in the caller's table.  As a result:
> 
> - clients that did not set NLM_F_ACK block on recv() indefinitely
> waiting for a CGROUPSTATS_CMD_NEW message that is never emitted;
> - clients that set NLM_F_ACK receive a misleading "success" ACK
> (errno == 0) with no statistics payload.
> 
> Return -EBADF instead so the netlink layer propagates the error to
> userspace as expected.
> 
> Signed-off-by: Yiyang Chen <cyyzero16@gmail.com>
> ---
>  kernel/taskstats.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/taskstats.c b/kernel/taskstats.c
> index 2cd0172d0516..8d115670a3ca 100644
> --- a/kernel/taskstats.c
> +++ b/kernel/taskstats.c
> @@ -423,7 +423,7 @@ static int cgroupstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
>  	fd = nla_get_u32(info->attrs[CGROUPSTATS_CMD_ATTR_FD]);
>  	CLASS(fd, f)(fd);
>  	if (fd_empty(f))
> -		return 0;
> +		return -EBADF;
>  
>  	size = nla_total_size(sizeof(struct cgroupstats));
>  

Thanks!

Acked-by: Balbir Singh <balbirs@nvidia.com>

  reply	other threads:[~2026-07-27  0:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10 20:07 [PATCH 0/2] taskstats: fix cgroupstats invalid fd handling and add selftests Yiyang Chen
2026-07-10 20:07 ` [PATCH 1/2] taskstats: return -EBADF when cgroupstats receives an invalid fd Yiyang Chen
2026-07-27  0:40   ` Balbir Singh [this message]
2026-07-10 20:07 ` [PATCH 2/2] selftests/acct: add cgroupstats functional test Yiyang Chen
2026-07-10 22:59 ` [PATCH 0/2] taskstats: fix cgroupstats invalid fd handling and add selftests Andrew Morton
2026-07-11  4:44   ` Yiyang Chen
2026-07-24 22:51 ` Bradley Morgan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=03a98114-ed40-419f-a2c4-11e042c74c26@nvidia.com \
    --to=balbirs@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=cyyzero16@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thomas.orgis@uni-hamburg.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®