[MDEV-23491] __bss_start breaks compilation of various platforms Created: 2020-08-16 Updated: 2020-10-06 Resolved: 2020-08-18 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Compiling |
| Affects Version/s: | 10.1, 10.2, 10.3, 10.4, 10.5 |
| Fix Version/s: | 10.1.48, 10.2.35, 10.3.26, 10.4.16, 10.5.7 |
| Type: | Bug | Priority: | Major |
| Reporter: | Sergei Golubchik | Assignee: | Oleksandr Byelkin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||
| 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. |
| Comments |
| Comment by Oleksandr Byelkin [ 2020-08-16 ] |
|
commit eaf707984683b2ab4b5e35c5b598b23fd24c4c09 (HEAD -> bb-10.1-release, origin/bb-10.1-release) remove __bss_start & Co |
| Comment by Oleksandr Byelkin [ 2020-08-17 ] |
|
commit 14f9f95beecf7374f7741ec804b931cfb382d369 (HEAD -> bb-10.1-release, origin/bb-10.1-release) Remove __bss_start & Co, because systen call "write" check buffer address and return EFAULT if it is wrong. |
| Comment by Oleksandr Byelkin [ 2020-08-18 ] |
|
rebased versions (where were conflicts): |