From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2534823AE62; Mon, 30 Mar 2026 21:29:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774906151; cv=none; b=gVSG6FcROWNCbncXzWHBV8LHB+WXd70esQli+U6Xs0kZFxIZcIvPbKTCnCX4ANVj2YsYvcEfs9VjqQNdU9z+PGqWTcve9VoSJiMXW5GwmBn+tYkcRaxXIk0Dx2pkuTVvwc+AlU3nAz4oID/rN6Zx4+8OIdHKworwcjuTt7yKT7g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774906151; c=relaxed/simple; bh=7YXvq1MsfQHE3SrFhAi3vCgluhob3a3rWMvitZkC0fM=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=Ah70nXLLJL09eem0hVxcz+6hlsZtcpHVvDUEgpBr6qLjW+uIOQyNUfcc8WdzCPIvSQMiTUulQEdI9sOe4hPMI4bcC1aUFo/gxhhZkfXKPgLFP7sWsvkYKS+OSeLvKrUhBud+WktrCeYyeSTsBGtw0UqP/CmQQ0LsBB3qCqn1u8Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=IAov1hn8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="IAov1hn8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64DEAC4CEF7; Mon, 30 Mar 2026 21:29:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1774906150; bh=7YXvq1MsfQHE3SrFhAi3vCgluhob3a3rWMvitZkC0fM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IAov1hn81U6kG0aCTcncnSjiJRArpiMQrTaBVIw8QyU9tvjmvb/+CNfXk++EXW+D2 FTG0N/F4ica+PuIMkTUCCtKPXWN0khQ49JsfEnReJMwzVjpPIuLjFU8fDL0nwG/EH5 aDWhT2cuJlF3wxpdI9I+4EveV4YxYFjkVGd+L4iY= Date: Mon, 30 Mar 2026 14:29:09 -0700 From: Andrew Morton To: Yiyang Chen Cc: Balbir Singh , linux-kernel@vger.kernel.org, Wang Yaxin , Fan Yu , "Dr . Thomas Orgis" , stable@vger.kernel.org Subject: Re: [PATCH 1/2] taskstats: set version in TGID exit notifications Message-Id: <20260330142909.3a5fe0ce22798a8cc34a8abe@linux-foundation.org> In-Reply-To: References: X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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 Content-Transfer-Encoding: 7bit On Mon, 30 Mar 2026 03:00:40 +0800 Yiyang Chen wrote: > delay accounting started populating taskstats records with a valid > version field via fill_pid() and fill_tgid(). > > Later, commit ad4ecbcba728 ("[PATCH] delay accounting taskstats > interface send tgid once") changed the TGID exit path to send the > cached signal->stats aggregate directly instead of building the outgoing > record through fill_tgid(). Unlike fill_tgid(), fill_tgid_exit() only > accumulates accounting data and never initializes stats->version. > > As a result, TGID exit notifications can reach userspace with > version == 0 even though PID exit notifications and > TASKSTATS_CMD_GET replies carry a valid taskstats version. > > Set stats->version = TASKSTATS_VERSION after copying the cached TGID > aggregate into the outgoing netlink payload so all taskstats records are > self-describing again. > > Fixes: ad4ecbcba728 ("[PATCH] delay accounting taskstats interface send tgid once") Thanks, lol, 20 years ago. Can you explain how others can trigger this? Some combination of steps which results in the bad output? > Cc: stable@vger.kernel.org Is there a chance of breaking existing userspace here? Some existing userspace code which is expecting 0 here and will get surprised by this change? > --- a/kernel/taskstats.c > +++ b/kernel/taskstats.c > @@ -649,6 +649,7 @@ void taskstats_exit(struct task_struct *tsk, int group_dead) > goto err; > > memcpy(stats, tsk->signal->stats, sizeof(*stats)); > + stats->version = TASKSTATS_VERSION; > > send: > send_cpu_listeners(rep_skb, listeners);