[patch 13/16] CRYPTO: api: Fix scatterwalk_sg_chain

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Greg KH
Date: Thursday, May 8, 2008 - 10:42 am

2.6.25-stable review patch.  If anyone has any objections, please let us
know.

------------------
From: Herbert Xu <herbert@gondor.apana.org.au>

[CRYPTO] api: Fix scatterwalk_sg_chain

[ Upstream commit: 8ec970d8561abb5645d4602433b772e268c96d05 ]

When I backed out of using the generic sg chaining (as it isn't currently
portable) and introduced scatterwalk_sg_chain/scatterwalk_sg_next I left
out the sg_is_last check in the latter.  This causes it to potentially
dereference beyond the end of the sg array.

As most uses of scatterwalk_sg_next are bound by an overall length, this
only affected the chaining code in authenc and eseqiv. Thanks to Patrick
McHardy for identifying this problem.

This patch also clears the "last" bit on the head of the chained list as
it's no longer last.  This also went missing in scatterwalk_sg_chain and
is present in sg_chain.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


---
 include/crypto/scatterwalk.h |    4 ++++
 1 file changed, 4 insertions(+)

--- a/include/crypto/scatterwalk.h
+++ b/include/crypto/scatterwalk.h
@@ -57,10 +57,14 @@ static inline void scatterwalk_sg_chain(
 					struct scatterlist *sg2)
 {
 	sg_set_page(&sg1[num - 1], (void *)sg2, 0, 0);
+	sg1[num - 1].page_link &= ~0x02;
 }
 
 static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg)
 {
+	if (sg_is_last(sg))
+		return NULL;
+
 	return (++sg)->length ? sg : (void *)sg_page(sg);
 }
 

-- 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 00/16] Linux 2.6.25 -stable review, Greg KH, (Thu May 8, 10:41 am)
[patch 02/16] mm: fix usemap initialization, Greg KH, (Thu May 8, 10:41 am)
[patch 08/16] b43: Fix dual-PHY devices, Greg KH, (Thu May 8, 10:42 am)
[patch 11/16] b43: Fix some TX/RX locking issues, Greg KH, (Thu May 8, 10:42 am)
[patch 12/16] x86 PCI: call dmi_check_pciprobe(), Greg KH, (Thu May 8, 10:42 am)
[patch 13/16] CRYPTO: api: Fix scatterwalk_sg_chain, Greg KH, (Thu May 8, 10:42 am)
Re: [patch 00/16] Linux 2.6.25 -stable review, Willy Tarreau, (Thu May 8, 10:51 am)
Re: [patch 00/16] Linux 2.6.25 -stable review, Willy Tarreau, (Thu May 8, 11:13 am)
Re: [patch 00/16] Linux 2.6.25 -stable review, Greg KH, (Thu May 8, 11:20 am)
Re: [patch 00/16] Linux 2.6.25 -stable review, Greg KH, (Thu May 8, 11:22 am)
Re: [patch 00/16] Linux 2.6.25 -stable review, Greg KH, (Thu May 8, 11:25 am)
Re: [patch 00/16] Linux 2.6.25 -stable review, Willy Tarreau, (Thu May 8, 11:33 am)
Re: [patch 00/16] Linux 2.6.25 -stable review, Len Brown, (Thu May 8, 12:16 pm)
Re: [patch 08/16] b43: Fix dual-PHY devices, John W. Linville, (Thu May 8, 12:38 pm)
Re: [patch 00/16] Linux 2.6.25 -stable review, Greg KH, (Thu May 8, 12:43 pm)
Re: [patch 11/16] b43: Fix some TX/RX locking issues, John W. Linville, (Thu May 8, 1:04 pm)
Re: [patch 00/16] Linux 2.6.25 -stable review, Li Zefan, (Thu May 8, 5:51 pm)