From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: drm/amdkfd: stop speculation on the kfd_ioctl path Date: Wed, 25 Mar 2026 06:37:21 +1000 Message-ID: In-Reply-To: <2026032408-divided-racing-fe78@gregkh> References: <2026032408-divided-racing-fe78@gregkh> <2026032408-divided-racing-fe78@gregkh> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review **Correctness: Good, with one minor observation** The bounds check at line 3345 (`nr >=3D AMDKFD_CORE_IOCTL_COUNT`) provides = the architectural bounds check, and the `array_index_nospec()` at line 3353= provides the speculation barrier. This is the correct pattern. However, there's a subtle point worth noting. The bounds check at line 3345: ```c if (nr >=3D AMDKFD_CORE_IOCTL_COUNT) { retcode =3D -ENOTTY; goto err_i1; } ``` checks against `AMDKFD_CORE_IOCTL_COUNT` (the full array size), while the s= ubsequent check at line 3350: ```c if ((nr >=3D AMDKFD_COMMAND_START) && (nr < AMDKFD_COMMAND_END)) { ``` further narrows the valid range to `[AMDKFD_COMMAND_START, AMDKFD_COMMAND_E= ND)` i.e. `[0x01, 0x28)`. The `array_index_nospec(nr, AMDKFD_CORE_IOCTL_COU= NT)` at line 3353 clamps to the full array size, which is correct since the= array is indexed by ioctl number using designated initializers (`[_IOC_NR(= ioctl)] =3D ...`). Using `AMDKFD_CORE_IOCTL_COUNT` as the bound is the righ= t choice here =E2=80=94 it matches the actual array size, and out-of-range = entries within the array simply have `.func =3D NULL` which is handled late= r. **Placement consideration:** The `array_index_nospec()` call is placed insi= de the `if ((nr >=3D AMDKFD_COMMAND_START) && (nr < AMDKFD_COMMAND_END))` b= lock. This is fine because the only array dereference (`&amdkfd_ioctls[nr]`= ) occurs within this block. The earlier bounds check at line 3345 ensures t= he architectural path is safe, and the nospec call handles the speculative = path. **Include:** The `` addition is correctly placed in alphabe= tical order. **Cc: stable** tag is appropriate =E2=80=94 this is a security hardening fi= x. **Nit:** The `Assisted-by: gkh_clanker_2000` tag is unconventional. Typical= ly AI/tool assistance is noted with a more descriptive tag or in the commit= message body, but this is a process/policy matter, not a code issue. **Verdict: Patch looks good.** No functional issues. --- Generated by Claude Code Patch Reviewer