Closed swick closed 11 years ago
Are you using the latest code from the repository ? Hotpatch does not manage library dependencies. libdl manages library dependencies. So if your libglcapture-client.so is injected into a process that does not link with libdl you will have to inject every .so file that libglcapture-client.so is dependent on except for libc. You can use "ldd -r libglcapture-client.so" to give you that information.
Please give me the following info: a) OS type/name/details such as Ubuntu vs debian vs CentoS b) Can you try injecting the hotpatchtest.so library into the process and see if it writes to /tmp/hotpatchtest.log file ? We need to separate out the failure of hotpatch working on your system vs injecting your custom library.
I think i fixed this problem in the latest checkin of hotpatch a few weeks ago. Please try that first.
Thanks for the reply. I'm on Ubuntu 12.10 x86_64. I tried to inject libhotpatchtest.so but the output is still the same. The funny thing is, that it works just fine with other target programs. I guess there is something a program must link to because I made a minimal program and tried to inject libhotpatchtest.so and it failed with the same output
#include <stdio.h>
int main(int argc, char **argv) {
while(1) {
printf(".\n");
sleep(1);
}
return 0;
}
There is a dummy program I provide that you can inject into.
When you build hotpatch from source using "make" in a new shell start the dummy program in the following way:
./Release/test/dummy
Then from another shell run the following:
PID=
pgrep dummy
./Release/src/hotpatcher -l $PWD/Release/test/libhotpatchtest.so $PIDcat /tmp/hotpatchtest.log
See if this works.
If this works, then you can compare your program with the dummy program.
This should work without "sudo".
If it doesn't work, we need to investigate further.
--Vikas On 01/30/2013 04:46 PM, Sebastian Wick wrote:
Thanks for the reply. I'm on Ubuntu 12.10 x86_64. I tried to inject libhotpatchtest.so but the output is still the same. The funny thing is, that it works just fine with other target programs. I guess there is something a program must link to because I made a minimal program and tried to inject libhotpatchtest.so and it failed with the same output
|#include
int main(int argc, char **argv) { while(1) { printf(".\n"); sleep(1); } return 0; } |
— Reply to this email directly or view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/2#issuecomment-12914364.
I need the sudo because Ubuntu needs super user rights to use ptrace. Same problem as always:
symbol is 0
Dll was injected at (nil)
Invocation of _init() returned (nil)
and the file /tmp/hotpatchtest.log doesn't exist.
Are you saying Ubuntu needs a sudo to run gdb on any program at all times now ? I have not tested Hotpatch on 12.10 so cannot guarantee that it works there. It works on 11.10 and 12.04 of Ubuntu, and the more recent versions of CentOS and Debian.
Btw, are you using the latest code from Github ?
On 01/31/2013 07:54 AM, Sebastian Wick wrote:
I need the sudo because Ubuntu needs super user rights to use ptrace. Same problem as always:
symbol is 0 Dll was injected at (nil) Invocation of _init() returned (nil) and the file /tmp/hotpatchtest.log doesn't exist.
— Reply to this email directly or view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/2#issuecomment-12941044.
gdb needs sudo to attach itself to a proccess which is not a child of gdb since Ubuntu 10.10 (https://wiki.ubuntu.com/Security/Features)
And yes, I use the lastest master.
Ok. Have you tried not using sudo. Just run the test as a root user or turn the Security Features off temporarily to test.
$ sudo su -
$ ./hotpatcher ....
Just want to confirm that sudo is not causing problems because of differences between user id and effective user id. Hotpatch doesn't care about it but still.
I will have to take care of Ubuntu next week.
On 01/31/2013 09:46 AM, Sebastian Wick wrote:
gdb needs sudo to attach itself to a proccess which is not a child of gdb since Ubuntu 10.10 (https://wiki.ubuntu.com/Security/Features)
And yes, I use the lastest master.
— Reply to this email directly or view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/2#issuecomment-12945430.
Tried sudo su first, then changed the kernel setting. No change at all. Same problem, same output.
Any news, yet? I'd like to help but I have to idea how to debug it ;)
Sorry, I have not found time to debug the problem. I just installed Ubuntu 12.04 today on a laptop for another project. Maybe tonight I can finally get time to look at hotpatch.
Are you trying on 32 or 64 bit systems ?
On 02/04/2013 02:34 PM, Sebastian Wick wrote:
Any news, yet? I'd like to help but I have to idea how to debug it ;)
— Reply to this email directly or view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/2#issuecomment-13094667.
Ok. I tested on Ubuntu 12.04 LTS and hotpatch seems to work in my test case.
I have the dummy programming running in a bash shell.
I run hotpatcher to inject libhotpatchtest.so into dummy and it succeeds and writes to the /tmp/hotpatchtest.log file.
I had to use sudo to do this.
On 02/04/2013 02:34 PM, Sebastian Wick wrote:
Any news, yet? I'd like to help but I have to idea how to debug it ;)
— Reply to this email directly or view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/2#issuecomment-13094667.
I'm on a 64 bit system and it doesn't work here. Maybe I messed something up, will try to test on another system.
Tested on a fresh ubuntu 12.10 64bit system, same error.
$ git clone https://github.com/vikasnkumar/hotpatch.git
$ mkdir build
$ cd build
$ cmake ../hotpatch/
$ make
$ ./test/dummy &
$ sleep 1
$ sudo ./src/hotpatcher -l ./test/libhotpatchtest.so $(pidof dummy)
Dll was injected at (nil)
Invocation of _init() returned (nil)
$ sleep 1
$ killall dummy
$ cat /tmp/hotpatchtest.log
cat: /tmp/hotpatchtest.log: No such file or directory
Please can you try this without running cmake yourself. The top level makefile calls Cmake itself by setting up the appropriate cmake variables as needed.
In a new terminal, please run the following $ git clone https://github.com/vikasnkumar/hotpatch.git $ make $ ./Release/test/dummy
In a separate terminal $ PID=$(pgrep dummy) $ cd Release $ sudo $PWD/src/hotpatcher -l $PWD/test/libhotpatchtest.so $PID
Thanks Vikas
On 02/04/2013 04:26 PM, Sebastian Wick wrote:
Tested on a fresh ubuntu 12.10 64bit system, same error.
$ git clone https://github.com/vikasnkumar/hotpatch.git $ mkdir build $ cd build $ cmake ../hotpatch/ $ make $ ./test/dummy & $ sleep 1 $ sudo ./src/hotpatcher -l ./test/libhotpatchtest.so $(pidof dummy) Dll was injected at (nil) Invocation of _init() returned (nil) $ sleep 1 $ killall dummy $ cat /tmp/hotpatchtest.log cat: /tmp/hotpatchtest.log: No such file or directory — Reply to this email directly or view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/2#issuecomment-13100400.
Same problem.
What are you really trying to do with hotpatch ? Is using Ubuntu 12.10 necessary ? Can you not use it on an earlier version ? I am not sure what has changed with Ubuntu 12.10 vs the earlier versions. I will have to find time and a system to install Ubuntu 12.10 64-bit on.
On 02/04/2013 05:28 PM, Sebastian Wick wrote:
Same problem.
— Reply to this email directly or view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/2#issuecomment-13103522.
I am downloading Ubuntu 12.10 64-bit to run it on a VM... let's see what the real problem is .
On 02/04/2013 05:28 PM, Sebastian Wick wrote:
Same problem.
— Reply to this email directly or view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/2#issuecomment-13103522.
Ok. I am testing it on 12.10. Yes there is something off with the return value of dlopen() and I will investigate that when I get time this weekend.
However, the library does get added to the memory map as you can see by running
$ grep hotpatchtest /proc/$(pgrep dummy)/maps
Not sure why dlopen() is returning NULL which means somewhere an error occurred in dlopen() itself. So the library is partially loaded and when you try to inject it again into the program it says inconsistency detected.
More debugging is necessary. In the meantime hotpatch works fine on Debian 6.0, CentOS 6.2 and Ubuntu 12.04.
When I find time to fix for 12.10 I will until then you might have to use a system which is supported.
--Vikas
Thanks a lot. I just wanted to make sure that this will work with all linux x86 platforms.
any news here?
sorry was out of town. have not had time to fix the bugs in Ubuntu 12.10.
On 03/11/2013 08:45 AM, Sebastian Wick wrote:
any news here?
— Reply to this email directly or view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/2#issuecomment-14711233.
I'm having the same issue with Mint 13, which is derived from 12.10 iirc.
I've noticed that I'm able to inject into a process within the same tree though, for example: urxvt -> zsh -> hotpatcher I can inject into the zsh instance that hotpatcher is run from, but not another zsh instance, and only when I use sudo.
Have you made any progress @vikasnkumar?
Sorry have not had time to make any serious progress. Linux 3.2 has become more secure not allowing injection as nicely as 2.6. Hence you need the sudo and hence it is more tough to inject into a non-tree process. I can fix it by using some custom reverse engineering but it will get patched in the kernel and I will keep chasing newer exploits. That I am not willing to do. I will try to find a more workable solution. Could you let me know what you are using hotpatch for ? You can email me privately. I can maybe suggest another route to solve your specific problem.
FYI, I currently use GDB for injecting: https://gist.github.com/swick/5470356
I have tested on Ubuntu 13.04 and yes you have to use SUDO to inject if your /proc/sys/kernel/yama/ptrace_scope has the value 1 and no need of sudo if it has the value 0.
$ sudo su -c "echo 0 > /proc/sys/kernel/yama/ptrace_scope"
You can now inject a library into other processes without using sudo. This works on kernel 3.8 running on Ubuntu 13.04. Cannot say about 12.10 and why it never worked there. Maybe it is your system's security features.
Same error happened on my computer.
But error only happened when I injected into a specified PID .
such as : bash> ./hotpatcher -l ./libhotpatchtest.so -s mysym -v1 9057
9057 is a simple app with a while loop.
if I use bash> ./hotpatcher -l ./libhotpatchtest.so -s mysym -v1 $$
and inject into current shell pid, it works well.
It really confused me~
If the /proc/sys/kernel/yama/ptrace_scope is set to 1 on Ubuntu then you can inject only in the same process tree. Hence you are able to inject in your own bash shell and not on some other process started in a separate shell.
Here is the link for that: https://wiki.ubuntu.com/Security/Features#ptrace_scope
So either turn the security feature off or stick to injecting in same process tree.
This is only for Ubuntu and its derivatives. Debian and CentOS do not have this issue for example.
On 08/25/2013 01:30 AM, ntop001 wrote:
Same error happened on my computer.
- os : ubuntu 12.04 LTS 64-bit
- kernel : 3.2.0-52-generic
But error only happened when I injected into a specified PID .
such as : bash> ./hotpatcher -l ./libhotpatchtest.so -s mysym -v1 9057
9057 is a simple app with a while loop.
if I use |bash> ./hotpatcher -l ./libhotpatchtest.so -s mysym -v1 $$| and inject into current shell pid, it works well.
It really confused me~
— Reply to this email directly or view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/2#issuecomment-23222259.
Thanks , I'll test later.
Same error happened on my computer.
Linux 2.6.18-238.12.1.el5.centos.plus #1 SMP Wed Jun 1 11:12:25 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
error only happened when I injected into a specified PID on centos
info:
Dll was injected at (nil) Invocation of func() returned (nil)
Can you be more specific as to what you launched and what exactly was the error ? Saying "same error" will not help.
Thanks
On 10/24/2013 02:23 AM, lengzijian wrote:
Same error happened on my computer.
Linux 2.6.18-238.12.1.el5.centos.plus #1 https://github.com/vikasnkumar/hotpatch/issues/1 SMP Wed Jun 1 11:12:25 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
error only happened when I injected into a specified PID on centos
— Reply to this email directly or view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/2#issuecomment-26969216.
if I inject into current shell pid, it works well. you say that CentOS do not have this issue . error happended when i injected into others pid on centos
CentOS 6.2 is what I had tested on. I have not tested on other versions. What kernel are you running ? What version of CentOS are you running ? Are you running SELinux ? There might be other security things that might be in place such as ptrace limitations.
All these things need to be looked at.
On 10/28/2013 12:40 AM, lengzijian wrote:
if I inject into current shell pid, it works well. you say that CentOS do not have this issue . error happended when i injected into others pid on centos
— Reply to this email directly or view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/2#issuecomment-27189156.
I'm not sure why it doesn't work.
even so it says
I think the real problem here is that dlopen returns 0:
Or maybe it's just me being dumb.