From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384229; b=pgqV9kUKV97E3v/nF6Velt0JJdOrOx5xT5LKQXUAnQT53ujHkIR5PjggT++JrXrK2alq HKkTzIchLRdmqAAOLKV7SIpoqcwPto2q6kssm055kiapPxOU0LA/338Qoy6l+qB5dAjdk MYvPjXbB3XB9ooyKfrcg44xnarDlZdQgjThjJNpXSqxb70ApZMaTCBOqf1gBQqt4l8BRH QvK+DG48TU/42LuaPWV2EPHl03mbLg7vcdcfB5G51It3MrogcxL9EPGafiQ54LywJwYzM P9fLfF+hHesz/Ocn0WQPehoImhuJKOSTLTxZjAEvyioqBt8xXUeezy0c0HW+25kWkqQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384229; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=xPJxQDN3MmTyJRLDYibz0vLiJuc92CS3fKVJvAUrVKc=; b=26HXqxFl6iWZ9aA9EyD8SwwhIxUYdMwMzafG84G7Gn+Efj4pZxizObolrocbdPBwTJgi N+10CwGugDxhjVDz226KI2zszB7EhafNO+5UdRp0dNtsVyFIfe3FImZPa4FQ3098suv8D UMASXgyjsFEFNuuEfhoG5dLubUmuadNmAAQlNZ6/Km2wzAa3OqbNfT/9uH98LbwGfPJvo 7uj4jF0L/RLPeegzJ7qlTaA6PDExuGAA7KqqrRUzyUfO6f0zbjdZcatLjTqhMIXDlyYVq 7l/5yhrriCg8te8vZsL6FtZ3Vb1X5MmL85k8Y21kz39F2QyCK6pvP/gZ7weA40NHurg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=jHkoOpGL; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A3C5606A322; Fri, 4 Dec 2026 11:37:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=jHkoOpGL Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AEB11F000CE; Fri, 4 Dec 2026 11:37:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384228; bh=xPJxQDN3MmTyJRLDYibz0vLiJuc92CS3fKVJvAUrVKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jHkoOpGL/4Gq2H0rn8pyzHFn2hz7DAqp2LSS3MUd35UTZuYLQFbJqlDGm7ll6fLbd Lo8n2+sOMhopquR9qtS3BC3qthEx7rt2ZZSMoa6ajhQylKgPawdzHiUzNBh7l0ykCJ /Ze4OibKhHY2Q3baHj89yN9TH5zNjKBYGRQny4yY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jaewon Jung , Steven Rostedt Subject: [PATCH 6.12 500/555] tracing: Avoid undefined shifts for zero histogram map size Date: Fri, 4 Dec 2026 19:09:03 +0900 Message-ID: <20261204100628.002323384@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jaewon Jung commit cae7fb0d853eff05c70b08ef9e7ecb18867f8945 upstream. Reject size=0 before calling roundup_pow_of_two(). include/linux/log2.h documents roundup_pow_of_two() as: - the result is undefined when n == 0 With CONFIG_UBSAN_SHIFT=y, a size=0 histogram trigger reports: UBSAN: shift-out-of-bounds in include/linux/log2.h shift exponent 64 is too large for 64-bit type 'long unsigned int' Tested on x86_64 QEMU: size=0 is rejected without UBSAN warnings, and the histogram modifier and parser tests pass. Fixes: 7ef224d1d0e3 ("tracing: Add 'hist' event trigger command") Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261028074610.2212374-1-jaewon8868@gmail.com Signed-off-by: Jaewon Jung Signed-off-by: Steven Rostedt Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_events_hist.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -1414,6 +1414,11 @@ static int parse_map_size(char *str) if (ret) goto out; + if (!size) { + ret = -EINVAL; + goto out; + } + map_bits = ilog2(roundup_pow_of_two(size)); if (map_bits < TRACING_MAP_BITS_MIN || map_bits > TRACING_MAP_BITS_MAX)