staging: gasket: Check the return value of gasket_get_bar_index()
PATCH 1/1 staging: gasket: Check the return value of gasket_get_bar_index()
Check the return value of gasket_get_bar_index function as it can return a negative one (-EINVAL). If this happens, a negative index is used in the "gasket_dev->bar_data" array.
Addresses-Coverity-ID: 1438542 ("Negative array index read")
--- drivers/staging/gasket/gasket_core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/staging/gasket/gasket_core.c +4 -0
@@ -925,6 +925,10 @@ do_map_region(const struct gasket_dev *gasket_dev, struct vm_area_struct *vma,gasket_get_bar_index (gasket_dev, (vma->vm_pgoff <<PAGE_SHIFT ) + driver_desc->legacy_mmap_address_offset); + +if (bar_index <0 ) +return DO_MAP_REGION_INVALID ; + phys_base = gasket_dev->bar_data[bar_index].phys_base + phys_offset;while (mapped_bytes < map_length) {/*
--
2.20.1
A message that is not in the archive (sent off-list or not yet received): CANJCoRvCUFkRuSSM0egkMuAd5+kzve4CWvhQ3KkppZBSM8PGkw@mail.gmail.com
Greg Kroah-Hartman
maintainerQuoted 1 line · Richard Yeh
Hi, as a new maintainer, I thought I would try to handle this one.
Great, as a start:
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
A: No.
Q: Should I include quotations after my reply?
http://daringfireball.net/2007/07/on_top
Quoted 6 lines
This patch looks good to me. This new check properly protects against using a negative return value from
gasket_get_bar_index()to index into a pointer. Thegasket_get_bar_indexfunction is called in two other places (old lines 845 and 1044) and both other places check thebar_indexreturn value for negative values and return error values.
Quoted 7 lines
What is the next step in the process? How do I test the patch? Does Greg K-H take these patches directly, or is there something else I should do (looking at
https://github.com/gregkh/presentation-linux-maintainer/blob/master/maintainer.pdf
page
5: clone from
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git, ...)?
Just send a "Reviewed-by:" to the patch and I can take it from there. Also, I strongly suggest going and talking to your co-maintainers for exactly how to do this, normally at this point in the process you already know this as it is usually an experienced developer doing the maintaining.
thanks,
greg k-h
Quoted 27 lines · Oscar Carter
Check the return value of
gasket_get_bar_indexfunction as it can return a negative one (-EINVAL). If this happens, a negative index is used in the "gasket_dev->bar_data" array.Addresses-Coverity-ID: 1438542 ("Negative array index read")
Fixes 9a69f5087ccc2 ("drivers/staging: Gasket driver framework + Apex driver")Signed-off-by Oscar Carter <[email protected]>--- drivers/staging/gasket/gasket_core.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/staging/gasket/gasket_core.c +4
-1@@ -925,6 +925,10 @@ do_map_region(const struct gasket_dev *gasket_dev, struct vm_area_struct *vma,gasket_get_bar_index (gasket_dev, (vma->vm_pgoff <<PAGE_SHIFT ) + driver_desc->legacy_mmap_address_offset); + +if (bar_index <0 ) +return DO_MAP_REGION_INVALID ; + phys_base = gasket_dev->bar_data[bar_index].phys_base + phys_offset;while (mapped_bytes < map_length) {/* --
Quoted 2 lines
2.20.1