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 A629B2737EE; Mon, 23 Mar 2026 15:20:34 +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=1774279234; cv=none; b=DKLK3jGLnFZwOhRmQHbBGLbXr0JwEHcLlrJ1VMIV4awUQZ5/AXTuMhgJLYvrGn0Uragl2riCyaACJqMC/rZXAKOe8rbch3C8zsLpAD6P4DfmozEB1rUSJ1VmLrkAo1ogpRZiqCikhQmQec0uKCVBKIvPBh7l5Klm55SiFG9/zig= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774279234; c=relaxed/simple; bh=IpLL1lgIX1uaXgiO+T1n78BGU/BG5z8RCraXRI2ySCY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Fj/dFC9znAfAoE87/OocH6sKdgXacc+l/xBGy/bW+h0J41JzIYMfQNF+ywqWsm7OI6soUb0Mm7jljEyQ6z42g6psMV454aJKbZ2lwjplEQnm0G7TRPk1U865i64qkq5rmjOsY9Gm+KXaL5Y+Tn7U5b2FtWXnGJd0y8UqaHci+nI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NdSsYYAO; 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="NdSsYYAO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A209C4CEF7; Mon, 23 Mar 2026 15:20:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774279234; bh=IpLL1lgIX1uaXgiO+T1n78BGU/BG5z8RCraXRI2ySCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NdSsYYAOyQG3VnRo5DSQuK41MgkwIV+afjwdCNqHBLPFBa1+48vTR60NoM7rPjFjh cygMtwc3RpFQBNHXlhY5Hf1fZBNdKwY5+kxeC7r2eYprIa46MllCXdkMzS5JnYsvJz 86PND1JM76m2GWe+ep/s+4T9buN0vjNgSSMtoekM= 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.6 520/567] netfilter: xt_time: use unsigned int for monthday bit shift Date: Mon, 23 Mar 2026 14:47:20 +0100 Message-ID: <20260323134546.875328945@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260323134533.749096647@linuxfoundation.org> References: <20260323134533.749096647@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-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