Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-23491

__bss_start breaks compilation of various platforms

Details

    Description

      when printing various strings from a SIGSEGV handler, stacktrace.c uses various tricks to make sure the pointer to a string is valid and can be resolved.

      It particular it reads /proc/self/task/%d/mem map and checks the pointer against the __bss_start address. Getting this __bss_start is a very fragile piece of code and it breaks linking on various linux versions depending on what libraries are linked and what compiler/binutil version is used.

      But this is all completely unnecessary, because the string is directly printed using kernel syscall write() — and kernel validates all user space pointers anyway. We should remove all pointer checks and just let the kernel vet them as it always does.

      Note that on other OSes stacktrace.c does not validate any pointers (neither via proc map nor against __bss_start). User space pointer validation is Linux-only and completely redundant.

      The trick is not to resolve the pointer before write(). In particular, at least one function does isprint(*c) — this should be removed. It doesn't add much, the crash information is printed to a log, not to a terminal, so we don't have to filter out control codes.

      Attachments

        Issue Links

          Activity

            sanja Oleksandr Byelkin added a comment - - edited

            commit eaf707984683b2ab4b5e35c5b598b23fd24c4c09 (HEAD -> bb-10.1-release, origin/bb-10.1-release)
            Author: Oleksandr Byelkin <sanja@mariadb.com>
            Date: Sun Aug 16 22:14:59 2020 +0200

            MDEV-23491: __bss_start breaks compilation of various platforms

            remove __bss_start & Co

            sanja Oleksandr Byelkin added a comment - - edited commit eaf707984683b2ab4b5e35c5b598b23fd24c4c09 (HEAD -> bb-10.1-release, origin/bb-10.1-release) Author: Oleksandr Byelkin <sanja@mariadb.com> Date: Sun Aug 16 22:14:59 2020 +0200 MDEV-23491 : __bss_start breaks compilation of various platforms remove __bss_start & Co

            commit 14f9f95beecf7374f7741ec804b931cfb382d369 (HEAD -> bb-10.1-release, origin/bb-10.1-release)
            Author: Oleksandr Byelkin <sanja@mariadb.com>
            Date: Sun Aug 16 22:14:59 2020 +0200

            MDEV-23491: __bss_start breaks compilation of various platforms

            Remove __bss_start & Co, because systen call "write" check buffer address and return EFAULT if it is wrong.

            sanja Oleksandr Byelkin added a comment - commit 14f9f95beecf7374f7741ec804b931cfb382d369 (HEAD -> bb-10.1-release, origin/bb-10.1-release) Author: Oleksandr Byelkin <sanja@mariadb.com> Date: Sun Aug 16 22:14:59 2020 +0200 MDEV-23491 : __bss_start breaks compilation of various platforms Remove __bss_start & Co, because systen call "write" check buffer address and return EFAULT if it is wrong.

            rebased versions (where were conflicts):
            10.2 623eafb734b26e468f232faf3506c6f4346439c1
            10.3 40aabfff1f28e16085e6cd6755ce8d6ab0862d4e
            10.5 86be5bda2412bc627a8b708b9cc32cf16a0a736f

            sanja Oleksandr Byelkin added a comment - rebased versions (where were conflicts): 10.2 623eafb734b26e468f232faf3506c6f4346439c1 10.3 40aabfff1f28e16085e6cd6755ce8d6ab0862d4e 10.5 86be5bda2412bc627a8b708b9cc32cf16a0a736f

            People

              sanja Oleksandr Byelkin
              serg Sergei Golubchik
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.