geoip: Use stdout for output and stderr for errors/diag
* xt_geoip_build, xt_geoip_build_maxmind: These scripts are emitting
"normal" output to stderr meaning that cronjobs basically have to sink
all output in order to avoid noise. Unfortunately, by doing that, one
also loses errors in the error case and said error might be transient.
A simple 1>/dev/null should work for the normal cron case.
* xt_geoip_build_maxmind: Fix missing $quiet check in the v4 case.
Jeremy Sowden [Thu, 29 Dec 2022 16:35:07 +0000 (17:35 +0100)]
build: support for Linux 6.2
`prandom_u32_max` was deprecated in favour of `get_random_u32_below`,
and removed in 6.2-rc1. Replace the three occurrences of it in the
TARPIT extension, and ad compat support for earlier kernels.
John Thomson [Mon, 24 Oct 2022 09:58:02 +0000 (11:58 +0200)]
build: support for Linux 6.1
6.1 commit de492c83cae0 ("prandom: remove unused functions") removed
prandom_u32, which was replaced and deprecated for get_random_u32 in
5.19 d4150779e60f ("random32: use real rng for non-deterministic
randomness"). get_random_u32 was introduced in 4.11 c440408cf690
("random: convert get_random_int/long into get_random_u32/u64")
Use the cocci script from 81895a65ec63 ("treewide: use prandom_u32_max()
when possible, part 1"), along with a best guess for _max changes, introduced:
3.14 f337db64af05 ("random32: add prandom_u32_max and convert open coded users")
D. Stussy [Sun, 10 Mar 2019 06:45:11 +0000 (06:45 +0000)]
xt_asn: new module
Recevied by private mail.
Date: Thu, 7 Mar 2019 00:49:16 +0000 (UTC)
"""
New feature: In thinking about various blocking of IP address groups,
I came to the conclusion that blocking by ASN may be a good
choice. Therefore, taking the lead of the geoip match module,
attached is what I have for an ASN matching module. I assume that the
support files generated will be the same format as those used for the
geoip match. [...]
I bet someone might want the ASNs on the same rule to be sorted in
numerical order. However, geoip didn't do that with country names, so
I didn't bother.
Matching by ASN may be "better" than matching by an ipset of all one
entities IP blocks (assuming that all of an entity's ASNs are known
if multiples exist). Of course, I would like to see this module make
it into your next release (3.3). ;-)
"""
Date: Sun, 10 Mar 2019 06:45:11 +0000 (UTC)
"""
I think I got everything including the documentation and build script
this time. [...]
I noticed that some other people tried to write similar patches (saw
one on github), but those have things that were missed.
I'm running the module on my colocated server now, and it's working
well. Already blocked ASN 4134 (a botnet-infected Chinese net) a few
hundred times in the first hour.
"""
Thomas Voegtle [Thu, 9 Jun 2022 13:19:22 +0000 (15:19 +0200)]
xt_ECHO: use flowi6_to_flowi_common starting Linux 5.10.121
Upstream commit 3df98d79215a "lsm,selinux: pass flowi_common instead of flowi
to the LSM hooks" was backported to Linux 5.10.121 and you can't use flowi
anymore.
Jeremy Sowden [Fri, 4 Feb 2022 13:26:42 +0000 (14:26 +0100)]
extensions: replace PDE_DATA
The `PDE_DATA` function for retrieving private data from a procfs inode
has been replaced by `pde_data` in 5.17. Replace all instances of the
former with the latter, but add a macro to xtables_compat.h in order to
preserve compatibility with older kernels.
Jeremy Sowden [Mon, 13 Sep 2021 19:46:07 +0000 (21:46 +0200)]
xt_ipp2p: fix compatibility with pre-5.1 kernels
`ip_transport_len` and `ipv6_transport_len` were introduced in 5.1.
They are both single-statement static inline functions, so add fall-back
implementations for compatibility with older kernels.
Jeremy Sowden [Sun, 22 Aug 2021 16:35:53 +0000 (17:35 +0100)]
xt_condition: remove `wmb` when adding new variable
Originally, some accesses to `conditions_list` were protected by RCU and
the memory-barrier was needed to ensure that the new variable was fully
initialized before being added to the list. These days, however, all
accesses are protected by the `proc_lock` mutex, so the barrier is no
longer required.
Jeremy Sowden [Sat, 21 Aug 2021 10:17:24 +0000 (12:17 +0200)]
Add DWARF object files to .gitignore.
If we build against a kernel with `CONFIG_DEBUG_INFO_SPLIT` enabled, the
kernel compiler flags will include `-gsplit-dwarf`, and the linker will
emit .dwo files.
Jan Engelhardt [Thu, 11 Mar 2021 16:11:47 +0000 (17:11 +0100)]
xt_pknock: fix build failure under platforms like ARM 32-bit
./arch/arm/include/asm/div64.h:24:45: note: expected "uint64_t *"
{aka "long long unsigned int *"} but argument is of type
"long unsigned int *"
24 | static inline uint32_t __div64_32(uint64_t *n, uint32_t base)
The original patch for long division on x86 didn't take into account
the use of short circuit logic for checking if peer is NULL before
testing it. Here is a revised patch to v3.16.
Jan Engelhardt [Fri, 5 Feb 2021 19:14:55 +0000 (20:14 +0100)]
xt_pknock: replace obsolete function get_seconds
get_seconds is removed in 5.11; its replacement ktime_get_real_seconds
is available since 3.19. The timestamps should not be affected by clock
resets, so will be switched to ktime_get_seconds.
Jeremy Sowden [Sun, 22 Nov 2020 14:05:30 +0000 (15:05 +0100)]
geoip: use correct download URL for MaxMind DBs
The download URL for the GeoLite2 DBs has changed and includes a
licence key. Update the download script to read the key from file or
stdin and use the correct URL.
Jeremy Sowden [Sun, 25 Oct 2020 13:15:59 +0000 (14:15 +0100)]
xt_pknock: remove DEBUG definition and disable debug output
The DEBUG definition in xt_pknock.h causes a compiler warning if one
adds a DEBUG define to xt_pknock.c to enable pr_debug. Since it only
controls some debugging output in libxt_pknock.c, it would make sense to
move the definition there, but let's just disable the debugging instead.
Jeremy Sowden [Sun, 25 Oct 2020 13:15:55 +0000 (14:15 +0100)]
pknlusr: fix hard-coded netlink multicast group ID
The group ID used by xt_pknock is configurable, but pknlusr hard-codes
it. Modify pknlusr to accept an optional ID from the command line.
Group IDs range from 1 to 32 and each ID appears in the group bitmask
at position `group_id - 1`.
Jeremy Sowden [Sun, 25 Oct 2020 13:15:53 +0000 (14:15 +0100)]
pknlusr: do not treat recv return value of zero as an error
A return-value of zero is not an error, so there is no point calling
perror, but since we have not requested and do not expect a zero-length
datagram, we treat it as EOF and exit.