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 934A3286A4; Mon, 23 Mar 2026 13:56:35 +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=1774274195; cv=none; b=rPh2j5PiIh8419KuLHXHOdbXoBAoDTMylvUcZyiebql1zO72mPnS/MMn86pLjURbPFSw2dkn7LV+u8XmQdqJykLChIDfQnxxmNAoV6jJOYoTYittH/ZKVlS+O0I08gTJ5Mh5plXXOV5Se2eyum2EC5P+tyrfvMlb/Sc1u7FnViU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774274195; c=relaxed/simple; bh=MTNx+IhHZQE+94CguFQBZlKfn94c1IO3+nBlG2rn1Hg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nQnM+D/N/nF/MNf2KPPa4oC7RFoRQbu/PjdHNayc7m4iQLEnQFlCYMLvySnVQe90GM6C/EVzCiUhkXy++SejPb4G1M+Zc3+FmW91b8JY3UDh0aguuBHB2v1I7guvoGk/xB1WrdLi85XakVuqCyiA7NgKH093FRftfPqLTeDTfSg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nRtB2bQX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="nRtB2bQX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16245C4CEF7; Mon, 23 Mar 2026 13:56:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774274195; bh=MTNx+IhHZQE+94CguFQBZlKfn94c1IO3+nBlG2rn1Hg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nRtB2bQXo4rWJj7byw7FdXTITtCg+Nxx+6i0D3NwZPViFmHiyKQo4gPHfuGMv5HML s5GdZPe14TzOH2VH0ndaccT7PPblWUo8Iq6TMZoVs/sHeaa1emKKBXNF73T3wToWCr ZHOQAYibW0kyGFjc8MgECUlEIm0fxNwjMerFsxu4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Klaudia Kloc , =?UTF-8?q?Dawid=20Moczad=C5=82o?= , Jenny Guanni Qu , Florian Westphal , Sasha Levin Subject: [PATCH 6.19 140/220] netfilter: xt_time: use unsigned int for monthday bit shift Date: Mon, 23 Mar 2026 14:45:17 +0100 Message-ID: <20260323134508.989760306@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260323134504.575022936@linuxfoundation.org> References: <20260323134504.575022936@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jenny Guanni Qu [ Upstream commit 00050ec08cecfda447e1209b388086d76addda3a ] The monthday field can be up to 31, and shifting a signed integer 1 by 31 positions (1 << 31) is undefined behavior in C, as the result overflows a 32-bit signed int. Use 1U to ensure well-defined behavior for all valid monthday values. Change the weekday shift to 1U as well for consistency. Fixes: ee4411a1b1e0 ("[NETFILTER]: x_tables: add xt_time match") Reported-by: Klaudia Kloc Reported-by: Dawid MoczadĹ‚o Tested-by: Jenny Guanni Qu Signed-off-by: Jenny Guanni Qu Signed-off-by: Florian Westphal Signed-off-by: Sasha Levin --- net/netfilter/xt_time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/netfilter/xt_time.c b/net/netfilter/xt_time.c index 6aa12d0f54e23..61de85e02a40f 100644 --- a/net/netfilter/xt_time.c +++ b/net/netfilter/xt_time.c @@ -227,13 +227,13 @@ time_mt(const struct sk_buff *skb, struct xt_action_param *par) localtime_2(¤t_time, stamp); - if (!(info->weekdays_match & (1 << current_time.weekday))) + if (!(info->weekdays_match & (1U << current_time.weekday))) return false; /* Do not spend time computing monthday if all days match anyway */ if (info->monthdays_match != XT_TIME_ALL_MONTHDAYS) { localtime_3(¤t_time, stamp); - if (!(info->monthdays_match & (1 << current_time.monthday))) + if (!(info->monthdays_match & (1U << current_time.monthday))) return false; } -- 2.51.0