From nobody Sun Jun 14 17:35:56 2026 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74C79239E7E for ; Fri, 3 Apr 2026 20:59:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775249956; cv=none; b=GlaShgE/CYF8e+Nn7fYaUhG3JpNlnIWFF4sNJbt8QFt6dS9TIiJ89dTLUw42Mkvl/M5rgBblSccSOMNS0IGyN6RjkKGEn4TciDRic6ncHHQHnXZYiyCNoiqi+wUXgbr6UGnEoQvQXk5l00Pf2E8mgSUU8UlF8Ag/DqnWUSVV6vw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775249956; c=relaxed/simple; bh=kqYs482WFY46q7KpNwPM4K3CeK+5fOx+6sZ6nE4D9Rc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=NfiF1L3hmA0ZLekT2k3RDE5qhL1r4kPzYv9S9/pay2nU5Rj5Zq1nr9iJE96w0kbqleCigqg8kHLdmoPq4RIutZv2rv4GI1hQBU7c/1sWtBVi13SWmUR4w0WoV43acGdrXUC8WBKxswQut20aPStsmrYC40fZ7fUq8yy98iTGJak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dBE4CG55; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dBE4CG55" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-486fe36cfabso20799675e9.1 for ; Fri, 03 Apr 2026 13:59:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775249952; x=1775854752; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=PC6QSIaCKHRw04W5RZeL/4jeRdbgtJ8aXjIrqAGfS2c=; b=dBE4CG55oJU4skkB0N1F6ZGedSw9a0i0B5D6KUGu0YFmN3X0zxdmmerqUp8UFMWMpo d0kExpCFgbmRzYlYvmbM70tM/HUAhlYHPDHKiLA80bH5/Z18zK1hiAKaZG++E49wtleD k63gW05g8SdtedyJYkzuRlkzyaQHvHayeJl9tSeReu3Zk1ezWtV1CdfUq/VnNZsy2xM3 j0JOhhbvNmwW2YCiCqSGLneD/Fz+JPNpE6tzR395C+pjHfik3ICkH3Up0ypSVck+Qcrt eraGrCez0eaFQv4mjTXtWhbBN8L65IXkNY38kQc2GNY92AJQM62V2Dwkp8y8fEoqKxdC CkQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775249952; x=1775854752; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=PC6QSIaCKHRw04W5RZeL/4jeRdbgtJ8aXjIrqAGfS2c=; b=V0qeEb0b1O/sEt5W5H+sQPDDX6++hAqBqNoNlagSw5HRtGixtQF6RKHosfZse3S6h4 37QsDx4aYAmGgGiKzUlrEknDObIBVXNTaYPb+9FndRoRRUhVKBoOK8cVrWPQOU5id3im VUCDRkC97BU2cLaTbtMAiRu7+WTuJO1TSb6U8s9UDnpZPo9zyNzOIcbEafIgoNOuogNH gBarx2u+a5CiXKstcG1smPWd5KkTd4sFa5DtgYLDIZqSZgoYH1NsZwXUsMTJSxJjDQZY KLBMh6CaE111IUDoRIBK++7bGAq7bAL9lvWHgAx8D+/5O0V5CZgy7FcwQhxW4mcu4ZwD YV1g== X-Forwarded-Encrypted: i=1; AJvYcCWSxFTznyd+hL2W62MAI7n1CixMNXUstDPAb7Di3jorTOUs2qjXajnbZYjgy1DU0noW+gZ99vy1SRUhVMY=@vger.kernel.org X-Gm-Message-State: AOJu0YyKn9fp9yZg4HXgdR9GIiduVdL5l9d9bFq+mPVRoiG6lS/Jlply fQU47wp4O9LX+yFt3zZrCETn7YPJ8teCzT7Rd2Cc5a2sj96Z5NScKUkM X-Gm-Gg: ATEYQzyNN42QF5Wv0780cFW2Mj2bI2zJH9lrQ+E2p9vxdrlqlJ5BhsQNnlvJqy2ys8h fKZMRXjc6xQitwehw/fojPEYQmXrSch2o7ZtVMFoVrgdZIHMngrIXjZjyFFAL3jluH485PLtBQV BOO9+QP6ThohkCwXxvoqFsHXMe16w/H4J2SbhSIAqHEmHLcQgBCeKAUylp2gpXAtaA2rGr1RduP n82+2q7nu4I3QCe8WT09L/0jGAE1Kus3zRMd8SGSWiPNKJfQ2/BvVEcqZ59IkaabxPVGzydNr4f gsMfVz1uai4CniKqR/HJVuEMB+Lt1MuxsIoFcr9++fQbQObUwYhkrr1ddhBwA3ypyLiAxC1BEbn KUBCXlWxvqBbcGF1w2x7ZwWLYIgFcivASsOE7O035Z8sD/CM0T8kc8/DcDH/Wur8HfSPz4+Iq9U mFROdIR5lT88PSoBnxc/FwagudSfDINkcKgOF99GizzTYcgvOfNYD2VFS9daNLuV65Y7HMtm+Ak ZhpOHXNp+EIQvHA/Xiq6J0rPuEdO+dD18exoryxa56eqA2ChzI= X-Received: by 2002:a05:600c:450d:b0:485:3428:774c with SMTP id 5b1f17b1804b1-4889946a42dmr64393995e9.4.1775249951503; Fri, 03 Apr 2026 13:59:11 -0700 (PDT) Received: from localhost.localdomain (cpe-188-129-81-72.dynamic.amis.hr. [188.129.81.72]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48893f39027sm104356165e9.2.2026.04.03.13.59.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 03 Apr 2026 13:59:11 -0700 (PDT) From: Marino Dzalto To: pablo@netfilter.org, fw@strlen.de Cc: jacob.e.keller@intel.com, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Marino Dzalto Subject: [PATCH v3] netfilter: xt_HL: add pr_fmt and checkentry validation Date: Fri, 3 Apr 2026 22:59:07 +0200 Message-ID: <20260403205907.92749-1-marino.dzalto@gmail.com> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add pr_fmt to prefix log messages with the module name for easier debugging in dmesg. Add checkentry functions for IPv4 (ttl_mt_check) and IPv6 (hl_mt6_check) to validate the match mode at rule registration time, rejecting invalid modes with -EINVAL. Signed-off-by: Marino Dzalto --- v3: Remove mention of NULL checks from commit message, as they were never part of the original code. v2: Remove NULL checks for skb as suggested by Florian Westphal (skb is guaranteed non-NULL by netfilter core). Move mode validation to checkentry functions instead of match function, also as suggested by Florian Westphal. --- net/netfilter/xt_hl.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/net/netfilter/xt_hl.c b/net/netfilter/xt_hl.c index c1a70f8f0441..4a12a757ecbf 100644 --- a/net/netfilter/xt_hl.c +++ b/net/netfilter/xt_hl.c @@ -6,6 +6,7 @@ * Hop Limit matching module * (C) 2001-2002 Maciej Soltysiak */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt =20 #include #include @@ -22,6 +23,18 @@ MODULE_LICENSE("GPL"); MODULE_ALIAS("ipt_ttl"); MODULE_ALIAS("ip6t_hl"); =20 +static int ttl_mt_check(const struct xt_mtchk_param *par) +{ + const struct ipt_ttl_info *info =3D par->matchinfo; + + if (info->mode > IPT_TTL_GT) { + pr_err("Unknown TTL match mode: %d\n", info->mode); + return -EINVAL; + } + + return 0; +} + static bool ttl_mt(const struct sk_buff *skb, struct xt_action_param *par) { const struct ipt_ttl_info *info =3D par->matchinfo; @@ -41,6 +54,18 @@ static bool ttl_mt(const struct sk_buff *skb, struct xt_= action_param *par) return false; } =20 +static int hl_mt6_check(const struct xt_mtchk_param *par) +{ + const struct ip6t_hl_info *info =3D par->matchinfo; + + if (info->mode > IP6T_HL_GT) { + pr_err("Unknown Hop Limit match mode: %d\n", info->mode); + return -EINVAL; + } + + return 0; +} + static bool hl_mt6(const struct sk_buff *skb, struct xt_action_param *par) { const struct ip6t_hl_info *info =3D par->matchinfo; @@ -65,6 +90,7 @@ static struct xt_match hl_mt_reg[] __read_mostly =3D { .name =3D "ttl", .revision =3D 0, .family =3D NFPROTO_IPV4, + .checkentry =3D ttl_mt_check, .match =3D ttl_mt, .matchsize =3D sizeof(struct ipt_ttl_info), .me =3D THIS_MODULE, @@ -73,6 +99,7 @@ static struct xt_match hl_mt_reg[] __read_mostly =3D { .name =3D "hl", .revision =3D 0, .family =3D NFPROTO_IPV6, + .checkentry =3D hl_mt6_check, .match =3D hl_mt6, .matchsize =3D sizeof(struct ip6t_hl_info), .me =3D THIS_MODULE, --=20 2.50.1 (Apple Git-155)