Bug 27828

Summary: memmove doesn't work with tagged address
Product: glibc Reporter: H.J. Lu <hjl.tools>
Component: stringAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED OBSOLETE    
Severity: normal CC: carlos, fweimer
Priority: P2    
Version: 2.34   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description H.J. Lu 2021-05-06 21:02:40 UTC
string/memmove.c has

rettype
inhibit_loop_to_libcall
MEMMOVE (a1const void *a1, a2const void *a2, size_t len)
{
  unsigned long int dstp = (long int) dest;
  unsigned long int srcp = (long int) src;

  /* This test makes the forward copying code be used whenever possible.
     Reduces the working set.  */
  if (dstp - srcp >= len)	/* *Unsigned* compare!  */
      ^^^^^^^^^^^^  This doesn't work with tagged address.
    {
      ...
    }

Processor specific memmove may have the same issue.

sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:

247 L(start_movsb):
248         mov     %RDX_LP, %RCX_LP
249         cmp     %RSI_LP, %RDI_LP
            ^^^^^^^^^^^^^^^^^^^^^^^^ This has the same issue.
250         jb      1f
Comment 1 H.J. Lu 2021-09-17 17:08:40 UTC
Overlapping pointers should have the same tag.