From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 EA59434DCE4 for ; Tue, 21 Jul 2026 23:38:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784677125; cv=none; b=P6fXkaywVulrCp7IniqxjUjj5Ze0av/S4i8U9XXCOXg+yykNeh+cM9j+oo5oKiv2MtweP3lAxspf+0jL3P8scob1mqQYMSDMrCVuSj1fVosn9/MkcxrsADSbChSy0J9sSzV7PpQ3I3c6OB7rfIisZ5ERJbwuoXdYvrEpkPzXbAE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784677125; c=relaxed/simple; bh=yvGQpwXndBU6qNrL7ez2hOZCtx54UAgoUDYrfjxk4I8=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=spWNakhAhxbucHOJxpULNdXPn/aiUATZ93ph5sCdVkVKr8Fbuil2qVUJ/xaQL0YcWi+MXd9xqH42KrNUxiQv8T7z5umMjp5AjKk2hFzV0Z3ELa/Ac+Oax4X0VgaYijRSa+ptnkPFRIDStN5x/5IoKpsY2Hu/IX1rq5Ni6CJGjPQ= 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=MWjG6GmW; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="MWjG6GmW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5562E1F000E9; Tue, 21 Jul 2026 23:38:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1784677123; bh=H9ZRk1JZn0RN1gwZNafqnAfMvEHzuZyx2yCVCqP0BpE=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=MWjG6GmW+kZFYPn3CnJXCFup1qprF/dXnwfAw7PeACUTBhz1CJscmFx/vzC/+AbLd 4fiaM31o7gJxOoZ45sRVQjnxGRGWA7QZ8zuXjTG6gtlEUQINHBsTLGb9y830Jn18hW Ide8vFqFjklkFCrHMICssazYIZpwpaOfF+j4Z1tU= Date: Tue, 21 Jul 2026 16:38:42 -0700 From: Andrew Morton To: Oleg Deomi Cc: Balbir Singh , linux-kernel@vger.kernel.org Subject: Re: [BUG] taskstats: REGISTER_CPUMASK silently truncates the last byte of the cpumask string Message-Id: <20260721163842.f08e18db987a749251cfa367@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=UTF-8 Content-Transfer-Encoding: 8bit On Tue, 21 Jul 2026 15:52:33 +0300 Oleg Deomi wrote: > TASKSTATS REGISTER_CPUMASK silently drops the last byte of the cpumask > string it's given, due to a destination-buffer-sizing bug in > kernel/taskstats.c's parse(). A request for "0-31" is silently parsed as > "0-3" instead — the call still succeeds (ACK, no error), so the caller > has no way to detect that most of the CPUs it asked to cover were never > actually registered. Thanks, I queued this fix: From: Andrew Morton Subject: kernel/taskstats.c:parse(): fix buffer allocation size Date: Tue Jul 21 04:30:41 PM PDT 2026 parse() is failing to allow for the nla_strscpy()'s null termination of the cpumask string. This can result in the cpumask string being truncated. This can result in an inappropriate -EINVAL failure or in reporting for an incorrect span of CPUs. Fixes: f9fd8914c1ac ("[PATCH] per-task delay accounting taskstats interface: control exit data through cpumasks") Reported-by: Oleg Deomi Closes: https://lore.kernel.org/CAByWkfZ6b1=3H9pwkz-dDQOs9cZaF-HYQ6b9Yb0=Hq2r1Vv_Pw@mail.gmail.com Cc: Balbir Singh Cc: Signed-off-by: Andrew Morton --- kernel/taskstats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/taskstats.c~a +++ a/kernel/taskstats.c @@ -368,7 +368,7 @@ static int parse(struct nlattr *na, stru return -E2BIG; if (len < 1) return -EINVAL; - data = kmalloc(len, GFP_KERNEL); + data = kmalloc(len + 1, GFP_KERNEL); if (!data) return -ENOMEM; nla_strscpy(data, na, len); _