upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/root_signature.cpp
diff options
context:
space:
mode:
authorsanuk369 <224479491+quackottu@users.noreply.github.com>2026-11-22 11:33:49 +0530
committersanuk369 <224479491+quackottu@users.noreply.github.com>2026-11-22 11:33:49 +0530
commit22465fa6b6e7bad805d1f7ee22eafa56369177ec (patch)
treeca738e8bc25f8864262ff8ee0a529c6bc8c9df73 /runtime/src/root_signature.cpp
parent43d470316ec6cbcd64002bc3792998d9f5745dac (diff)
rootsig::pack: 64-bit sums, so a huge constant count can't wrap past the limits
cost and dword_count + dwords were 32-bit. With {Constants 1, Constants 0xFFFFFFFF} both wrap to 0, so the 64-dword cost check and the 32-SGPR check pass and the loop writes past PackResult::dwords[32] (the test binary dies with 0xC0000409). parse_rts0 copies Num32BitValues from a blob unchecked, so a malformed RTS0 reaches this. Both sums are now 64-bit; root_signature_test gets the wrapping case.
Diffstat (limited to 'runtime/src/root_signature.cpp')
-rw-r--r--runtime/src/root_signature.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/runtime/src/root_signature.cpp b/runtime/src/root_signature.cpp
index 8aac0f554..762dd704e 100644
--- a/runtime/src/root_signature.cpp
+++ b/runtime/src/root_signature.cpp
@@ -11,7 +11,7 @@ PackResult pack(const RootSignature& sig) {
11 out.error = "root signature has more than 64 root parameters"; 11 out.error = "root signature has more than 64 root parameters";
12 return out; 12 return out;
13 } 13 }
14 uint32_t cost = 0; 14 uint64_t cost = 0; // 64-bit: a parameter of 0xFFFFFFFF constants must not wrap past the limits
15 for (const RootParameter& p : sig.params) { 15 for (const RootParameter& p : sig.params) {
16 if (p.type == ParamType::Constants && p.num_values == 0) { 16 if (p.type == ParamType::Constants && p.num_values == 0) {
17 out.error = "root constant parameter needs at least 1 dword"; 17 out.error = "root constant parameter needs at least 1 dword";
@@ -25,7 +25,7 @@ PackResult pack(const RootSignature& sig) {
25 out.error = "root signature exceeds the 64-dword D3D12 cost limit"; 25 out.error = "root signature exceeds the 64-dword D3D12 cost limit";
26 return out; 26 return out;
27 } 27 }
28 if (out.dword_count + dwords > kMaxUserSgprs) { 28 if (uint64_t(out.dword_count) + dwords > kMaxUserSgprs) {
29 // Spill layout is unknown (see __XB_GetRootSignatureSpillPointer): 29 // Spill layout is unknown (see __XB_GetRootSignatureSpillPointer):
30 // refuse loudly instead of silently truncating every draw. 30 // refuse loudly instead of silently truncating every draw.
31 out.error = "root signature needs more than 32 user SGPRs (spill unsupported)"; 31 out.error = "root signature needs more than 32 user SGPRs (spill unsupported)";
@@ -39,7 +39,7 @@ PackResult pack(const RootSignature& sig) {
39 ++out.dword_count; 39 ++out.dword_count;
40 } 40 }
41 } 41 }
42 out.d3d12_cost = cost; 42 out.d3d12_cost = static_cast<uint32_t>(cost); // <= kMaxD3d12Cost here
43 out.ok = true; 43 out.ok = true;
44 return out; 44 return out;
45} 45}