You are not logged in.

#1 2017-03-12 15:52:58

SteveDeFacto
Member
Registered: 2013-08-16
Posts: 158

Why doesn't GDB work without root while using ZSH?

I've been having a problem with GDB where it will error out when using ZSH with:

Starting program: /home/steven/zsurf/zsurf
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7fffe86c3700 (LWP 25410)]
FATAL: The application binary appears to be running setuid, this is a security hole.

Thread 1 "zsurf" received signal SIGABRT, Aborted.
0x00007ffff7a6f04f in raise () from /usr/lib/libc.so.6

I don't have this problem with GDB when using BASH as my shell. What could be causing this and most importantly how can I fix it?

Offline

#2 2017-03-12 16:48:03

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Why doesn't GDB work without root while using ZSH?

Can you replicate it with vanilla Zsh?


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2017-03-12 16:50:11

SteveDeFacto
Member
Registered: 2013-08-16
Posts: 158

Re: Why doesn't GDB work without root while using ZSH?

jasonwryan wrote:

Can you replicate it with vanilla Zsh?

It is vanilla Zsh.

Offline

#4 2017-03-12 16:53:07

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Why doesn't GDB work without root while using ZSH?

So you have removed all configs?


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2017-03-12 17:05:57

SteveDeFacto
Member
Registered: 2013-08-16
Posts: 158

Re: Why doesn't GDB work without root while using ZSH?

jasonwryan wrote:

So you have removed all configs?

Yes. I created a blank .zshrc. It still happens. No .zprofile either.

Last edited by SteveDeFacto (2017-03-12 17:06:26)

Offline

#6 2017-03-12 19:57:12

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Why doesn't GDB work without root while using ZSH?

Works fine here: Zsh 5.3.1-1 with a minimal config.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#7 2017-03-12 21:50:14

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,722

Re: Why doesn't GDB work without root while using ZSH?

ewaller@turing ~/devel/C/segfaultgenerator 1013 %cat main.c 
#include <stdio.h>
int main (int argc, char* argv[])

{
   char* myString;
   myString=0; 
   printf ("%s",*myString);
   return 0;
} 
ewaller@turing ~/devel/C/segfaultgenerator 1014 %./a.out 
zsh: segmentation fault (core dumped)  ./a.out
ewaller@turing ~/devel/C/segfaultgenerator [139]1015 %gdb a.out
GNU gdb (GDB) 7.12.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...done.
(gdb) l
1	#include <stdio.h>
2	int main (int argc, char* argv[])
3	
4	{
5	   char* myString;
6	   myString=0; 
7	   printf ("%s",*myString);
8	   return 0;
9	} 
(gdb) r
Starting program: /home/ewaller/devel/C/segfaultgenerator/a.out 

Program received signal SIGSEGV, Segmentation fault.
0x00000000004004df in main (argc=1, argv=0x7fffffffdfb8) at main.c:7
7	   printf ("%s",*myString);
(gdb) 

Seems okay here


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#8 2017-03-12 22:57:25

SteveDeFacto
Member
Registered: 2013-08-16
Posts: 158

Re: Why doesn't GDB work without root while using ZSH?

ewaller wrote:
ewaller@turing ~/devel/C/segfaultgenerator 1013 %cat main.c 
#include <stdio.h>
int main (int argc, char* argv[])

{
   char* myString;
   myString=0; 
   printf ("%s",*myString);
   return 0;
} 
ewaller@turing ~/devel/C/segfaultgenerator 1014 %./a.out 
zsh: segmentation fault (core dumped)  ./a.out
ewaller@turing ~/devel/C/segfaultgenerator [139]1015 %gdb a.out
GNU gdb (GDB) 7.12.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...done.
(gdb) l
1	#include <stdio.h>
2	int main (int argc, char* argv[])
3	
4	{
5	   char* myString;
6	   myString=0; 
7	   printf ("%s",*myString);
8	   return 0;
9	} 
(gdb) r
Starting program: /home/ewaller/devel/C/segfaultgenerator/a.out 

Program received signal SIGSEGV, Segmentation fault.
0x00000000004004df in main (argc=1, argv=0x7fffffffdfb8) at main.c:7
7	   printf ("%s",*myString);
(gdb) 

Seems okay here

jasonwryan wrote:

Works fine here: Zsh 5.3.1-1 with a minimal config.

There appears to be more at play here than I thought. It only appears to be an issue with applications which use either GTK or QT(probably others.). Trying it with otter-browser results in the same error I'm getting. Trying it with a GTK application give a GTK version of the same error:

(waterfox:13039): Gtk-WARNING **: This process is currently running setuid or setgid.
This is not a supported use of GTK+. You must create a helper
program instead. For further details, see:

    http://www.gtk.org/setuid.html

Refusing to initialize GTK+.

However, trying it with just console applications seems to work fine.

Last edited by SteveDeFacto (2017-03-12 22:58:04)

Offline

#9 2017-03-13 18:20:29

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,896

Re: Why doesn't GDB work without root while using ZSH?

Errr... stupid question: did you suid gdb or zsh or run it sudo to sidestep the yama security setting?

type gdb
stat `which gdb` `which zsh`
id -un; id -unr
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

Online

#10 2017-03-13 20:24:51

SteveDeFacto
Member
Registered: 2013-08-16
Posts: 158

Re: Why doesn't GDB work without root while using ZSH?

seth wrote:

Errr... stupid question: did you suid gdb or zsh or run it sudo to sidestep the yama security setting?

type gdb
stat `which gdb` `which zsh`
id -un; id -unr
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

Yes, I did try running it with sudo which works but that isn't an acceptable solution. I assume you wanted me to run those commands? Here is the output:

gdb is /usr/bin/gdb
gdb is /usr/sbin/gdb
  File: /usr/bin/gdb
  Size: 6634184         Blocks: 12960      IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 5270296     Links: 1
Access: (6755/-rwsr-sr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2017-03-13 13:01:50.060208260 -0700
Modify: 2017-01-25 05:12:51.000000000 -0700
Change: 2017-02-15 20:46:17.961200879 -0700
 Birth: -
  File: /usr/bin/zsh
  Size: 796280          Blocks: 1560       IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 5252950     Links: 2
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2017-03-12 15:42:06.253796677 -0700
Modify: 2016-12-22 12:27:11.000000000 -0700
Change: 2017-03-12 15:41:53.200463220 -0700
 Birth: -
steven
steven
0

Offline

#11 2017-03-13 20:35:31

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,896

Re: Why doesn't GDB work without root while using ZSH?

Why does "type" reveal a gdb in /usr/sbin - that should  be a symlink to /usr/bin (if)
Also, why is gdb 6755? The suid bit is set, thus the errors.
=> Investigate on these items.

I rather wanted to know whether you were calling "sudo gdb foo" to avoid the yama protection, since this might have cause this or similar troubles.
The last command (which you apparently put into a shell w/o thinking about it, don't do such, net even with commands from this forum) turns off this mechanism "the right way" and allows random users to attach gdb to running processes, but is not permanent (ie. will be gone with the next reboot)

Online

#12 2017-03-14 08:44:35

SteveDeFacto
Member
Registered: 2013-08-16
Posts: 158

Re: Why doesn't GDB work without root while using ZSH?

seth wrote:

Why does "type" reveal a gdb in /usr/sbin - that should  be a symlink to /usr/bin (if)
Also, why is gdb 6755? The suid bit is set, thus the errors.
=> Investigate on these items.

I rather wanted to know whether you were calling "sudo gdb foo" to avoid the yama protection, since this might have cause this or similar troubles.
The last command (which you apparently put into a shell w/o thinking about it, don't do such, net even with commands from this forum) turns off this mechanism "the right way" and allows random users to attach gdb to running processes, but is not permanent (ie. will be gone with the next reboot)

That is very odd to say the least... Thank you, it works now...

Offline

Board footer

Powered by FluxBB