From 88590b3b5c587ea5ef436d7218d64f8523511290 Mon Sep 17 00:00:00 2001 From: suyuan <175338101@qq.com> Date: Wed, 5 Jul 2023 16:07:43 +0800 Subject: [PATCH] fix --- xtables-addons/Makefile | 14 +- .../001-fix-kernel-version-detection.patch | 4 +- .../patches/100-add-rtsp-conntrack.patch | 4 +- .../patches/200-add-lua-packetscript.patch | 56 ++-- .../patches/201-fix-lua-packetscript.patch | 11 + ...-packetscript-kernel-5.16-no-isystem.patch | 284 ------------------ 6 files changed, 55 insertions(+), 318 deletions(-) delete mode 100644 xtables-addons/patches/202-fix-lua-packetscript-kernel-5.16-no-isystem.patch diff --git a/xtables-addons/Makefile b/xtables-addons/Makefile index cba09357d..cb678ac9c 100644 --- a/xtables-addons/Makefile +++ b/xtables-addons/Makefile @@ -1,26 +1,26 @@ +# SPDX-License-Identifier: GPL-2.0-only # # Copyright (C) 2009-2013 OpenWrt.org # -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=xtables-addons -PKG_VERSION:=3.22 -PKG_RELEASE:=$(AUTORELEASE) -PKG_HASH:=faa16a27166275afbfe8df605f55c3a81ac693bf19da674d45ceded4137ae217 +PKG_VERSION:=3.24 +PKG_RELEASE:=1 +PKG_HASH:=3e823f71720519ced31c4c7d2bfaf7120d9c01c59a0843dfcbe93c95c64d81c1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=https://inai.de/files/xtables-addons/ PKG_BUILD_DEPENDS:=iptables + PKG_INSTALL:=1 PKG_BUILD_PARALLEL:=1 PKG_MAINTAINER:=Jo-Philipp Wich PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:=COPYING PKG_FIXUP:=autoreconf PKG_ASLR_PIE:=0 @@ -162,7 +162,7 @@ define Package/iptgeoip/install $(1)/usr/lib/xtables-addons/ $(INSTALL_DIR) $(1)/usr/bin $(CP) \ - $(PKG_INSTALL_DIR)/usr/bin/xt_geoip_fetch \ + $(PKG_INSTALL_DIR)/usr/bin/xt_geoip_query \ $(1)/usr/bin/ $(INSTALL_DIR) $(1)/usr/share/xt_geoip touch $(1)/usr/share/xt_geoip/.keep diff --git a/xtables-addons/patches/001-fix-kernel-version-detection.patch b/xtables-addons/patches/001-fix-kernel-version-detection.patch index 775ccf657..e29b3925c 100644 --- a/xtables-addons/patches/001-fix-kernel-version-detection.patch +++ b/xtables-addons/patches/001-fix-kernel-version-detection.patch @@ -1,8 +1,8 @@ --- a/configure.ac +++ b/configure.ac -@@ -44,7 +44,7 @@ regular_CFLAGS="-Wall -Waggregate-return +@@ -41,7 +41,7 @@ regular_CFLAGS="-Wall -Waggregate-return - if test -n "$kbuilddir"; then + AS_IF([test -n "$kbuilddir"], [ AC_MSG_CHECKING([kernel version that we will build against]) - krel="$(make -sC "$kbuilddir" M=$PWD kernelrelease | $AWK -v 'FS=[[^0-9.]]' '{print $1; exit}')" + krel="$(make -sC "$kbuilddir" M=$PWD kernelversion | $AWK -v 'FS=[[^0-9.]]' '{print $1; exit}')" diff --git a/xtables-addons/patches/100-add-rtsp-conntrack.patch b/xtables-addons/patches/100-add-rtsp-conntrack.patch index dbdc52e94..befcd06a3 100644 --- a/xtables-addons/patches/100-add-rtsp-conntrack.patch +++ b/xtables-addons/patches/100-add-rtsp-conntrack.patch @@ -1725,7 +1725,7 @@ +module_exit(fini); --- a/extensions/Kbuild +++ b/extensions/Kbuild -@@ -27,6 +27,7 @@ obj-${build_lscan} += xt_lscan.o +@@ -28,6 +28,7 @@ obj-${build_lscan} += xt_lscan.o obj-${build_pknock} += pknock/ obj-${build_psd} += xt_psd.o obj-${build_quota2} += xt_quota2.o @@ -1735,7 +1735,7 @@ -include ${M}/Kbuild.* --- a/mconfig +++ b/mconfig -@@ -23,3 +23,4 @@ build_lscan=m +@@ -24,3 +24,4 @@ build_lscan=m build_pknock=m build_psd=m build_quota2=m diff --git a/xtables-addons/patches/200-add-lua-packetscript.patch b/xtables-addons/patches/200-add-lua-packetscript.patch index 8dd926712..2a97f54d7 100644 --- a/xtables-addons/patches/200-add-lua-packetscript.patch +++ b/xtables-addons/patches/200-add-lua-packetscript.patch @@ -1,6 +1,6 @@ --- /dev/null +++ b/extensions/LUA/byte_array.c -@@ -0,0 +1,145 @@ +@@ -0,0 +1,161 @@ +/* + * Copyright (C) 2010 University of Basel + * by Andre Graf @@ -110,12 +110,26 @@ +static int32_t byte_array_to_string(lua_State *L) +{ + lua_packet_segment * array = checkbytearray(L, 1); -+ uint8_t buf[(array->length * 3) + 255]; + uint8_t hexval[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; -+ char res[255 + (array->length * 3)]; /* make sure the buffer is big enough*/ ++ uint8_t * buf; ++ char * res; + int32_t i, n; + uint8_t *ptr = array->start + array->offset; + ++ buf = kcalloc((array->length * 3) + 255, sizeof(*buf), GFP_KERNEL); ++ ++ if (!buf) { ++ return luaL_error(L, "byte_array_to_string, failed alloc buf buffer"); ++ } ++ ++ /* make sure the buffer is big enough*/ ++ res = kcalloc((array->length * 3) + 255, sizeof(*res), GFP_KERNEL); ++ ++ if (!res) { ++ kfree(buf); ++ return luaL_error(L, "byte_array_to_string, failed alloc res buffer"); ++ } ++ + for (i = 0; i < array->length; i++) { + buf[i * 3] = hexval[(ptr[i] >> 4) & 0xF]; + buf[(i * 3) + 1] = hexval[ptr[i] & 0x0F]; @@ -126,6 +140,8 @@ + n = sprintf(res, "byte_array: length: %d value: %s", array->length, buf); + + lua_pushlstring(L, res, n); ++ kfree(res); ++ kfree(buf); + + return 1; +} @@ -1137,7 +1153,7 @@ + struct xt_lua_tginfo *info = (void *)target->data; + + info->state_id = 0; -+ strncpy(info->function, "process_packet\0", sizeof("process_packet\0")); ++ strcpy(info->function, "process_packet\0"); +} + +static int @@ -2453,15 +2469,13 @@ +#endif --- /dev/null +++ b/extensions/LUA/lua/lauxlib.c -@@ -0,0 +1,674 @@ +@@ -0,0 +1,672 @@ +/* +** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + -+#include -+ +#if !defined(__KERNEL__) +#include +#include @@ -4887,7 +4901,7 @@ +#endif --- /dev/null +++ b/extensions/LUA/lua/ldebug.c -@@ -0,0 +1,637 @@ +@@ -0,0 +1,636 @@ +/* +** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $ +** Debug Interface @@ -4895,7 +4909,6 @@ +*/ + + -+#include +#include +#include + @@ -5301,7 +5314,7 @@ + case OP_FORLOOP: + case OP_FORPREP: + checkreg(pt, a+3); -+ /* go through */ ++ fallthrough; + case OP_JMP: { + int dest = pc+1+b; + /* not full check and jump is forward and do not skip `lastpc'? */ @@ -6204,7 +6217,7 @@ + +static void DumpString(const TString* s, DumpState* D) +{ -+ if (s==NULL || getstr(s)==NULL) ++ if (s==NULL) + { + size_t size=0; + DumpVar(size,D); @@ -7716,6 +7729,7 @@ + } + else if (sep == -1) return '['; + else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING); ++ fallthrough; + } + case '=': { + next(ls); @@ -7809,7 +7823,6 @@ + lua_assert(ls->lookahead.token == TK_EOS); + ls->lookahead.token = llex(ls, &ls->lookahead.seminfo); +} -+ --- /dev/null +++ b/extensions/LUA/lua/llex.h @@ -0,0 +1,81 @@ @@ -8165,15 +8178,13 @@ + --- /dev/null +++ b/extensions/LUA/lua/lobject.c -@@ -0,0 +1,215 @@ +@@ -0,0 +1,213 @@ +/* +** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $ +** Some generic functions over Lua objects +** See Copyright Notice in lua.h +*/ + -+#include -+ +#include +#include +#include @@ -12471,7 +12482,7 @@ + lua_number2int(k, n); + if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */ + return luaH_getnum(t, k); /* use specialized version */ -+ /* else go through */ ++ fallthrough; + } + default: { + Node *n = mainposition(t, key); @@ -12766,7 +12777,7 @@ + if (!lua_isstring(L, -1)) + luaL_error(L, "invalid value (%s) at index %d in table for " + LUA_QL("concat"), luaL_typename(L, -1), i); -+ luaL_addvalue(b); ++ luaL_addvalue(b); +} + + @@ -13851,7 +13862,7 @@ + --- /dev/null +++ b/extensions/LUA/lua/lua.h -@@ -0,0 +1,387 @@ +@@ -0,0 +1,386 @@ +/* +** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ +** Lua - An Extensible Extension Language @@ -13863,7 +13874,6 @@ +#ifndef lua_h +#define lua_h + -+#include +#include + +#include "luaconf.h" @@ -17984,7 +17994,7 @@ + int32_t ret; + struct lua_env * env = kmalloc(sizeof(struct lua_env), GFP_KERNEL); + -+ if (!script_size > 0) { ++ if (!script_size) { + pr_debug("LUA [%d]: script_size %lu < 0\n", state_id, script_size); + return false; + } @@ -18134,7 +18144,7 @@ + --- a/extensions/Kbuild +++ b/extensions/Kbuild -@@ -28,6 +28,7 @@ obj-${build_pknock} += pknock/ +@@ -29,6 +29,7 @@ obj-${build_pknock} += pknock/ obj-${build_psd} += xt_psd.o obj-${build_quota2} += xt_quota2.o obj-${build_rtsp} += rtsp/ @@ -18144,14 +18154,14 @@ -include ${M}/Kbuild.* --- a/extensions/Mbuild +++ b/extensions/Mbuild -@@ -23,3 +23,4 @@ obj-${build_pknock} += pknock/ +@@ -24,3 +24,4 @@ obj-${build_pknock} += pknock/ obj-${build_psd} += libxt_psd.so obj-${build_quota2} += libxt_quota2.so obj-${build_gradm} += libxt_gradm.so +obj-${build_LUA} += LUA/ --- a/mconfig +++ b/mconfig -@@ -24,3 +24,4 @@ build_pknock=m +@@ -25,3 +25,4 @@ build_pknock=m build_psd=m build_quota2=m build_rtsp=m diff --git a/xtables-addons/patches/201-fix-lua-packetscript.patch b/xtables-addons/patches/201-fix-lua-packetscript.patch index 5a016e2ae..64130121c 100644 --- a/xtables-addons/patches/201-fix-lua-packetscript.patch +++ b/xtables-addons/patches/201-fix-lua-packetscript.patch @@ -1,3 +1,14 @@ +--- a/extensions/LUA/Kbuild ++++ b/extensions/LUA/Kbuild +@@ -22,6 +22,8 @@ xt_LUA-y += nf_lua.o \ + prot_buf_dynamic.o \ + + ++# Enable ++EXTRA_CFLAGS += -isystem $(shell $(CC) -print-file-name=include) + # Adding Lua Support + EXTRA_CFLAGS += -I$(src)/lua -I$(src)/lua/include + xt_LUA-y += lua/lapi.o \ --- a/extensions/LUA/xt_LUA_target.c +++ b/extensions/LUA/xt_LUA_target.c @@ -19,7 +19,7 @@ diff --git a/xtables-addons/patches/202-fix-lua-packetscript-kernel-5.16-no-isystem.patch b/xtables-addons/patches/202-fix-lua-packetscript-kernel-5.16-no-isystem.patch deleted file mode 100644 index 5279619da..000000000 --- a/xtables-addons/patches/202-fix-lua-packetscript-kernel-5.16-no-isystem.patch +++ /dev/null @@ -1,284 +0,0 @@ -Linux 5.16 includes 04e85bbf71c9 ("isystem: delete global -isystem compile option") - -compile error on >=5.16 -xtables-addons-3.21/extensions/LUA/lua/lua.h:12:10: fatal error: stdarg.h: No such file or directory - 12 | #include - | ^~~~~~~~~~ - -Generated with coccinelle: - -cat <cocci-xtables-lua-linux-5.16.spatch -@include_arg@ -@@ - #include - -@include_def@ -@@ - #include - -@include_both depends on include_arg && include_def@ -@@ - #include - -@add_include_linux_stdheaders_both depends on include_both@ -@@ -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) -?#include -?#include -+#else -+#include -+#include -+#endif - -@add_include_linux_stdheaders depends on !include_both@ -@@ -( -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - #include -+#else -+#include -+#endif -| -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - #include -+#else -+#include -+#endif -) -EOF -spatch --in-place --include-headers --no-includes --sp-file cocci-xtables-lua-linux-5.16.spatch --dir extensions/LUA/lua/ - ---- - ---- a/extensions/LUA/lua/lauxlib.c -+++ b/extensions/LUA/lua/lauxlib.c -@@ -4,7 +4,12 @@ - ** See Copyright Notice in lua.h - */ - -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - #include -+#else -+#include -+#endif - - #if !defined(__KERNEL__) - #include ---- a/extensions/LUA/lua/lauxlib.h -+++ b/extensions/LUA/lua/lauxlib.h -@@ -9,7 +9,12 @@ - #define lauxlib_h - - -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - #include -+#else -+#include -+#endif - #include /* for kmalloc and kfree when allocating luaL_Buffer */ - - #if !defined(__KERNEL__) ---- a/extensions/LUA/lua/ldebug.c -+++ b/extensions/LUA/lua/ldebug.c -@@ -5,8 +5,14 @@ - */ - - -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - #include - #include -+#else -+#include -+#include -+#endif - #include - - #define ldebug_c ---- a/extensions/LUA/lua/ldump.c -+++ b/extensions/LUA/lua/ldump.c -@@ -4,7 +4,12 @@ - ** See Copyright Notice in lua.h - */ - -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - #include -+#else -+#include -+#endif - - #define ldump_c - #define LUA_CORE ---- a/extensions/LUA/lua/lfunc.c -+++ b/extensions/LUA/lua/lfunc.c -@@ -5,7 +5,12 @@ - */ - - -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - #include -+#else -+#include -+#endif - - #define lfunc_c - #define LUA_CORE ---- a/extensions/LUA/lua/llimits.h -+++ b/extensions/LUA/lua/llimits.h -@@ -7,7 +7,12 @@ - #ifndef llimits_h - #define llimits_h - -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - #include -+#else -+#include -+#endif - - #include "lua.h" - ---- a/extensions/LUA/lua/lmem.c -+++ b/extensions/LUA/lua/lmem.c -@@ -5,7 +5,12 @@ - */ - - -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - #include -+#else -+#include -+#endif - - #define lmem_c - #define LUA_CORE ---- a/extensions/LUA/lua/lmem.h -+++ b/extensions/LUA/lua/lmem.h -@@ -8,7 +8,12 @@ - #define lmem_h - - -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - #include -+#else -+#include -+#endif - - #include "llimits.h" - #include "lua.h" ---- a/extensions/LUA/lua/lobject.c -+++ b/extensions/LUA/lua/lobject.c -@@ -4,7 +4,12 @@ - ** See Copyright Notice in lua.h - */ - -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - #include -+#else -+#include -+#endif - - #include - #include ---- a/extensions/LUA/lua/lobject.h -+++ b/extensions/LUA/lua/lobject.h -@@ -9,7 +9,12 @@ - #define lobject_h - - -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - #include -+#else -+#include -+#endif - - - #include "llimits.h" ---- a/extensions/LUA/lua/lstate.c -+++ b/extensions/LUA/lua/lstate.c -@@ -5,7 +5,12 @@ - */ - - -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - #include -+#else -+#include -+#endif - - #define lstate_c - #define LUA_CORE ---- a/extensions/LUA/lua/lstrlib.c -+++ b/extensions/LUA/lua/lstrlib.c -@@ -6,7 +6,12 @@ - - - #include -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - #include -+#else -+#include -+#endif - #include - #include - #include ---- a/extensions/LUA/lua/ltablib.c -+++ b/extensions/LUA/lua/ltablib.c -@@ -5,7 +5,12 @@ - */ - - -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - #include -+#else -+#include -+#endif - - #define ltablib_c - #define LUA_LIB ---- a/extensions/LUA/lua/lua.h -+++ b/extensions/LUA/lua/lua.h -@@ -9,8 +9,14 @@ - #ifndef lua_h - #define lua_h - -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - #include - #include -+#else -+#include -+#include -+#endif - - #include "luaconf.h" - ---- a/extensions/LUA/lua/luaconf.h -+++ b/extensions/LUA/lua/luaconf.h -@@ -8,7 +8,12 @@ - #ifndef lconfig_h - #define lconfig_h - -+#include -+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - #include -+#else -+#include -+#endif - - #if !defined(__KERNEL__) - #include