]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
addrfilt: fix access configuration with subnet size indivisible by 4
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 30 Mar 2015 12:41:37 +0000 (14:41 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 7 Apr 2015 14:35:16 +0000 (16:35 +0200)
When NTP or cmdmon access was configured (from chrony.conf or via
authenticated cmdmon) with a subnet size that is indivisible by 4 and
an address that has nonzero bits in the 4-bit subnet remainder (e.g.
192.168.15.0/22 or f000::/3), the new setting was written to an
incorrect location, possibly outside the allocated array.

An attacker that has the command key and is allowed to access cmdmon
(only localhost is allowed by default) could exploit this to crash
chronyd or possibly execute arbitrary code with the privileges of the
chronyd process.

addrfilt.c

index 0930289d2143d5d5bc28b21f49d9ea6b1653fb6e..4b8879ac2cf608b8d28103508c032ee365a974b8 100644 (file)
@@ -199,7 +199,10 @@ set_subnet(TableNode *start_node,
 
       /* How many subnet entries to set : 1->8, 2->4, 3->2 */
       N = 1 << (NBITS-bits_to_go);
-      subnet = get_subnet(ip, bits_consumed);
+
+      subnet = get_subnet(ip, bits_consumed) & ~(N - 1);
+      assert(subnet + N <= TABLE_SIZE);
+
       if (!(node->extended)) {
         open_node(node);
       }