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 ADF2231715D; Mon, 13 Apr 2026 16:53:11 +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=1776099191; cv=none; b=rn6W48ILodkRkdSMARA2A/lk8/Etpd0lGD7BxvG8h//71HhdAxZcfP57bL14y43k0G7bPIR+uzR+F7qLtl5DPHiPytouJeXcJCKhuIfrqs5tLiLbq7oMN8putjUH+84fh7OvRW3FpmzELW9qXhzHhacF1fF9IR5XkRuIVHtPHwU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776099191; c=relaxed/simple; bh=VikyoReH9M16TZjVEXwalDfsDbi7QHKH5SfbCPiXX8s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=J4KpX57UIcxQyiY0fHD66SdT0yC1ZpoYvqn0kskTxGR8w7TWKMsU6V/QPcOoUXj84UBD1cRdX06DU9ant8jRCCZ+6lL2F0JmXSpjZZynciXCgLpc9WvIh00qD5pfsrXDpf9bD5ofKHrIb62AYri/QSh/jk/0LlClpv9F8zm8MTo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jX8tQzzp; 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="jX8tQzzp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 432A6C2BCB0; Mon, 13 Apr 2026 16:53:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776099191; bh=VikyoReH9M16TZjVEXwalDfsDbi7QHKH5SfbCPiXX8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jX8tQzzp5TR3kURfSwjm31wSkeJXl2QCZegkH7OwxXdHHpKueKs7PgJ85aXR6I3JO 8NV1DhFX6gxy57qudkz8B0cnaHJMH+M1MUY0jK32PqH+c80Xe8Y6SffXrggNsmYfX+ ikwzyTeYONtj9LfHMb0X2BjmjZlioyvGqUFNo34o= 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 5.10 212/491] netfilter: xt_time: use unsigned int for monthday bit shift Date: Mon, 13 Apr 2026 17:57:37 +0200 Message-ID: <20260413155827.004138807@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155819.042779211@linuxfoundation.org> References: <20260413155819.042779211@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 5.10-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