[CBR 7.9] media: technisat-usb2: break out of loop at end of buffer #428
+10
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[CBR 7.9]
CVE-2019-15505
VULN-7734
Problem
https://www.cve.org/CVERecord?id=CVE-2019-15505
More concrete info about the issue in the fixing commit 0c4df39:
Applicability: yes
The driver is enabled in
configs/kernel-3.10.0-x86_64.config
kernel-src-tree/configs/kernel-3.10.0-x86_64.config
Line 3808 in 3f2bd20
Moreover, the affected function
technisat_usb2_get_ir
from https://github.com/ctrliq/kernel-src-tree/blob/ciqcbr7_9/drivers/media/usb/dvb-usb/technisat-usb2.c clearly doesn't contain any boundary check forb
, relying instead solely on the*b == 0xff
condition to break the loop:kernel-src-tree/drivers/media/usb/dvb-usb/technisat-usb2.c
Lines 640 to 652 in 3f2bd20
Solution
The essence of mainline solution 0c4df39 can be captured in the following points:
b
to indexing a constant pointerbuf
pointing at the beginning of the buffer, and introducing the necessary for that indexi
.while(1)
with afor
loop controlling the increments ofi
and its upper bound - the size of the buffer.0xff
value starts from thebuf + 1
element instead ofbuf + 2
.Breaking down the change in such way is necessary to apply the patch correctly as the
ciqcbr7_9
codebase misses the 5d0f2df commit on which the mainline fix 0c4df39 is based: there is nod->priv->buf
to operate on. The proposed fix preserves all 3 modifications with the buffer located on stack, in the localbuf
array, instead ofd->priv->buf
.Notes:
ARRAY_SIZE
macro works forbuf
inciqcbr7_9
just as it works forstate->buf
in the mainline - both arrays are defined as staticciqcbr7_9
kernel-src-tree/drivers/media/usb/dvb-usb/technisat-usb2.c
Line 594 in 3f2bd20
kernel-mainline
kernel-src-tree/drivers/media/usb/dvb-usb/technisat-usb2.c
Line 59 in 6832a93
ciqcbr7_9
and in the mainline -62
vs64
- so the proposed fix is not 100% functionally equivalent to 0c4df39. However, if the size62
was appropriate for the driver inciqcbr7_9
so far then it should be preserved - the CVE-2019-15505 bug and its patch aren't concerned with the buffer sizes but with their checking.kABI check: passed
Boot test: passed
boot-test.log
Kselftests: passed relative
Reference
kselftests–ciqcbr7_9–run1.log
kselftests–ciqcbr7_9–run2.log
kselftests–ciqcbr7_9–run3.log
Patch
kselftests–ciqcbr7_9-CVE-2019-15505–run1.log
kselftests–ciqcbr7_9-CVE-2019-15505–run2.log
kselftests–ciqcbr7_9-CVE-2019-15505–run3.log
Comparison
The results were compared manually with Meld. No changes indicative of some newly introduced malfunctions were found.
Specific tests: skipped