Thread (24 messages) 24 messages, 7 authors, 2023-06-02

RE: [PATCH v5 1/2] lib/mpi: Fix buffer overrun when SG is too long

From: David Laight <hidden>
Date: 2022-12-31 13:23:29
Also in: keyrings, linux-crypto, linux-integrity, lkml, stable

From: Herbert Xu
Sent: 30 December 2022 15:40

On Fri, Dec 30, 2022 at 01:35:07PM +0000, David Laight wrote:
quoted
miter.length is size_t (unsigned long on 64bit) and nbytes unsigned int.
miter.length is bounded by sg->length which is unsigned int.
I did say 'technically' :-)

Should there be a sg_miter_stop() before the return at the bottom?
Care seems to have been taken to add one before an earlier error return.
(The logic in that function is very strange...)

Indeed other parts of the file are equally strange.
The big multi-line if-else in twocompl() is just:
	p[i] = (p[1] ^ 0xff) + 1;
or even:
	p[i] = -p[i];
That function could also return the 'zero status' to correct
for -0 (rather than the extra check earlier in the caller).

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help