Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932277AbYCUWws (ORCPT ); Fri, 21 Mar 2008 18:52:48 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1762773AbYCUWrN (ORCPT ); Fri, 21 Mar 2008 18:47:13 -0400 Received: from 216-99-217-87.dsl.aracnet.com ([216.99.217.87]:58950 "EHLO sous-sol.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762606AbYCUWrK (ORCPT ); Fri, 21 Mar 2008 18:47:10 -0400 Message-Id: <20080321224350.867706168@sous-sol.org> References: <20080321224250.144333319@sous-sol.org> User-Agent: quilt/0.46-1 Date: Fri, 21 Mar 2008 15:43:13 -0700 From: Chris Wright To: linux-kernel@vger.kernel.org, stable@kernel.org Cc: Justin Forbes , Zwane Mwaikambo , "Theodore Ts'o" , Randy Dunlap , Dave Jones , Chuck Wolber , Chris Wedgwood , Michael Krufky , Chuck Ebbert , Domenico Andreoli , torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, Herbert Xu , Joy Latten , Greg Kroah-Hartman Subject: [patch 23/76] CRYPTO xcbc: Fix crash with IPsec Content-Disposition: inline; filename=crypto-xcbc-fix-crash-with-ipsec.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1761 Lines: 56 -stable review patch. If anyone has any objections, please let us know. --------------------- From: Joy Latten [ Upstream commit: 2f40a178e70030c4712fe63807c883f34c3645eb ] When using aes-xcbc-mac for authentication in IPsec, the kernel crashes. It seems this algorithm doesn't account for the space IPsec may make in scatterlist for authtag. Thus when crypto_xcbc_digest_update2() gets called, nbytes may be less than sg[i].length. Since nbytes is an unsigned number, it wraps at the end of the loop allowing us to go back into loop and causing crash in memcpy. I used update function in digest.c to model this fix. Please let me know if it looks ok. Signed-off-by: Joy Latten Signed-off-by: Herbert Xu Signed-off-by: Chris Wright Signed-off-by: Greg Kroah-Hartman --- crypto/xcbc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/crypto/xcbc.c +++ b/crypto/xcbc.c @@ -124,6 +124,11 @@ static int crypto_xcbc_digest_update2(st unsigned int offset = sg[i].offset; unsigned int slen = sg[i].length; + if (unlikely(slen > nbytes)) + slen = nbytes; + + nbytes -= slen; + while (slen > 0) { unsigned int len = min(slen, ((unsigned int)(PAGE_SIZE)) - offset); char *p = crypto_kmap(pg, 0) + offset; @@ -177,7 +182,6 @@ static int crypto_xcbc_digest_update2(st offset = 0; pg++; } - nbytes-=sg[i].length; i++; } while (nbytes>0); -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/