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=1796382759; b=wHi29O4O0XNJTSoIkrVp2T/Mr8vdOxvdFbb8GG2wglkLctQqfqmtOIXGqrVnKCOz//gD BPefltR0jhLODJUfO1JAvg1afjBYMxbqP5thZb3ThIqQH9IapPKrH8l4HT6Z4U7awx6jZ MSorFuvEx9wiMGHCPZqNJzPzxmSJRjiSMGnz/d6LRQ6nqbGBRr3skzzqy2wz/G0yoRKEC JaPr9uuZ++qzxLWysA3iOUhune2VL9VxuKNt569CS2yptzlnnLbVrgsBIGLSHNOWj9mv5 qyOoRqQoVDBfj9iXQfxb4wIBqLJfF8QTuF5B0yjdvBVN90yx0PVWAdnKih4kaAScsNA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382759; 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=sDDOXp8XPIds5F7ChL/XqjuXta7LTpn1vOUSwEvbhKo=; b=OpNXjulr12YzvuyR/+dquhIDN8Fk0LtnVaTlo32LimhOkr2yFAn8/rL8uDqy07dxlPny S/RRhV31FhdyL2W1khztL4a/5PCgdI1zg4qgtFG8EDtfOlzwUf1EAkJqkzyUQe895YmP/ EvUft5VroApDMWzgGXB9sWkkOWzWy6Y0zPpMCDx/sJ/fuCBq6HnEwEuHYXGnvoc7H9AWk 8RjfkJhsrZwkhDxvI5u7n4TQJw/LFmdLJZN8Eu78o38p0GmPZXISUkY8+AQzZVSO+v6Pl cHMR8JOpdYRxzn5j8v9ydinbeep1BPYxr+nG5oywK+FdVmPtCJNHeGGVbt6/7KVyLeA== 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=vbvNKMAJ; 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 4498D606A32F; Fri, 4 Dec 2026 11:12:39 +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=vbvNKMAJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DEF81F000C2; Fri, 4 Dec 2026 11:12:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382758; bh=sDDOXp8XPIds5F7ChL/XqjuXta7LTpn1vOUSwEvbhKo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vbvNKMAJTWPkFJqXox/X76GQTTzkeA+mSbkE+OGRWD+bAcGN/do8ODpDDyBsiyfgf iRmPNP86ZX35IsO2MVI6YNQpSbUjNc753jwdTbPeNWVlbKgcR+mvovqEXhkvYUz8Wa wdyTPyQwCJ0n2aRxciZaCfLzWsKOweAYkA10hOLQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jaewon Jung , Steven Rostedt Subject: [PATCH 6.18 591/703] tracing: Avoid undefined shifts for zero histogram map size Date: Fri, 4 Dec 2026 19:08:10 +0900 Message-ID: <20261204100643.474443177@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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 @@ -1424,6 +1424,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)