Skip to content

ipvs: fix LBLC and LBLCR cache growth

Julian Anastasov lvs-devel netfilter-devel 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v4 Latest2 patches 0 repliesNew

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2ipvs: fix missing counter decrement in lblcnet/netfilter/ipvs/ip_vs_lblc.c+1 -00 replies
2/2ipvs: bound LBLCR and LBLC cache growthnet/netfilter/ipvs/ip_vs_lblc.c net/netfilter/ipvs/ip_vs_lblcr.c+6 -00 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchJulian Anastasov
1/2
2/2A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 nf 0/2] ipvs: fix LBLC and LBLCR cache growth

Hello,

Following is a patchset with two changes:

1. fix for a missing decrement in LBLC

2. v3 of the LBLC/LBLCR patch from Zhiling Zou applied on top of the first patch, as v4

Zhiling Zou <[email protected]> explained the problem in v3:

We found and validated an issue in net/netfilter/ipvs/ip_vs_lblcr.c. The bug is reachable by a non-root user through a new user and network namespace. The same cache growth bound is also missing from the sibling LBLC scheduler in net/netfilter/ipvs/ip_vs_lblc.c.

Bug details:

ip_vs_lblcr_new() allocates and publishes an LBLCR cache entry for every previously unseen destination address. Although tbl->max_size is initialized to 16384 entries, it is only used by the periodic collector after cache growth has already exceeded the limit. The collector runs once per minute and does not reclaim recently used entries.

An attacker can configure a fwmark-based LBLCR service and continuously send UDP packets to distinct destination addresses. Each new address creates an entry, allowing the table to grow without bound. The allocations use GFP_ATOMIC and are not charged to the originating socket or memory cgroup.

LBLC uses the same cache model and periodic collector. Bound new LBLC cache entries the same way so both scheduler variants stop growing after their table reaches max_size * 3 / 2.

The scheduler selects a destination before attempting to cache it and already continues to use that destination when cache creation fails. The fix therefore rejects only new cache entries once the table reaches max_size * 3 / 2, while normal traffic to new addresses remains serviceable without further cache growth.

Julian Anastasov (1):
ipvs: fix missing counter decrement in lblc

Zhiling Zou (1):
ipvs: bound LBLCR and LBLC cache growth

 net/netfilter/ipvs/ip_vs_lblc.c  | 4 ++++
 net/netfilter/ipvs/ip_vs_lblcr.c | 3 +++
 2 files changed, 7 insertions(+)
Signature · 1 line
2.55.0