[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH] udhcpd: Do not pass out static leases to random clients
From:       "Ramsay, Lincoln" <Lincoln.Ramsay () digi ! com>
Date:       2020-12-03 5:39:11
Message-ID: CY4PR1001MB231112F2880220B318855767E8F20 () CY4PR1001MB2311 ! namprd10 ! prod ! outlook ! com
[Download RAW message or body]

Hi,

Apologies if this arrives twice, I missed that you have to be subscribed to post, I'm \
assuming my first message went into /dev/null.

I have run into an interesting problem. We have a DHCP server that exists to serve a \
single address to a single client.

start 192.168.0.2
end 192.168.0.2
interface eth1
max_leases 1
lease_file /var/run/udhcpd.leases
option subnet 255.255.255.252
option router 50.50.50.50
option dns 123.50.50.128
option lease 60
static_lease 11:22:33:44:55:66 192.168.0.2

If machine 11:22:33:44:55:66 sends a DHCPDISCOVER it gets the address as expected.

If a different machine sends a DHCPDISCOVER, the server will not assign it an address \
because the only available address is attached to a static lease (or alternatively, \
because that address is already leased out).

However, if a different machine sends a DHCPDISCOVER with DHCP_REQUESTED_IP of \
192.168.0.2, the server will happily allow it unless the address is already leased \
out.

The way we found this was by changing the MAC address in the server's config. We \
expected the old client to lose its lease but instead, it just kept on getting the \
address even though the server config indicates it should not.

The patch here will cause the server to ignore the DHCP_REQUESTED_IP in the event \
that it is a static lease for a different machine. The server will fall back to the \
available pool of addresses as if the DHCP_REQUESTED_IP was not included.

Lincoln


["0001-udhcpd-do-not-pass-out-static-leases.patch" (application/octet-stream)]

From 635e9902510bba2c43f6df91d94723f15c480141 Mon Sep 17 00:00:00 2001
From: Lincoln Ramsay <lincoln.ramsay@opengear.com>
Date: Fri, 27 Nov 2020 13:59:02 +1000
Subject: [PATCH] udhcpd: Do not pass out static leases to random clients

If a client sends a DHCP DISCOVER with a DHCP_REQUESTED_IP that is a
static lease for another machine, do not allow it.

Signed-off-by: Lincoln Ramsay <lincoln.ramsay@opengear.com>

---
 networking/udhcp/dhcpd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 9d66049..20c3956 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -743,6 +743,8 @@ static NOINLINE void send_offer(struct dhcp_packet *oldpacket,
 		 /* and the IP is in the lease range */
 		 && ntohl(requested_nip) >= server_data.start_ip
 		 && ntohl(requested_nip) <= server_data.end_ip
+		 /* and the IP does not belong to a static lease for a different machine */
+		 && !is_nip_reserved_as_static(requested_nip)
 		 /* and */
 		 && (  !(lease = find_lease_by_nip(requested_nip)) /* is not already taken */
 		    || is_expired_lease(lease) /* or is taken, but expired */
-- 
2.17.1



_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic