|
Zbigniew Jędrzejewski-Szmek |
611201 |
From fa30043f5a3e4eaff50a72bad95601d582ac045d Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
Date: Sun, 18 Jun 2017 16:07:57 -0400
|
|
Zbigniew Jędrzejewski-Szmek |
611201 |
Subject: [PATCH] resolved: simplify alloc size calculation
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
The allocation size was calculated in a complicated way, and for values
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
close to the page size we would actually allocate less than requested.
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
Reported by Chris Coulson <chris.coulson@canonical.com>.
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
CVE-2017-9445
|
|
Zbigniew Jędrzejewski-Szmek |
611201 |
|
|
Zbigniew Jędrzejewski-Szmek |
611201 |
(cherry picked from commit db848813bae4d28c524b3b6a7dad135e426659ce)
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
src/resolve/resolved-dns-packet.c | 8 +-------
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
src/resolve/resolved-dns-packet.h | 2 --
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
2 files changed, 1 insertion(+), 9 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
index 240ee448f4..821b66e266 100644
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
--- a/src/resolve/resolved-dns-packet.c
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
+++ b/src/resolve/resolved-dns-packet.c
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
@@ -47,13 +47,7 @@ int dns_packet_new(DnsPacket **ret, DnsProtocol protocol, size_t mtu) {
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
assert(ret);
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
- if (mtu <= UDP_PACKET_HEADER_SIZE)
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
- a = DNS_PACKET_SIZE_START;
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
- else
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
- a = mtu - UDP_PACKET_HEADER_SIZE;
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
- if (a < DNS_PACKET_HEADER_SIZE)
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
- a = DNS_PACKET_HEADER_SIZE;
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
+ a = MAX(mtu, DNS_PACKET_HEADER_SIZE);
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
/* round up to next page size */
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
a = PAGE_ALIGN(ALIGN(sizeof(DnsPacket)) + a) - ALIGN(sizeof(DnsPacket));
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
diff --git a/src/resolve/resolved-dns-packet.h b/src/resolve/resolved-dns-packet.h
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
index 2c92392e4d..3abcaf8cf3 100644
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
--- a/src/resolve/resolved-dns-packet.h
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
+++ b/src/resolve/resolved-dns-packet.h
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
@@ -66,8 +66,6 @@ struct DnsPacketHeader {
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
/* With EDNS0 we can use larger packets, default to 4096, which is what is commonly used */
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
#define DNS_PACKET_UNICAST_SIZE_LARGE_MAX 4096
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
-#define DNS_PACKET_SIZE_START 512
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
struct DnsPacket {
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
int n_ref;
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
DnsProtocol protocol;
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
--
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
2.13.0
|
|
Zbigniew Jędrzejewski-Szmek |
4bbfd1 |
|