Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/vkms: __nocfi indirect call to CFI function in
  show_bitfield()
- [Low] drm/vkms: shift-out-of-bounds in show_bitfield() loop condition
--

commit d7f3545cf9bb01180602070fd069bfa2db6fb425
Author: Louis Chauvet <[email protected]>

drm/vkms: Introduce config for plane color encoding

This commit adds configuration helpers, validation, debugfs reporting, and
KUnit tests to configure supported and default color encodings per VKMS
plane.

> diff --git a/drivers/gpu/drm/vkms/vkms_config.c 
> b/drivers/gpu/drm/vkms/vkms_config.c
> index d4f15f1c53b06..90cc28f3d3860 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.c
> +++ b/drivers/gpu/drm/vkms/vkms_config.c
[ ... ]
> @@ -402,6 +424,22 @@ bool vkms_config_is_valid(const struct vkms_config 
> *config)
>  }
>  EXPORT_SYMBOL_IF_KUNIT(vkms_config_is_valid);
>  
> +static __nocfi void show_bitfield(struct seq_file *m, uint32_t value, const 
> char *callback(unsigned int))
> +{
> +     u32 offset = 0;
> +     bool first = true;
> +
> +     while (value >= BIT(offset) && offset < 32) {

[Severity: Low]
Does this loop condition evaluate BIT(offset) before checking offset < 32?
On 32-bit architectures, if bit 31 is set in value, offset reaches 32 and
BIT(32) shifts out of bounds; on 64-bit architectures, BIT(32) exceeds
any uint32_t value, making offset < 32 dead code.

> +             if (value & BIT(offset)) {
> +                     if (!first)
> +                             seq_puts(m, ",");
> +                     seq_printf(m, "%s", callback(offset));
> +                     first = false;
> +             }
> +             offset += 1;
> +     }
> +}
> +
>  static int vkms_config_show(struct seq_file *m, void *data)
>  {
[ ... ]
> @@ -436,6 +474,12 @@ static int vkms_config_show(struct seq_file *m, void 
> *data)
>                                  
> DRM_ROTATION_FMT_ARGS(vkms_config_plane_get_supported_rotations(plane_cfg)));
>                       seq_printf(m, "\tdefault rotation=" DRM_ROTATION_FMT 
> "\n",
>                                  
> DRM_ROTATION_FMT_ARGS(vkms_config_plane_get_default_rotation(plane_cfg)));
> +                     seq_puts(m, "\tsupported color encoding=");
> +                     show_bitfield(m, 
> vkms_config_plane_get_supported_color_encodings(plane_cfg),
> +                                   drm_get_color_encoding_name);

[Severity: Medium]
Can calling drm_get_color_encoding_name() indirectly from the __nocfi
show_bitfield() helper fault under FineIBT?

drm_get_color_encoding_name() takes enum drm_color_encoding rather than
unsigned int, and marking show_bitfield() __nocfi suppresses the kCFI type
hash check on callback(offset).  On x86_64 with CONFIG_CFI_CLANG=y, this
triggers an objtool "no-cfi indirect call!" warning at build time, and
under FineIBT at runtime cfi_rewrite_endbr() poisons the endbr64 at
drm_get_color_encoding_name+0 while skipping the uninstrumented __nocfi
call site, causing a #CP (Missing ENDBR) kernel fault when reading the
vkms_config debugfs file.

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

Reply via email to