38 Commits

Author SHA1 Message Date
Peter Müller
5086ed681d sysctl: Permit ptrace usage for processes with CAP_SYS_PTRACE
https://lists.ipfire.org/pipermail/development/2022-June/013763.html

Reported-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
2022-06-29 19:43:08 +00:00
Peter Müller
f62b488f82 sysctl: Actually arm YAMA
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
2022-06-20 20:10:47 +00:00
Peter Müller
84d6e93150 sysctl: For the sake of completeness, do not accept IPv6 redirects
While IPFire 2.x' web interface does not support IPv6, users can
technically run it with IPv6 by conducting the necessary configuration
changes manually.

To provide these systems as well, we should disable acceptance of ICMPv6
redirect packets - which is apparently not default in Linux, yet. :-/

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>
2022-06-13 15:48:45 +00:00
Peter Müller
1af975dceb sysctl: Use strict Reverse Path Filtering
The strict mode, as specified in RFC 3704, section 2.2, causes packets
to be dropped by the kernel if they arrive with a source IP address that
is not expected on the interface they arrived in. This prevents internal
spoofing attacks, and is considered best practice among the industry.

After a discussion with Michael, we reached the conclusion that
permitting users to configure the operating mode of RPF in IPFire causes
more harm than good. The scenarios where strict RPF is not usable are
negligible, and the vast majority of IPFire's userbase won't even
notice a difference.

This supersedes <495b4ca2-5a4b-2ffa-8306-38f152889582@ipfire.org>.

Suggested-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Reviewed-by: Adolf Belka <adolf.belka@ipfire.org>
2022-05-02 05:28:52 +00:00
Peter Müller
400c4e8edb Kernel: Block non-UID-0 profiling completely
This is recommended by KSPP, Lynis, and others. Indeed, there is no
legitimate reason why an unprivileged user on IPFire should do any
profiling. Unfortunately, this change never landed in the mainline
kernel, hence a distribution patch is necessary.

The second version of this patch rebases the kernel patch by Jeff
Vander Stoep against Linux 5.15.17 to avoid fuzzying.

Tested-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
2022-04-04 19:58:49 +00:00
Peter Müller
d21e6d94cb sysctl.conf: Enable Loose Reverse Path Filter according to RFC 3704
For historical reasons, we were always reluctant to reverse path
filtering, since configuration changes were tricky to evaluate for a
larger userbase, IPFire permits a number of complex scenarios, and due
to limited resources.

As a compromise, this patch suggests to enable Loose Reverse Path
Filtering, as specified in RFC 3704 (section 2.4), to gain at least some
security achievement on this end.

To quote from that:

   Loose Reverse Path Forwarding (Loose RPF) is algorithmically similar
   to strict RPF, but differs in that it checks only for the existence
   of a route (even a default route, if applicable), not where the route
   points to.  Practically, this could be considered as a "route
   presence check" ("loose RPF is a misnomer in a sense because there is
   no "reverse path" check in the first place).

   The questionable benefit of Loose RPF is found in asymmetric routing
   situations: a packet is dropped if there is no route at all, such as
   to "Martian addresses" or addresses that are not currently routed,
   but is not dropped if a route exists.

There is no legitimate reason why we cannot enable this: If IPFire
receives a packet on some interface it cannot route on _any_ interface
at all, there is no sense in processing it.

While testing this change, I was unable to produce a situation where it
actually causes any harm. In theory, it shouldn't do so anyways.

In the future, we will hopefully be able to set these sysctl's to "1",
using Strict Reverse Path Filtering, as specified in RFC 3704 (section
2.2). Doing so was found to work fine in my testing environment as well,
but there is no asymmetric routing in place there.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
2022-01-19 17:45:04 +00:00
Arne Fitzenreiter
ffd857d098 sysctl: kernel 5.13 has removed some scheduler variables.
sched_min_granularity_ns and sched_migration_cost_ns are not
available for sysctl anymore. They can only altered via debugfs
if scheduler debugging is enabled.

Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2021-11-30 09:50:38 +01:00
Michael Tremer
4d622b7ebe sysctl.conf: prevent autoloading of TTY line disciplines
This reverts commit a9d90b1b3f.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2021-04-06 10:13:38 +00:00
Peter Müller
b474e87bb8 sysctl.conf: include PID in file names of generated core dumps
This is recommended by various Linux hardening guides in order to
prevent accidential overwriting of existing core dumps. While it has
probably little to no relevance to the average IPFire user, enabling it
won't harm and fixes a Lynis warning. :-)

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2020-11-05 23:37:53 +00:00
Michael Tremer
a9d90b1b3f Revert "sysctl.conf: prevent autoloading of TTY line disciplines"
This reverts commit 14c65ab71c.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2020-10-06 12:26:26 +00:00
Peter Müller
14c65ab71c sysctl.conf: prevent autoloading of TTY line disciplines
Malicious/vulnerable TTY line disciplines have been subject of some
kernel exploits such as CVE-2017-2636, and since - to put it in Greg
Kroah-Hatrman's words - we do not "trust the userspace to do the right
thing", this reduces local kernel attack surface.

Further, there is no legitimate reason why an unprivileged user should
load kernel modules during runtime, anyway.

See also:
- https://lkml.org/lkml/2019/4/15/890
- https://a13xp0p0v.github.io/2017/03/24/CVE-2017-2636.html

Cc: Arne Fitzenreiter <arne.fitzenreiter@ipfire.org>
Cc: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2020-10-06 12:04:14 +00:00
Peter Müller
b7b65e736e sysctl.conf: prevent unintentional writes into attacker-controlled files and FIFOs
Similar to hard- and symlink protection introduced a while ago, this
patch enables protections against unintentional writes into
attacker-controlled regular files or FIFOs, where a program expected to
create new ones. This makes exploiting TOCTOU flaws harder.

See also: https://www.kernel.org/doc/Documentation/sysctl/fs.txt

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2020-10-05 15:07:47 +00:00
Peter Müller
dc5a89c948 sysctl.conf: drop RST packets for sockets in TIME-WAIT state
RFC 1337 describes various TCP (side channel) attacks against
prematurely closed connections stalling in TIME-WAIT state, such as DoS
or injecting arbitrary TCP segments, and recommends to silently discard
RST packets for sockets in this state.

While applications still tied to such sockets should tolerate invalid
input (thanks to Jon Postel), there is little legitimate reason to send
such RST packets altogether.

At the time of writing, no collateral damage related to active RFC 1337
implementations is known. Measuerements in productive environments did
not reveal any side effects either, which is why I consider enabling RFC
1337 implementation to be a safe change.

See also: https://tools.ietf.org/html/rfc1337

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2020-09-30 17:14:07 +00:00
Peter Müller
29a8992b72 sysctl.conf: Turn on hard- and symlink protection
Cc: Michael Tremer <michael.tremer@ipfire.org>
Cc: Arne Fitzenreiter <arne_f@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Acked-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2020-03-30 17:07:26 +00:00
Michael Tremer
58b3c9b58a sysctl: Adopt more settings from the IBM HPC guidelines
https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Welcome%20to%20High%20Performance%20Computing%20%28HPC%29%20Central/page/Linux%20System%20Tuning%20Recommendations

Since we have already configured most of our IP/TCP stack
for low latency and fast throughput, these settings complete
those efforts.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2019-10-14 17:56:30 +00:00
Michael Tremer
e37e796206 sysctl.conf: Revert enabling busy loop waiting on sockets
This causes the firmware in my ath10k module to crash.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-02-28 18:53:22 +00:00
Michael Tremer
d03916e558 Enable some performance tuning
These parameters increase the throughput on various (large-ish)
systems by 5-10% on the slight expense of higher power consumption.

Socket buffers are increases and the system is configured to be
less aggressive when scheduling processes from one processor to
another one which ensures that the cache remains "hot" for longer.

On a slower system (apu1d) no performance improvement or loss
could have been measured.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-01-24 12:31:27 +00:00
Michael Tremer
93d516bd70 Revert "Disable Path MTU discovery"
This reverts commit 1c0cfaa594.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-01-17 19:24:46 +00:00
Michael Tremer
f0092a6e3e keepalived: Move change of conntrack sysctl option into package
The setting cannot be set on the default system because the ip_vs
module is not loaded by default and there is no reason to load it
just because we would be able to set the setting.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-01-13 12:50:26 +01:00
Michael Tremer
af2cc3be64 IPVS: Enable connection tracking by default
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-01-06 21:33:43 +00:00
Tim FitzGeorge
dfb985caa9 Allow kernel to swap memory on high demand
Signed-off-by: Tim FitzGeorge <ipfr@tfitzgeorge.me.uk>
Fixes: Bug 11839
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2018-10-18 14:34:33 +01:00
Peter Müller
d5fe332283 do not expose kernel address spaces even to privileged users
Change this setting from 1 to 2 so kernel addresses are not
displayed even if a user has CAPS_SYSLOG privileges.

See also:
- https://lwn.net/Articles/420403/
- https://tails.boum.org/contribute/design/kernel_hardening/

Signed-off-by: Peter Müller <peter.mueller@link38.eu>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2018-09-09 17:47:08 +01:00
Peter Müller
373590b7c3 hide kernel addresses in /proc
Make sure kernel address space is hidden from files somewhere
in /proc . This reduces attack surface and partially addresses #11659.

Signed-off-by: Peter Müller <peter.mueller@link38.eu>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2018-07-03 10:32:56 +01:00
Michael Tremer
1c0cfaa594 Disable Path MTU discovery
This seems to be a failed concept and causes issues with transferring
large packets through an IPsec tunnel connection.

This configures the kernel to still respond to PMTU ICMP discovery
messages, but will not try this on its own.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2018-02-26 15:37:49 +00:00
Jonatan Schlag
0f1cda211c Disable netfilter on all bridges per default
Fixes: #11301

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2017-03-11 10:08:16 +00:00
Michael Tremer
32c6ebdced firewall: Make ICMP ratelimiting a bit saner again. 2014-03-05 12:31:36 +01:00
Michael Tremer
fa8229546b firewall: Extend rate limiting for ICMP error messages.
Fixes #10489.
2014-03-04 14:14:54 +01:00
Michael Tremer
1108a15cc6 Move enabling nf_conntrack_acct where it should be. 2014-02-14 12:52:28 +01:00
Michael Tremer
a30c7aa3be Compile-in IPv6 kernel module and disable all IPv6.
It comes much more handy to compile in the IPv6 kernel module
(because it is loading almost everywhere) and disable the IPv6
functionality when the system starts up.

Therefore, IPv6 is not accidentially enabled at any time unless
someone wants to use it and disables the systcl options.
2012-11-24 14:52:32 +01:00
Arne Fitzenreiter
fa5b71bf28 Revert "sysctl: activate conntrack accounting."
This reverts commit 94ca39b479.
Cannot set this because nf_conntrack is not loaded yet.
2012-11-17 20:04:53 +01:00
Arne Fitzenreiter
94ca39b479 sysctl: activate conntrack accounting. 2012-11-17 15:39:54 +01:00
Arne Fitzenreiter
d1605d0810 sysctl.conf: reserve 8MB free memory.
Some driver like SMSC9500 need some free memory for network packet
recieve and produce kernel faults if this memory cant allocated fast
enough.
2012-06-26 15:19:36 +02:00
Michael Tremer
ed37f707f9 Remove old settings from sysctl.conf.
This commits removes some settings from /etc/sysctl.conf that have
been there forever with no particular reason.
They could improve performance on internet connections, especially
on lines with massive packet lost.
2011-06-25 22:02:08 +02:00
Arne Fitzenreiter
dc931fbac7 Set vm.mmap_min_addr to 4096 to block a security problem. 2009-11-04 18:48:38 +01:00
maniacikarus
4894d87017 Just a lot of things changed for squid 2009-02-07 14:41:28 +01:00
maniacikarus
8b88498602 Started core27 modified max Open Files per process 2009-02-07 08:59:44 +01:00
Maniacikarus
832eec2359 Change system behaviour to less swapping 2008-12-07 18:49:27 +01:00
ipfire
cd1a292722 git-svn-id: http://svn.ipfire.org/svn/ipfire/IPFire/source@16 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8 2006-02-15 21:15:54 +00:00