Skip to content

Random small fixes in preparation for full kbuild support#1068

Open
minipli-oss wants to merge 10 commits intoNVIDIA:mainfrom
minipli-oss:fixes
Open

Random small fixes in preparation for full kbuild support#1068
minipli-oss wants to merge 10 commits intoNVIDIA:mainfrom
minipli-oss:fixes

Conversation

@minipli-oss
Copy link

Various small fixes in preparation for building all sources with Linux's kbuild with the ultimate goal of supporting features like RANDSTRUCT, kCFI and grsecurity kernel features like RAP, KERNEXEC, CONSTIFY,...

The return type is expected to be 'enum drm_mode_status', fix that.

Signed-off-by: Mathias Krause <minipli@grsecurity.net>
nvswitch_task_dispatch() is supposed to be of type nv_q_func_t which
expects a void pointer argument.

Fix that to make it compatible with strongly type-based CFI
implementations like RAP, as found in grsecurity.

Signed-off-by: Mathias Krause <minipli@grsecurity.net>
The retun type should be 'void' as all users of tmrCtrlCmdEventCreate()
pass a 'void (*)(void *)' function pointer.

Signed-off-by: Mathias Krause <minipli@grsecurity.net>
gcc warns about the use of the wrong enum type, fix that!

  .../src/nvidia/src/kernel/gpu/mem_mgr/arch/maxwell/virt_mem_allocator_gm107.c:1720:76: warning: implicit conversion from ‘GMMU_APERTURE’ to ‘FB_CACHE_MEMTYPE’ [-Wenum-conversion]
   1720 |         kmemsysCacheOp_HAL(pGpu, GPU_GET_KERNEL_MEMORY_SYSTEM(pGpu), NULL, aperture, FB_CACHE_INVALIDATE);
        |                                                                            ^~~~~~~~
  .../src/nvidia/generated/g_kern_mem_sys_nvoc.h:632:135: note: in definition of macro ‘kmemsysCacheOp_HAL’
    632 | #define kmemsysCacheOp_HAL(pGpu, pKernelMemorySystem, arg3, arg4, operation) kmemsysCacheOp_DISPATCH(pGpu, pKernelMemorySystem, arg3, arg4, operation)
        |                                                                                                                                       ^~~~
Signed-off-by: Mathias Krause <minipli@grsecurity.net>
In case tmrEventCreate() fails, we will copy the uninitialized value of
the stack local variable 'pEvent' and expose it to the caller.

Prevent that by initializing it to NULL, as all other users do.

Signed-off-by: Mathias Krause <minipli@grsecurity.net>
Targets added to 'clean-files' shouldn't have the '$(obj)/' prefix or
won't be found for the 'make clean' target.

Fix that to ensure 'nv_compiler.h' will be removed on 'make clean'.

Signed-off-by: Mathias Krause <minipli@grsecurity.net>
The drm_connector_helper_funcs.mode_valid() hook is expected to return a
'enum drm_mode_status' since Linux commit 0993f1d0d8a1 ("drm: Make the
connector mode_valid() func return a drm_mode_status enum") merged in
v3.14.

Add a conftest test for it to fix that without breaking older kernels.

The test is slightly evolved as C considers mismatched enum vs. int
return types as compatible but they still violate CFI checks for
advanced implementations like RAP as found in grsecurity.

Signed-off-by: Mathias Krause <minipli@grsecurity.net>
There is no need to initialize 'g_exported_uvm_events' at runtime,
initialize at compile time.

Signed-off-by: Mathias Krause <minipli@grsecurity.net>
Actual implementations of the NVEvoSubDevRec.scanLockState hook want an
'NVEvoLockAction'-typed 'action' argument. Fix that.

Signed-off-by: Mathias Krause <minipli@grsecurity.net>
Test the kernel for having RANDSTRUCT enabled and break the build, if it
is as this would otherwise lead to ABI-incompatibilities with the
OS-agnostic part that doesn't get compiled with RANDSTRCUT enabled.

A visible outcome of this would be calling the wrong callback function
via structures that purely consist of function pointers (which
RANDSTRUCT randomizes).

Signed-off-by: Mathias Krause <minipli@grsecurity.net>
@CLAassistant
Copy link

CLAassistant commented Mar 19, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants