oneapi-src / oneapi-src/unified-runtime

Parameter validation layer does not account for extended enums

Open
#1,779 1 comment 0 reactions 1 assignee View on GitHub

@callumfare is already working on this.

Since Jul 3, 2024.

bug loader
Dominant language
C++
Stars
57
Forks
120
Avg merge
1d 14h
Merged PRs (30d)
1

Description

Validation of ur_mem_type_t, which is extended by the experimental bindless images feature, does not correctly validate the extended enumeration UR_MEM_TYPE_IMAGE_CUBEMAP_EXP.

        if (pImageDesc && UR_MEM_TYPE_IMAGE1D_ARRAY < pImageDesc->type) {
            return UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR;
        }
typedef enum ur_mem_type_t {
    UR_MEM_TYPE_IMAGE2D = 0,                ///< 2D image object
    UR_MEM_TYPE_IMAGE3D = 1,                ///< 3D image object
    UR_MEM_TYPE_IMAGE2D_ARRAY = 2,          ///< 2D image array object
    UR_MEM_TYPE_IMAGE1D = 3,                ///< 1D image object
    UR_MEM_TYPE_IMAGE1D_ARRAY = 4,          ///< 1D image array object
    UR_MEM_TYPE_IMAGE_CUBEMAP_EXP = 0x2000, ///< Experimental cubemap image object
    /// @cond
    UR_MEM_TYPE_FORCE_UINT32 = 0x7fffffff
    /// @endcond

} ur_mem_type_t;

This results in valid usage of the bindless images entry points which take a ur_mem_type_t returning the UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR erroneously.

Given the gap in valid values, validation should instead look like this:

        if (pImageDesc) {
            switch (pImageDesc->type) {
            case UR_MEM_TYPE_IMAGE2D:
            case UR_MEM_TYPE_IMAGE3D:
            case UR_MEM_TYPE_IMAGE2D_ARRAY:
            case UR_MEM_TYPE_IMAGE1D:
            case UR_MEM_TYPE_IMAGE1D_ARRAY:
            case UR_MEM_TYPE_IMAGE2D:
            case UR_MEM_TYPE_IMAGE_CUBEMAP_EXP:
                break;
            default:
                return UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR;
            }
        }

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.