Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] Validation of the 64-bit `supported_fm` mask uses the 32-bit `BIT()` 
macro, causing invalid bits in the upper 32 bits to silently bypass validation 
on 32-bit architectures.
--

--- Patch [1]: [v5 01/14] drm/colorop: Add DRM_COLOROP_FIXED_MATRIX ---
commit 25b997b331b57b2649988bc81ff156f876274b02
Author: Chaitanya Kumar Borah <[email protected]>

drm/colorop: Add DRM_COLOROP_FIXED_MATRIX

Introduce DRM_COLOROP_FIXED_MATRIX, a new colorop type representing a
hardware that performs a fixed matrix operation. Userspace selects one of
the predefined hardware modes via a new FIXED_MATRIX_TYPE enum property.

> diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c
> index 682fcc6515259..483defad699c0 100644
> --- a/drivers/gpu/drm/drm_colorop.c
> +++ b/drivers/gpu/drm/drm_colorop.c
[ ... ]
> @@ -453,6 +462,80 @@ int drm_plane_colorop_3dlut_init(struct drm_device *dev, 
> struct drm_colorop *col
[ ... ]
> +int drm_plane_colorop_fixed_matrix_init(struct drm_device *dev, struct 
> drm_colorop *colorop,
> +                                     struct drm_plane *plane,
> +                                     const struct drm_colorop_funcs *funcs,
> +                                     u64 supported_fm, uint32_t flags)
> +{
> +     struct drm_prop_enum_list enum_list[DRM_COLOROP_FM_COUNT];
> +     int i, len;
> +     struct drm_property *prop;
> +     int ret;
> +
> +     if (!supported_fm) {
> +             drm_err(dev,
> +                     "No supported FM type op for new Fixed Matrix colorop 
> on [PLANE:%d:%s]\n",
> +                     plane->base.id, plane->name);
> +             return -EINVAL;
> +     }
> +
> +     if ((supported_fm & -BIT(DRM_COLOROP_FM_COUNT)) != 0) {

[Severity: Medium]
Since supported_fm is a u64, could using the 32-bit BIT() macro here cause
validation issues on 32-bit architectures?

On 32-bit architectures, BIT() evaluates to an unsigned long (32 bits). When
negated and then promoted to u64 for the bitwise AND with supported_fm, it
zero-extends the upper 32 bits (e.g., 0x00000000FFFFFFE0ULL). This means any
invalid bits set in the upper 32 bits of supported_fm would be zeroed out
during the operation and silently bypass this validation check.

Would it be better to use BIT_ULL(DRM_COLOROP_FM_COUNT) or GENMASK_ULL to
ensure the mask is properly validated across its entire 64-bit range?

> +             drm_err(dev, "Unknown Fixed Matrix provided on [PLANE:%d:%s]\n",
> +                     plane->base.id, plane->name);
> +             return -EINVAL;
> +     }

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to