public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/100665] New: [hwsanitizer] nested funtion pointer is tagged but never checked.
@ 2021-05-19  5:43 crazylht at gmail dot com
  2021-05-27 15:07 ` [Bug sanitizer/100665] " matmal01 at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: crazylht at gmail dot com @ 2021-05-19  5:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100665

            Bug ID: 100665
           Summary: [hwsanitizer] nested funtion pointer is tagged but
                    never checked.
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    hjl.tools at gmail dot com, jakub at gcc dot gnu.org,
                    kcc at gcc dot gnu.org, marxin at gcc dot gnu.org,
                    matmal01 at gcc dot gnu.org
  Target Milestone: ---

testcase is gcc/testsuite/gcc.dg/hwasan/nested-functions-0.c

__attribute__((noinline))
int *Ident(void *x) {
  return x;
}

int __attribute__ ((noinline))
intermediate (void (*f) (int, char),
              char num)
{
  if (num == 1)
    /* NOTE: We need to overrun by an amount greater than the "extra data" in a
       nonlocal goto structure.  The entire structure is allocated on the stack
       with a single tag, which means hwasan can't tell if a closed-over buffer
       was overrun by an amount small enough that the access was still to some
       data in that nonlocal goto structure.  */
    f (100, 100);
  else
    f (3, 100);
  /* Just return something ... */
  return num % 3;
}

int* __attribute__ ((noinline))
nested_function (char num)
{
  int big_array[16];
  int other_array[16];
  void store (int index, char value)
    { big_array[index] = value; }
  return Ident(&other_array[intermediate (store, num)]);
}

#ifndef MAIN
int main ()
{
  nested_function (0);
  return 0;
}
#endif


nest function store is defined and resides one the stack of nested_function,
function pointer of store will be tagged since hwasan thought it was stack
variable, but since there's no explicit load for the function pointer, the tag
is never checked, so i wonder, is hwasan supposed to tag the function pointer?

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-01  9:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19  5:43 [Bug sanitizer/100665] New: [hwsanitizer] nested funtion pointer is tagged but never checked crazylht at gmail dot com
2021-05-27 15:07 ` [Bug sanitizer/100665] " matmal01 at gcc dot gnu.org
2021-06-01  2:56 ` crazylht at gmail dot com
2021-06-01  9:53 ` matmal01 at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).