net: atm: Spectre v1 fix introduced bug in bcb964012d1b in -stable
Subsystems (2)
In lecd_attach, if arg is < 0, it was treated as 0. Spectre v1 fix changed that. Bug does not exist in mainline AFAICT.
# for 4.19.y
net/atm/lec.c +1 -1
@@ -731,7 +731,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg) i = arg;if (arg >=MAX_LEC_ITF )return -EINVAL ; - i =array_index_nospec (arg,MAX_LEC_ITF ); + i =array_index_nospec (i,MAX_LEC_ITF );if (!dev_lec[i]) {int size;
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 12 lines · Pavel Machek
In
lecd_attach, if arg is < 0, it was treated as 0. Spectre v1 fix changed that. Bug does not exist in mainline AFAICT.Signed-off-by Pavel Machek <[email protected]># for 4.19.ynet/atm/lec.c +0
-0
net/atm/lec.c static int lecd_attach(struct atm_vcc *vcc, int arg) · line 737
Quoted 8 lines
net/atm/lec.c +1
-1@@ -731,7 +731,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg) i = arg;if (arg >=MAX_LEC_ITF )return -EINVAL ; - i =array_index_nospec (arg,MAX_LEC_ITF ); + i =array_index_nospec (i,MAX_LEC_ITF );if (!dev_lec[i]) {int size;
Why is this only for 4.19.y? What is different in Linus's tree that makes this not needed there?
thanks,
greg k-h
Quoted 4 lines · Pavel Machek
In
lecd_attach, if arg is < 0, it was treated as 0. Spectre v1 fix changed that. Bug does not exist in mainline AFAICT.
NACK
array_index_nospec() macro returns zero if *arg* is out of bounds.
In any case, if the "bug" does not exist in mainline, what should be done is to port the code that fixed it in mainline to old kernels, not randomly add a "fix" here and there because that means we are breaking backward compatibility.
--
Gustavo
Quoted 17 lines
Signed-off-by Pavel Machek <[email protected]># for 4.19.ynet/atm/lec.c +1
-1@@ -731,7 +731,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg) i = arg;if (arg >=MAX_LEC_ITF )return -EINVAL ; - i =array_index_nospec (arg,MAX_LEC_ITF ); + i =array_index_nospec (i,MAX_LEC_ITF );if (!dev_lec[i]) {int size;
Quoted 8 lines · Greg KH
Quoted 7 lines · Pavel Machek
In
lecd_attach, if arg is < 0, it was treated as 0. Spectre v1 fix changed that. Bug does not exist in mainline AFAICT.Signed-off-by Pavel Machek <[email protected]># for 4.19.y
Quoted 17 lines
net/atm/lec.c static int lecd_attach(struct atm_vcc *vcc, int arg) · line 737
Quoted 13 lines
net/atm/lec.c +1
-1@@ -731,7 +731,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg) i = arg;if (arg >=MAX_LEC_ITF )return -EINVAL ; - i =array_index_nospec (arg,MAX_LEC_ITF ); + i =array_index_nospec (i,MAX_LEC_ITF );if (!dev_lec[i]) {int size;Why is this only for 4.19.y? What is different in Linus's tree that makes this not needed there?
The only difference is this clean up:
As Dan says, the code works fine, but the *i* value wasn't being used anymore, so that piece of code was a bit confusing.
Thanks
--
Gustavo
Quoted 8 lines · Greg KH
Quoted 7 lines · Pavel Machek
In
lecd_attach, if arg is < 0, it was treated as 0. Spectre v1 fix changed that. Bug does not exist in mainline AFAICT.Signed-off-by Pavel Machek <[email protected]># for 4.19.y
Quoted 16 lines
net/atm/lec.c static int lecd_attach(struct atm_vcc *vcc, int arg) · line 737
Quoted 13 lines
net/atm/lec.c +1
-1@@ -731,7 +731,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg) i = arg;if (arg >=MAX_LEC_ITF )return -EINVAL ; - i =array_index_nospec (arg,MAX_LEC_ITF ); + i =array_index_nospec (i,MAX_LEC_ITF );if (!dev_lec[i]) {int size;Why is this only for 4.19.y? What is different in Linus's tree that makes this not needed there?
Mainline sanitizes "arg", 4.19 copies "arg" into "i" then sanitizes it. Take a look, it is local to the function.
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Quoted 11 lines · Gustavo A. R. Silva
Quoted 4 lines · Pavel Machek
In
lecd_attach, if arg is < 0, it was treated as 0. Spectre v1 fix changed that. Bug does not exist in mainline AFAICT.NACK
array_index_nospec()macro returns zero if *arg* is out of bounds.
No, it does not. Take a look:
#define array_index_nospec(index, size)
...
(typeof(_i)) (_i & _mask); })
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Quoted 11 lines · Pavel Machek
Quoted 10 lines · Gustavo A. R. Silva
Quoted 4 lines · Pavel Machek
In
lecd_attach, if arg is < 0, it was treated as 0. Spectre v1 fix changed that. Bug does not exist in mainline AFAICT.NACK
Quoted 9 lines
Quoted 1 line
array_index_nospec()macro returns zero if *arg* is out of bounds.No, it does not. Take a look:
#define
array_index_nospec(index, size)
...(typeof(_i)) (_i & _mask); })
Tell me more about that _mask.
Also, don't ignore the backward compatibility; otherwise you would be forking your own kernel.
--
Gustavo
Quoted 29 lines · Gustavo A. R. Silva
Quoted 8 lines · Greg KH
Quoted 7 lines · Pavel Machek
In
lecd_attach, if arg is < 0, it was treated as 0. Spectre v1 fix changed that. Bug does not exist in mainline AFAICT.Signed-off-by Pavel Machek <[email protected]># for 4.19.yQuoted 17 lines
net/atm/lec.c static int lecd_attach(struct atm_vcc *vcc, int arg) · line 737
Quoted 13 lines
net/atm/lec.c +1
-1@@ -731,7 +731,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg) i = arg;if (arg >=MAX_LEC_ITF )return -EINVAL ; - i =array_index_nospec (arg,MAX_LEC_ITF ); + i =array_index_nospec (i,MAX_LEC_ITF );if (!dev_lec[i]) {int size;Why is this only for 4.19.y? What is different in Linus's tree that makes this not needed there?
Quoted 6 lines
The only difference is this clean up:
As Dan says, the code works fine, but the *i* value wasn't being used anymore, so that piece of code was a bit confusing.
Yep, you are right, code managed to confused me: array_index_nospec really returns 0 if it is out of bounds,
(typeof(_i)) (_i & _mask);
because _mask is always 0 or ~0.
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany