public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: Jakub Jelinek <jakub@redhat.com>, Matthias Klose <doko@ubuntu.com>
Cc: gcc Development <gcc@gcc.gnu.org>
Subject: Re: libsanitizer in GCC 10 is dropping symbols without bumping the soversions
Date: Fri, 29 Nov 2019 12:07:00 -0000	[thread overview]
Message-ID: <98b2f626-324d-405d-add2-c45f2324c174@suse.cz> (raw)
In-Reply-To: <20191129114752.GK10088@tucnak>

On 11/29/19 12:47 PM, Jakub Jelinek wrote:
> __ubsan_handle_function_type_mismatch* is something we don't use (Martin,
> should we add such sanitizer?  We have gimple_call_fntype vs. actual decl
> types, but it would need some inspection on what the sanitizer really does),
> but still e.g. clang compiled binaries could and could be (at least in
> theory) be linked against gcc libubsan.

Yes, we can add it for GCC 11. The sanitizer is about:

$ cat indirect.C
int foo(int a)
{
   return a;
}

void bar(int (*fn) (void))
{
   fn();
}

int main()
{
   bar(reinterpret_cast<int (*)(void)> (foo));
}

$ clang++ indirect.C -fsanitize=function && ./a.out
indirect.C:8:3: runtime error: call to function foo(int) through pointer to incorrect function type 'int (*)()'
(/tmp/a.out+0x424c60): note: foo(int) defined here
     #0 0x424cfb in bar(int (*)()) (/tmp/a.out+0x424cfb)
     #1 0x424d2d in main (/tmp/a.out+0x424d2d)
     #2 0x7f2e8bbfee0a in __libc_start_main /usr/src/debug/glibc-2.30-1.2.x86_64/csu/../csu/libc-start.c:308:16
     #3 0x403309 in _start /home/abuild/rpmbuild/BUILD/glibc-2.30/csu/../sysdeps/x86_64/start.S:120

static bool handleFunctionTypeMismatch(FunctionTypeMismatchData *Data,
                                        ValueHandle Function,
                                        ValueHandle calleeRTTI,
                                        ValueHandle fnRTTI, ReportOptions Opts) {
   if (checkTypeInfoEquality(reinterpret_cast<void *>(calleeRTTI),
                             reinterpret_cast<void *>(fnRTTI)))
     return false;

So it should be quite trivial as we're already using checkTypeInfoEquality in
bool __ubsan::checkDynamicType(void *Object, void *Type, HashValue Hash) {

Martin




      reply	other threads:[~2019-11-29 12:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-29 11:28 Matthias Klose
2019-11-29 11:33 ` Martin Liška
2019-11-29 11:48 ` Jakub Jelinek
2019-11-29 12:07   ` Martin Liška [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=98b2f626-324d-405d-add2-c45f2324c174@suse.cz \
    --to=mliska@suse.cz \
    --cc=doko@ubuntu.com \
    --cc=gcc@gcc.gnu.org \
    --cc=jakub@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).