[PATCH 1/5] x86_64: Extend 32-bit syscall arguments to the full register (BZ 34917)

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Fri Nov 6 14:00:15 GMT 2026



On 06/11/26 10:33, Florian Weimer wrote:
> * Adhemerval Zanella Netto:
> 
>> Would you be ok with the patch with both fixed?
> 
> I can review the compiler barrier.
> 
> Apparently, the new code isn't used on x32, and it looks good for
> 64-bit.
> 
> Thanks,
> Florian

It is:

+/* Return V with garbage in the upper 32 bits.  The asm hides the value from
+   the compiler, which could otherwise drop the upper bits because the
+   call_* functions only use the lower 32 bits.  */
+#define DIRTY(v)                                                       \
+  ({                                                                   \
+    uint64_t __dirty = ((uint64_t) (unsigned int) (v)                  \
+                       | UINT64_C (0xdeadbeef00000000));               \
+    asm ("" : "+r" (__dirty));                                         \
+    __dirty;                                                           \
+  })
+
+/* Check that DIRTY, a call with garbage in the upper bits of its 32-bit
+   arguments, returns the same value and errno as CLEAN.  This is for
+   calls whose outcome depends on the system, such as kernel support or
+   a seccomp filter.  */
+#define COMPARE_CALLS(clean, dirty)                                    \
+  do                                                                   \
+    {                                                                  \
+      errno = 0;                                                       \
+      long int ret = (clean);                                          \
+      int err = errno;                                                 \
+      errno = 0;                                                       \
+      long int dret = (dirty);                                         \
+      int derr = errno;                                                        \
+      if (dret != ret || derr != err)                                  \
+       FAIL ("%s: returned %ld (errno %d), expected %ld (errno %d)",   \
+             #dirty, dret, derr, ret, err);                            \
+    }                                                                  \
+  while (0)

I created a branch to avoid reposting this series again [1].

[1] https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/azanella/bz34917-mprotect


More information about the Libc-alpha mailing list