Wed Jun 10 13:57:08 2009 UTC ()
Patches for CVE-2009-1377, CVE-2009-1378 & CVE-2009-1379 from
http://cvs.openssl.org/filediff?f=openssl/ssl/d1_both.c&v1=1.4.2.9&v2=1.4.2.10
http://cvs.openssl.org/filediff?f=openssl/ssl/d1_both.c&v1=1.4.2.13&v2=1.4.2.15
http://cvs.openssl.org/filediff?f=openssl/crypto/pqueue/pqueue.c&v1=1.2.2.4&v2=1.2.2.5
http://cvs.openssl.org/filediff?f=openssl/crypto/pqueue/pqueue.h&v1=1.2.2.1&v2=1.2.2.2
http://cvs.openssl.org/filediff?f=openssl/ssl/d1_pkt.c&v1=1.4.2.17&v2=1.4.2.18


(tez)
diff -r1.139 -r1.140 pkgsrc/security/openssl/Makefile
diff -r1.67 -r1.68 pkgsrc/security/openssl/distinfo
diff -r0 -r1.1 pkgsrc/security/openssl/patches/patch-ax
diff -r0 -r1.1 pkgsrc/security/openssl/patches/patch-ay
diff -r0 -r1.1 pkgsrc/security/openssl/patches/patch-az
diff -r0 -r1.1 pkgsrc/security/openssl/patches/patch-ba

cvs diff -r1.139 -r1.140 pkgsrc/security/openssl/Makefile (switch to unified diff)

--- pkgsrc/security/openssl/Makefile 2009/05/21 21:37:28 1.139
+++ pkgsrc/security/openssl/Makefile 2009/06/10 13:57:08 1.140
@@ -1,123 +1,124 @@ @@ -1,123 +1,124 @@
1# $NetBSD: Makefile,v 1.139 2009/05/21 21:37:28 zafer Exp $ 1# $NetBSD: Makefile,v 1.140 2009/06/10 13:57:08 tez Exp $
2 2
3OPENSSL_SNAPSHOT?= # empty 3OPENSSL_SNAPSHOT?= # empty
4OPENSSL_STABLE?= # empty 4OPENSSL_STABLE?= # empty
5OPENSSL_VERS?= 0.9.8k 5OPENSSL_VERS?= 0.9.8k
 6PKGREVISION= 1
6 7
7.if empty(OPENSSL_SNAPSHOT) 8.if empty(OPENSSL_SNAPSHOT)
8DISTNAME= openssl-${OPENSSL_VERS} 9DISTNAME= openssl-${OPENSSL_VERS}
9MASTER_SITES= ftp://ftp.openssl.org/source/ \ 10MASTER_SITES= ftp://ftp.openssl.org/source/ \
10 ftp://sunsite.cnlab-switch.ch/mirror/openssl/source/ \ 11 ftp://sunsite.cnlab-switch.ch/mirror/openssl/source/ \
11 ftp://sunsite.uio.no/pub/security/openssl/source/  12 ftp://sunsite.uio.no/pub/security/openssl/source/
12.else 13.else
13. if !empty(OPENSSL_STABLE:M[yY][eE][sS]) 14. if !empty(OPENSSL_STABLE:M[yY][eE][sS])
14DISTNAME= openssl-${OPENSSL_VERS:C/[a-z]$//}-stable-SNAP-${OPENSSL_SNAPSHOT} 15DISTNAME= openssl-${OPENSSL_VERS:C/[a-z]$//}-stable-SNAP-${OPENSSL_SNAPSHOT}
15PKGNAME= openssl-${OPENSSL_VERS}beta${OPENSSL_SNAPSHOT} 16PKGNAME= openssl-${OPENSSL_VERS}beta${OPENSSL_SNAPSHOT}
16MASTER_SITES= ftp://ftp.openssl.org/snapshot/ 17MASTER_SITES= ftp://ftp.openssl.org/snapshot/
17. else 18. else
18DISTNAME= openssl-SNAP-${OPENSSL_SNAPSHOT} 19DISTNAME= openssl-SNAP-${OPENSSL_SNAPSHOT}
19PKGNAME= openssl-${OPENSSL_VERS}alpha${OPENSSL_SNAPSHOT} 20PKGNAME= openssl-${OPENSSL_VERS}alpha${OPENSSL_SNAPSHOT}
20MASTER_SITES= ftp://ftp.openssl.org/snapshot/ 21MASTER_SITES= ftp://ftp.openssl.org/snapshot/
21. endif 22. endif
22.endif 23.endif
23 24
24SVR4_PKGNAME= ossl 25SVR4_PKGNAME= ossl
25CATEGORIES= security 26CATEGORIES= security
26MAINTAINER= pkgsrc-users@NetBSD.org 27MAINTAINER= pkgsrc-users@NetBSD.org
27HOMEPAGE= http://www.openssl.org/ 28HOMEPAGE= http://www.openssl.org/
28COMMENT= Secure Socket Layer and cryptographic library 29COMMENT= Secure Socket Layer and cryptographic library
29 30
30CONFLICTS= SSLeay-[0-9]* ssleay-[0-9]* 31CONFLICTS= SSLeay-[0-9]* ssleay-[0-9]*
31 32
32CRYPTO= yes 33CRYPTO= yes
33 34
34PKG_INSTALLATION_TYPES= overwrite pkgviews 35PKG_INSTALLATION_TYPES= overwrite pkgviews
35PKG_DESTDIR_SUPPORT= user-destdir 36PKG_DESTDIR_SUPPORT= user-destdir
36 37
37.include "../../mk/bsd.prefs.mk" 38.include "../../mk/bsd.prefs.mk"
38.include "../../mk/compiler.mk" 39.include "../../mk/compiler.mk"
39 40
40USE_TOOLS+= gmake perl 41USE_TOOLS+= gmake perl
41TEST_TARGET= tests 42TEST_TARGET= tests
42MAKE_JOBS_SAFE= no 43MAKE_JOBS_SAFE= no
43 44
44HAS_CONFIGURE= yes 45HAS_CONFIGURE= yes
45CONFIGURE_SCRIPT= ./config 46CONFIGURE_SCRIPT= ./config
46CONFIGURE_ARGS+= --prefix=${PREFIX:Q} 47CONFIGURE_ARGS+= --prefix=${PREFIX:Q}
47CONFIGURE_ARGS+= --install_prefix=${DESTDIR} 48CONFIGURE_ARGS+= --install_prefix=${DESTDIR}
48CONFIGURE_ARGS+= --openssldir=${PKG_SYSCONFDIR:Q} 49CONFIGURE_ARGS+= --openssldir=${PKG_SYSCONFDIR:Q}
49CONFIGURE_ARGS+= shared threads no-fips 50CONFIGURE_ARGS+= shared threads no-fips
50 51
51.if ${OPSYS} == "SunOS" 52.if ${OPSYS} == "SunOS"
52. if ${MACHINE_ARCH} == "sparc" 53. if ${MACHINE_ARCH} == "sparc"
53OPENSSL_MACHINE_ARCH= ${SPARC_TARGET_ARCH} 54OPENSSL_MACHINE_ARCH= ${SPARC_TARGET_ARCH}
54. elif ${MACHINE_ARCH} == "i386" 55. elif ${MACHINE_ARCH} == "i386"
55OPENSSL_MACHINE_ARCH= x86 56OPENSSL_MACHINE_ARCH= x86
56. elif ${MACHINE_ARCH} == "x86_64" 57. elif ${MACHINE_ARCH} == "x86_64"
57OPENSSL_MACHINE_ARCH= ${MACHINE_ARCH} 58OPENSSL_MACHINE_ARCH= ${MACHINE_ARCH}
58. endif 59. endif
59# only override the configure target if we know the platform, falling 60# only override the configure target if we know the platform, falling
60# back to ./config's autodetection if not. 61# back to ./config's autodetection if not.
61. if defined(OPENSSL_MACHINE_ARCH) && !empty(OPENSSL_MACHINE_ARCH) 62. if defined(OPENSSL_MACHINE_ARCH) && !empty(OPENSSL_MACHINE_ARCH)
62CONFIGURE_SCRIPT= ./Configure 63CONFIGURE_SCRIPT= ./Configure
63. if !empty(CC_VERSION:Mgcc*) 64. if !empty(CC_VERSION:Mgcc*)
64CONFIGURE_ARGS+= solaris-${OPENSSL_MACHINE_ARCH}-gcc 65CONFIGURE_ARGS+= solaris-${OPENSSL_MACHINE_ARCH}-gcc
65. else 66. else
66CONFIGURE_ARGS+= solaris-${OPENSSL_MACHINE_ARCH}-cc 67CONFIGURE_ARGS+= solaris-${OPENSSL_MACHINE_ARCH}-cc
67. endif 68. endif
68. endif 69. endif
69.elif ${OPSYS} == "IRIX" 70.elif ${OPSYS} == "IRIX"
70CONFIGURE_ARGS+= no-asm 71CONFIGURE_ARGS+= no-asm
71. if ${ABI} == "64" 72. if ${ABI} == "64"
72CONFIGURE_SCRIPT= ./Configure 73CONFIGURE_SCRIPT= ./Configure
73. if !empty(CC_VERSION:Mgcc*) 74. if !empty(CC_VERSION:Mgcc*)
74CONFIGURE_ARGS+= irix64-mips4-gcc 75CONFIGURE_ARGS+= irix64-mips4-gcc
75. else 76. else
76CONFIGURE_ARGS+= irix64-mips4-cc 77CONFIGURE_ARGS+= irix64-mips4-cc
77. endif 78. endif
78. endif 79. endif
79.elif ${OPSYS} == "OSF1" 80.elif ${OPSYS} == "OSF1"
80PLIST_OPSYS= PLIST.osf1 81PLIST_OPSYS= PLIST.osf1
81CONFIGURE_SCRIPT= ./Configure 82CONFIGURE_SCRIPT= ./Configure
82. if !empty(CC_VERSION:Mgcc*) 83. if !empty(CC_VERSION:Mgcc*)
83CONFIGURE_ARGS+= tru64-alpha-gcc 84CONFIGURE_ARGS+= tru64-alpha-gcc
84. else 85. else
85CONFIGURE_ARGS+= tru64-alpha-cc 86CONFIGURE_ARGS+= tru64-alpha-cc
86. endif 87. endif
87.elif ${OPSYS} == "Darwin" 88.elif ${OPSYS} == "Darwin"
88.include "../../mk/dlopen.buildlink3.mk" 89.include "../../mk/dlopen.buildlink3.mk"
89 90
90SUBST_CLASSES+= dl 91SUBST_CLASSES+= dl
91SUBST_MESSAGE.dl= Adding dynamic link compatibility library. 92SUBST_MESSAGE.dl= Adding dynamic link compatibility library.
92SUBST_STAGE.dl= post-configure 93SUBST_STAGE.dl= post-configure
93SUBST_FILES.dl= Makefile apps/Makefile crypto/Makefile \ 94SUBST_FILES.dl= Makefile apps/Makefile crypto/Makefile \
94 crypto/pkcs7/Makefile test/Makefile 95 crypto/pkcs7/Makefile test/Makefile
95SUBST_SED.dl= -e 's,^EX_LIBS=,EX_LIBS=${DL_LDFLAGS:Q} ,g' 96SUBST_SED.dl= -e 's,^EX_LIBS=,EX_LIBS=${DL_LDFLAGS:Q} ,g'
96.endif 97.endif
97 98
98.include "../../security/openssl/options.mk" 99.include "../../security/openssl/options.mk"
99 100
100CONFIGURE_ARGS+= ${CFLAGS} ${LDFLAGS} 101CONFIGURE_ARGS+= ${CFLAGS} ${LDFLAGS}
101CONFIGURE_ENV+= PERL=${PERL5:Q} 102CONFIGURE_ENV+= PERL=${PERL5:Q}
102 103
103PLIST_OPSYS?= ${PKGDIR}/PLIST.${LOWER_OPSYS:C/([.0-9]*)$//} 104PLIST_OPSYS?= ${PKGDIR}/PLIST.${LOWER_OPSYS:C/([.0-9]*)$//}
104.if exists(${PLIST_OPSYS}) 105.if exists(${PLIST_OPSYS})
105PLIST_SHLIB= ${PLIST_OPSYS} 106PLIST_SHLIB= ${PLIST_OPSYS}
106.else 107.else
107PLIST_SHLIB= ${PKGDIR}/PLIST.shlib 108PLIST_SHLIB= ${PKGDIR}/PLIST.shlib
108.endif 109.endif
109PLIST_SRC= ${PLIST_SHLIB} 110PLIST_SRC= ${PLIST_SHLIB}
110PLIST_SRC+= ${PKGDIR}/PLIST.common 111PLIST_SRC+= ${PKGDIR}/PLIST.common
111PLIST_SUBST+= SHLIB_VERSION=${OPENSSL_VERS:C/[^0-9]*$//} 112PLIST_SUBST+= SHLIB_VERSION=${OPENSSL_VERS:C/[^0-9]*$//}
112PLIST_SUBST+= SHLIB_MAJOR=${OPENSSL_VERS:C/\..*$//} 113PLIST_SUBST+= SHLIB_MAJOR=${OPENSSL_VERS:C/\..*$//}
113 114
114PKG_SYSCONFSUBDIR= openssl 115PKG_SYSCONFSUBDIR= openssl
115CONF_FILES= ${PREFIX}/share/examples/openssl/openssl.cnf \ 116CONF_FILES= ${PREFIX}/share/examples/openssl/openssl.cnf \
116 ${PKG_SYSCONFDIR}/openssl.cnf 117 ${PKG_SYSCONFDIR}/openssl.cnf
117OWN_DIRS= ${PKG_SYSCONFDIR}/certs ${PKG_SYSCONFDIR}/private 118OWN_DIRS= ${PKG_SYSCONFDIR}/certs ${PKG_SYSCONFDIR}/private
118 119
119# Fix the path to perl in various scripts. 120# Fix the path to perl in various scripts.
120pre-configure: 121pre-configure:
121 cd ${WRKSRC} && ${PERL5} util/perlpath.pl ${PERL5} 122 cd ${WRKSRC} && ${PERL5} util/perlpath.pl ${PERL5}
122 123
123.include "../../mk/bsd.pkg.mk" 124.include "../../mk/bsd.pkg.mk"

cvs diff -r1.67 -r1.68 pkgsrc/security/openssl/distinfo (switch to unified diff)

--- pkgsrc/security/openssl/distinfo 2009/04/16 09:50:37 1.67
+++ pkgsrc/security/openssl/distinfo 2009/06/10 13:57:08 1.68
@@ -1,13 +1,17 @@ @@ -1,13 +1,17 @@
1$NetBSD: distinfo,v 1.67 2009/04/16 09:50:37 tnn Exp $ 1$NetBSD: distinfo,v 1.68 2009/06/10 13:57:08 tez Exp $
2 2
3SHA1 (openssl-0.9.8k.tar.gz) = 3ba079f91d3c1ec90a36dcd1d43857165035703f 3SHA1 (openssl-0.9.8k.tar.gz) = 3ba079f91d3c1ec90a36dcd1d43857165035703f
4RMD160 (openssl-0.9.8k.tar.gz) = 496df7a5d33457b0d8e3b930a8e5cf068923182c 4RMD160 (openssl-0.9.8k.tar.gz) = 496df7a5d33457b0d8e3b930a8e5cf068923182c
5Size (openssl-0.9.8k.tar.gz) = 3852259 bytes 5Size (openssl-0.9.8k.tar.gz) = 3852259 bytes
6SHA1 (patch-aa) = b28ec662bf0586e31d59cab45e3a28b91b10dac1 6SHA1 (patch-aa) = b28ec662bf0586e31d59cab45e3a28b91b10dac1
7SHA1 (patch-ac) = 7d03d0effcde4237216e9da4f38a318b0d1ae67d 7SHA1 (patch-ac) = 7d03d0effcde4237216e9da4f38a318b0d1ae67d
8SHA1 (patch-ad) = bb86ac463fc4ab8b485df5f1a4fb9c13c1fc41c3 8SHA1 (patch-ad) = bb86ac463fc4ab8b485df5f1a4fb9c13c1fc41c3
9SHA1 (patch-ae) = 7a58f1765a3761321dcc8dafc5fe2e33207be480 9SHA1 (patch-ae) = 7a58f1765a3761321dcc8dafc5fe2e33207be480
10SHA1 (patch-af) = 1eda5a96835b65d325c77ce5d39f1e524815a3c7 10SHA1 (patch-af) = 1eda5a96835b65d325c77ce5d39f1e524815a3c7
11SHA1 (patch-ag) = 5f12c72b85e4b6c6a79dfcf87055e9e029fbd8c8 11SHA1 (patch-ag) = 5f12c72b85e4b6c6a79dfcf87055e9e029fbd8c8
12SHA1 (patch-ak) = 049250b9bd42e6f155145703135dab39a7ec17e0 12SHA1 (patch-ak) = 049250b9bd42e6f155145703135dab39a7ec17e0
13SHA1 (patch-al) = 076a606352bdeaeea1cc64f16be2ac1325882302 13SHA1 (patch-al) = 076a606352bdeaeea1cc64f16be2ac1325882302
 14SHA1 (patch-ax) = ef0c657de2aa42baa365b9857583d1c55d0e7d1b
 15SHA1 (patch-ay) = 6d5de155e5508cd2237387626c8e1ff7ee603f8e
 16SHA1 (patch-az) = aa7ef7192d56979ba09aa1dab8a2cdf9868f9c4a
 17SHA1 (patch-ba) = b8ab55c0c6ab4b995cae18517609720f0803e11f

File Added: pkgsrc/security/openssl/patches/Attic/patch-ax
$NetBSD: patch-ax,v 1.1 2009/06/10 13:57:08 tez Exp $

Part of CVE-2009-1377 fix.

--- crypto/pqueue/pqueue.c.orig	2009-06-08 18:55:59.826213100 -0500
+++ crypto/pqueue/pqueue.c
@@ -234,3 +234,17 @@ pqueue_next(pitem **item)
 
 	return ret;
 	}
+
+int
+pqueue_size(pqueue_s *pq)
+{
+	pitem *item = pq->items;
+	int count = 0;
+	
+	while(item != NULL)
+	{
+		count++;
+		item = item->next;
+	}
+	return count;
+}

File Added: pkgsrc/security/openssl/patches/Attic/patch-ay
$NetBSD: patch-ay,v 1.1 2009/06/10 13:57:08 tez Exp $

Part of CVE-2009-1377 fix.

--- crypto/pqueue/pqueue.h.orig	2009-06-08 18:57:00.672546600 -0500
+++ crypto/pqueue/pqueue.h
@@ -91,5 +91,6 @@ pitem *pqueue_iterator(pqueue pq);
 pitem *pqueue_next(piterator *iter);
 
 void   pqueue_print(pqueue pq);
+int    pqueue_size(pqueue pq);
 
 #endif /* ! HEADER_PQUEUE_H */

File Added: pkgsrc/security/openssl/patches/Attic/patch-az
$NetBSD: patch-az,v 1.1 2009/06/10 13:57:08 tez Exp $

CVE-2009-1378 and CVE-2009-1379 fixes.

--- ssl/d1_both.c.orig	2009-06-08 18:59:50.629293200 -0500
+++ ssl/d1_both.c
@@ -519,6 +519,8 @@ dtls1_retrieve_buffered_fragment(SSL *s,
 
 	if ( s->d1->handshake_read_seq == frag->msg_header.seq)
 		{
+		unsigned long frag_len = frag->msg_header.frag_len;
+
 		pqueue_pop(s->d1->buffered_messages);
 
 		al=dtls1_preprocess_fragment(s,&frag->msg_header,max);
@@ -536,7 +538,7 @@ dtls1_retrieve_buffered_fragment(SSL *s,
 		if (al==0)
 			{
 			*ok = 1;
-			return frag->msg_header.frag_len;
+			return frag_len;
 			}
 
 		ssl3_send_alert(s,SSL3_AL_FATAL,al);
@@ -561,7 +563,16 @@ dtls1_process_out_of_seq_message(SSL *s,
 	if ((msg_hdr->frag_off+frag_len) > msg_hdr->msg_len)
 		goto err;
 
-	if (msg_hdr->seq <= s->d1->handshake_read_seq)
+	/* Try to find item in queue, to prevent duplicate entries */
+	pq_64bit_init(&seq64);
+	pq_64bit_assign_word(&seq64, msg_hdr->seq);
+	item = pqueue_find(s->d1->buffered_messages, seq64);
+	pq_64bit_free(&seq64);
+	
+	/* Discard the message if sequence number was already there, is
+	 * too far in the future or the fragment is already in the queue */
+	if (msg_hdr->seq <= s->d1->handshake_read_seq ||
+		msg_hdr->seq > s->d1->handshake_read_seq + 10 || item != NULL)
 		{
 		unsigned char devnull [256];
 

File Added: pkgsrc/security/openssl/patches/Attic/patch-ba
$NetBSD: patch-ba,v 1.1 2009/06/10 13:57:08 tez Exp $

Part of CVE-2009-1377 fix.

--- ssl/d1_pkt.c.orig	2009-06-08 18:58:13.784215600 -0500
+++ ssl/d1_pkt.c
@@ -167,6 +167,10 @@ dtls1_buffer_record(SSL *s, record_pqueu
     DTLS1_RECORD_DATA *rdata;
 	pitem *item;
 
+	/* Limit the size of the queue to prevent DOS attacks */
+	if (pqueue_size(queue->q) >= 100)
+		return 0;
+
 	rdata = OPENSSL_malloc(sizeof(DTLS1_RECORD_DATA));
 	item = pitem_new(priority, rdata);
 	if (rdata == NULL || item == NULL)