Skip to content

Commit 31e4e12

Browse files
zijun-hugregkh
authored andcommitted
software node: Correct a OOB check in software_node_get_reference_args()
software_node_get_reference_args() wants to get @index-th element, so the property value requires at least '(index + 1) * sizeof(*ref)' bytes but that can not be guaranteed by current OOB check, and may cause OOB for malformed property. Fix by using as OOB check '((index + 1) * sizeof(*ref) > prop->length)'. Reviewed-by: Sakari Ailus <[email protected]> Signed-off-by: Zijun Hu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f407a8a commit 31e4e12

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/base/swnode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode,
529529
if (prop->is_inline)
530530
return -EINVAL;
531531

532-
if (index * sizeof(*ref) >= prop->length)
532+
if ((index + 1) * sizeof(*ref) > prop->length)
533533
return -ENOENT;
534534

535535
ref_array = prop->pointer;

0 commit comments

Comments
 (0)