From patchwork Tue Mar 26 17:48:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Kiryushin X-Patchwork-Id: 13604817 Received: from relay161.nicmail.ru (relay161.nicmail.ru [91.189.117.5]) (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 824B0127B47; Tue, 26 Mar 2024 18:06:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.189.117.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711476374; cv=none; b=RYiUQigJhjcj7NmsnWtIKTuS6JHHTx0RFuKmcdxr662r2hZZZHqGAUfZfvms5CsRziIPGi9bvxVhPaBwiLaKOFcBoeGMyXoxQhvL5KugXCrGM1c8aiWobuXtyKeps4EAIu/rBQtt6X+swooqmiCG/rhiRFvoe9tdZOt36eUCLZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711476374; c=relaxed/simple; bh=1NprXnNucG4gNP4X723OkYkF5c9zIbC5pkXNXKegHoU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=fW0Lc46usJeGrA82pnOMMJw2XdRf3CS7ozCDqu2sPBCQn9rO9XYp+veHRwtr7rkcSCQiJPBLtFnV6CKP9IeR/dHtAglfNp99Qcm5xSxw3YSiRGHswqUtb0QTfLEIiOnwKVdV+QBJ3zmkeH2ASATEBMKn6rewkjom3+NlXjMFX00= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ancud.ru; spf=pass smtp.mailfrom=ancud.ru; arc=none smtp.client-ip=91.189.117.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ancud.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ancud.ru Received: from [10.28.136.255] (port=56066 helo=mitx-gfx..) by relay.hosting.mail.nic.ru with esmtp (Exim 5.55) (envelope-from ) id 1rpAuy-0000Uc-4G; Tue, 26 Mar 2024 20:49:00 +0300 Received: from [87.245.155.195] (account kiryushin@ancud.ru HELO mitx-gfx..) by incarp1105.mail.hosting.nic.ru (Exim 5.55) with id 1rpAuy-002Nej-0h; Tue, 26 Mar 2024 20:49:00 +0300 From: Nikita Kiryushin To: "Paul E. McKenney" Cc: Nikita Kiryushin , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , rcu@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] rcu-tasks: Update show_rcu_tasks_trace_gp_kthread buffer size Date: Tue, 26 Mar 2024 20:48:39 +0300 Message-Id: <20240326174839.487582-1-kiryushin@ancud.ru> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-Organization-SCL: -1 There is a possibility of buffer overflow in show_rcu_tasks_trace_gp_kthread() if counters, passed to sprintf() are huge. Counter numbers, needed for this are unrealistically high, but buffer overflow is still possible. Update used buffer size for maximum needed size for current format string. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: edf3775f0ad6 ("rcu-tasks: Add count for idle tasks on offline CPUs") Signed-off-by: Nikita Kiryushin --- kernel/rcu/tasks.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h index 147b5945d67a..13ac514489c0 100644 --- a/kernel/rcu/tasks.h +++ b/kernel/rcu/tasks.h @@ -1992,7 +1992,7 @@ static int __init rcu_spawn_tasks_trace_kthread(void) #if !defined(CONFIG_TINY_RCU) void show_rcu_tasks_trace_gp_kthread(void) { - char buf[64]; + char buf[87]; sprintf(buf, "N%lu h:%lu/%lu/%lu", data_race(n_trc_holdouts),