vikasnkumar / hotpatch

Hot patching executables on Linux using .so file injection
http://www.selectiveintellect.com/hotpatch.html
BSD 3-Clause "New" or "Revised" License
360 stars 119 forks source link

fail to run test #17

Closed fjzzhongyi closed 4 years ago

fjzzhongyi commented 4 years ago

Hi, I tried to run as commands written in README, i,e., bash> ./hotpatcher -l ./libhotpatchtest.so -s mysym -v1 $$; but this invocation of injection didn't create any file nor write anything. The following is standard output from my bash.

Options Given:
Verbose Level: 1
Process PID: 3840
Symbol name: mysym
Library name: ./libhotpatchtest.so
Dry run: false
[ld_load_maps:278] Max number of mappings present: 53
[ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so matching /lib64/ld-linux-x86-64.so.2
[ld_find_library:376] Doing best substring search for libc.
[ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so matching libc
[ld_find_library:376] Doing best substring search for libdl.
[ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so matching libdl
[ld_find_library:376] Doing best substring search for libpthread.
[ld_find_library:447] Library libpthread not found in procmaps
[hotpatch_gather_functions:104] libpthread not mapped.
[hotpatch_gather_functions:106] Found malloc at 0x7f8d8b5fb070 in libc
[hotpatch_gather_functions:107] Found realloc at 0x7f8d8b5fcc30 in libc
[hotpatch_gather_functions:108] Found free at 0x7f8d8b5fb950 in libc
[hotpatch_gather_functions:122] Found dlopen at 0x7f8d8b955fe0 in libdl
[hotpatch_gather_functions:123] Found dlclose at 0x7f8d8b956080 in libdl
[hotpatch_gather_functions:124] Found dlsym at 0x7f8d8b9560f0 in libdl
[hotpatch_inject_library:620] Allocating 1024 bytes in the target.
[hotpatch_inject_library:741] Dll opened at 0x55b287077a30
[hotpatch_inject_library:755] Symbol mysym found at 0x7f8d89f4f5ad
[hotpatch_inject_library:769] Return value from invoking mysym(): (nil)
Dll was injected at 0x55b287077a30
Invocation of mysym() returned (nil)

Could anyone help me out of this trap?

vikasnkumar commented 4 years ago

Hi Can you specify OS details here using lsb_release -a ? Ubuntu specifically blocks this nowadays using some kernel parameters in /proc so you have to use root to allow for ptrace() to work.

-- Vikas Kumar

On Tue, Jan 7, 2020, at 4:10 AM, fjzzhongyi wrote:

Hi, I tried to run as commands written in README, i,e., bash> ./hotpatcher -l ./libhotpatchtest.so -s mysym -v1 $$; but this invocation of injection didn't create any file nor write anything. The following is standard output from my bash.

`Options Given: Verbose Level: 1 Process PID: 3840 Symbol name: mysym Library name: ./libhotpatchtest.so Dry run: false [ld_load_maps:278] Max number of mappings present: 53 [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so matching /lib64/ld-linux-x86-64.so.2 [ld_find_library:376] Doing best substring search for libc. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so matching libc [ld_find_library:376] Doing best substring search for libdl. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so matching libdl [ld_find_library:376] Doing best substring search for libpthread. [ld_find_library:447] Library libpthread not found in procmaps [hotpatch_gather_functions:104] libpthread not mapped. [hotpatch_gather_functions:106] Found malloc at 0x7f8d8b5fb070 in libc [hotpatch_gather_functions:107] Found realloc at 0x7f8d8b5fcc30 in libc [hotpatch_gather_functions:108] Found free at 0x7f8d8b5fb950 in libc [hotpatch_gather_functions:122] Found dlopen at 0x7f8d8b955fe0 in libdl [hotpatch_gather_functions:123] Found dlclose at 0x7f8d8b956080 in libdl [hotpatch_gather_functions:124] Found dlsym at 0x7f8d8b9560f0 in libdl [hotpatch_inject_library:620] Allocating 1024 bytes in the target. [hotpatch_inject_library:741] Dll opened at 0x55b287077a30 [hotpatch_inject_library:755] Symbol mysym found at 0x7f8d89f4f5ad [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) Dll was injected at 0x55b287077a30 Invocation of mysym() returned (nil)

`

Could anyone help me out of this trap?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WCCY2UUPE53YWERV33Q4RBIHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IEN2LWQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WH5C5NVSJWY7C2EFG3Q4RBIHANCNFSM4KDVHUTQ.

fjzzhongyi commented 4 years ago

I run the command and the response is as follows:

No LSB modules are available. Distributor ID:    Ubuntu Description:    Ubuntu 18.04.1 LTS Release:    18.04 Codename:    bionic

I had tried to run it using "sudo".

On 2020/1/7 下午7:42, Vikas N Kumar wrote:

Hi Can you specify OS details here using lsb_release -a ? Ubuntu specifically blocks this nowadays using some kernel parameters in /proc so you have to use root to allow for ptrace() to work.

-- Vikas Kumar

On Tue, Jan 7, 2020, at 4:10 AM, fjzzhongyi wrote:

Hi, I tried to run as commands written in README, i,e., bash> ./hotpatcher -l ./libhotpatchtest.so -s mysym -v1 $$; but this invocation of injection didn't create any file nor write anything. The following is standard output from my bash.

`Options Given: Verbose Level: 1 Process PID: 3840 Symbol name: mysym Library name: ./libhotpatchtest.so Dry run: false [ld_load_maps:278] Max number of mappings present: 53 [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so matching /lib64/ld-linux-x86-64.so.2 [ld_find_library:376] Doing best substring search for libc. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so matching libc [ld_find_library:376] Doing best substring search for libdl. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so matching libdl [ld_find_library:376] Doing best substring search for libpthread. [ld_find_library:447] Library libpthread not found in procmaps [hotpatch_gather_functions:104] libpthread not mapped. [hotpatch_gather_functions:106] Found malloc at 0x7f8d8b5fb070 in libc [hotpatch_gather_functions:107] Found realloc at 0x7f8d8b5fcc30 in libc [hotpatch_gather_functions:108] Found free at 0x7f8d8b5fb950 in libc [hotpatch_gather_functions:122] Found dlopen at 0x7f8d8b955fe0 in libdl [hotpatch_gather_functions:123] Found dlclose at 0x7f8d8b956080 in libdl [hotpatch_gather_functions:124] Found dlsym at 0x7f8d8b9560f0 in libdl [hotpatch_inject_library:620] Allocating 1024 bytes in the target. [hotpatch_inject_library:741] Dll opened at 0x55b287077a30 [hotpatch_inject_library:755] Symbol mysym found at 0x7f8d89f4f5ad [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) Dll was injected at 0x55b287077a30 Invocation of mysym() returned (nil)

`

Could anyone help me out of this trap?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WCCY2UUPE53YWERV33Q4RBIHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IEN2LWQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WH5C5NVSJWY7C2EFG3Q4RBIHANCNFSM4KDVHUTQ.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=ABXRQM2AUXOEMOUAVH4CAFLQ4RTEHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIITMMA#issuecomment-571553328, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXRQM254SVKV6BH45YNCCLQ4RTEHANCNFSM4KDVHUTQ.

vikasnkumar commented 4 years ago

In Ubuntu, ptrace is blocked as a security feature.

More details here under ptrace scope section: https://wiki.ubuntu.com/Security/Features

You have to turn the security feature off for Hotpatch to work on Ubuntu. Other versions do not have this problem.

The behavior is controllable through the /proc/sys/kernel/yama/ptrace_scope Sysctl. You can toggle that value to see if it works.

-- Vikas Kumar vikas@vikaskumar.org

On Tue, Jan 7, 2020, at 7:05 AM, fjzzhongyi wrote:

I run the command and the response is as follows:

No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.1 LTS Release: 18.04 Codename: bionic

I had tried to run it using "sudo".

On 2020/1/7 下午7:42, Vikas N Kumar wrote:

Hi Can you specify OS details here using lsb_release -a ? Ubuntu specifically blocks this nowadays using some kernel parameters in /proc so you have to use root to allow for ptrace() to work.

-- Vikas Kumar

On Tue, Jan 7, 2020, at 4:10 AM, fjzzhongyi wrote:

Hi, I tried to run as commands written in README, i,e., bash> ./hotpatcher -l ./libhotpatchtest.so -s mysym -v1 $$; but this invocation of injection didn't create any file nor write anything. The following is standard output from my bash.

`Options Given: Verbose Level: 1 Process PID: 3840 Symbol name: mysym Library name: ./libhotpatchtest.so Dry run: false [ld_load_maps:278] Max number of mappings present: 53 [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so matching /lib64/ld-linux-x86-64.so.2 [ld_find_library:376] Doing best substring search for libc. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so matching libc [ld_find_library:376] Doing best substring search for libdl. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so matching libdl [ld_find_library:376] Doing best substring search for libpthread. [ld_find_library:447] Library libpthread not found in procmaps [hotpatch_gather_functions:104] libpthread not mapped. [hotpatch_gather_functions:106] Found malloc at 0x7f8d8b5fb070 in libc [hotpatch_gather_functions:107] Found realloc at 0x7f8d8b5fcc30 in libc [hotpatch_gather_functions:108] Found free at 0x7f8d8b5fb950 in libc [hotpatch_gather_functions:122] Found dlopen at 0x7f8d8b955fe0 in libdl [hotpatch_gather_functions:123] Found dlclose at 0x7f8d8b956080 in libdl [hotpatch_gather_functions:124] Found dlsym at 0x7f8d8b9560f0 in libdl [hotpatch_inject_library:620] Allocating 1024 bytes in the target. [hotpatch_inject_library:741] Dll opened at 0x55b287077a30 [hotpatch_inject_library:755] Symbol mysym found at 0x7f8d89f4f5ad [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) Dll was injected at 0x55b287077a30 Invocation of mysym() returned (nil)

`

Could anyone help me out of this trap?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WCCY2UUPE53YWERV33Q4RBIHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IEN2LWQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WH5C5NVSJWY7C2EFG3Q4RBIHANCNFSM4KDVHUTQ.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=ABXRQM2AUXOEMOUAVH4CAFLQ4RTEHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIITMMA#issuecomment-571553328, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXRQM254SVKV6BH45YNCCLQ4RTEHANCNFSM4KDVHUTQ.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WHRPVZI52D2JEJHIATQ4RVYVA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIIVAUI#issuecomment-571560017, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WHESP2CLS7TUI3BV63Q4RVYVANCNFSM4KDVHUTQ.

fjzzhongyi commented 4 years ago

I follow instructions to set ptrace_scope to 0 which enforces no restriction to ptrace. However, it doesn't work still. Would other issues claim it? And it notes that the standard output is a little different. I just attach it here.

Options Given:
Verbose Level: 1
Process PID: 3053
Symbol name: mysym
Library name: ./libhotpatchtest.so
Dry run: false
[ld_load_maps:278] Max number of mappings present: 50
[ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so matching /lib64/ld-linux-x86-64.so.2
[ld_find_library:376] Doing best substring search for libc.
[ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so matching libc
[ld_find_library:376] Doing best substring search for libdl.
[ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so matching libdl
[ld_find_library:376] Doing best substring search for libpthread.
[ld_find_library:447] Library libpthread not found in procmaps
[hotpatch_gather_functions:104] libpthread not mapped.
[hotpatch_gather_functions:106] Found malloc at 0x7fee7ede7070 in libc
[hotpatch_gather_functions:107] Found realloc at 0x7fee7ede8c30 in libc
[hotpatch_gather_functions:108] Found free at 0x7fee7ede7950 in libc
[hotpatch_gather_functions:122] Found dlopen at 0x7fee7f141fe0 in libdl
[hotpatch_gather_functions:123] Found dlclose at 0x7fee7f142080 in libdl
[hotpatch_gather_functions:124] Found dlsym at 0x7fee7f1420f0 in libdl
[hotpatch_inject_library:620] Allocating 1024 bytes in the target.
[hotpatch_inject_library:741] Dll opened at 0x55db6da03e70
[hotpatch_inject_library:755] Symbol mysym found at 0x7fee7d93d5ad
[hotpatch_inject_library:769] Return value from invoking mysym(): (nil)
Dll was injected at 0x55db6da03e70
Invocation of mysym() returned (nil)

In Ubuntu, ptrace is blocked as a security feature. More details here under ptrace scope section: https://wiki.ubuntu.com/Security/Features You have to turn the security feature off for Hotpatch to work on Ubuntu. Other versions do not have this problem. The behavior is controllable through the /proc/sys/kernel/yama/ptrace_scope Sysctl. You can toggle that value to see if it works. -- Vikas Kumar vikas@vikaskumar.org On Tue, Jan 7, 2020, at 7:05 AM, fjzzhongyi wrote: I run the command and the response is as follows: No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.1 LTS Release: 18.04 Codename: bionic I had tried to run it using "sudo". On 2020/1/7 下午7:42, Vikas N Kumar wrote: > Hi > Can you specify OS details here using lsb_release -a ? Ubuntu > specifically blocks this nowadays using some kernel parameters in > /proc so you have to use root to allow for ptrace() to work. > > > -- > Vikas Kumar > > > > > On Tue, Jan 7, 2020, at 4:10 AM, fjzzhongyi wrote: > > > > > Hi, I tried to run as commands written in README, i,e., bash> > ./hotpatcher -l ./libhotpatchtest.so -s mysym -v1 $$; but this > invocation of injection didn't create any file nor write anything. > > The following is standard output from my bash. > > > > > Options Given: > Verbose Level: 1 > Process PID: 3840 > Symbol name: mysym > Library name: ./libhotpatchtest.so > Dry run: false > [ld_load_maps:278] Max number of mappings present: 53 > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so > matching /lib64/ld-linux-x86-64.so.2 > [ld_find_library:376] Doing best substring search for libc. > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so > matching libc > [ld_find_library:376] Doing best substring search for libdl. > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so > matching libdl > [ld_find_library:376] Doing best substring search for libpthread. > [ld_find_library:447] Library libpthread not found in procmaps > [hotpatch_gather_functions:104] libpthread not mapped. > [hotpatch_gather_functions:106] Found malloc at 0x7f8d8b5fb070 in libc > [hotpatch_gather_functions:107] Found realloc at 0x7f8d8b5fcc30 in libc > [hotpatch_gather_functions:108] Found free at 0x7f8d8b5fb950 in libc > [hotpatch_gather_functions:122] Found dlopen at 0x7f8d8b955fe0 in libdl > [hotpatch_gather_functions:123] Found dlclose at 0x7f8d8b956080 in libdl > [hotpatch_gather_functions:124] Found dlsym at 0x7f8d8b9560f0 in libdl > [hotpatch_inject_library:620] Allocating 1024 bytes in the target. > [hotpatch_inject_library:741] Dll opened at 0x55b287077a30 > [hotpatch_inject_library:755] Symbol mysym found at 0x7f8d89f4f5ad > [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) > Dll was injected at 0x55b287077a30 > Invocation of mysym() returned (nil) > > > > Could anyone help me out of this trap? > > > — > > You are receiving this because you are subscribed to this thread. > > Reply to this email directly, view it on GitHub > <#17?email_source=notifications&email_token=AAAC6WCCY2UUPE53YWERV33Q4RBIHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IEN2LWQ>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/AAAC6WH5C5NVSJWY7C2EFG3Q4RBIHANCNFSM4KDVHUTQ. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <#17?email_source=notifications&email_token=ABXRQM2AUXOEMOUAVH4CAFLQ4RTEHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIITMMA#issuecomment-571553328>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/ABXRQM254SVKV6BH45YNCCLQ4RTEHANCNFSM4KDVHUTQ. > — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#17?email_source=notifications&email_token=AAAC6WHRPVZI52D2JEJHIATQ4RVYVA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIIVAUI#issuecomment-571560017>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WHESP2CLS7TUI3BV63Q4RVYVANCNFSM4KDVHUTQ.

vikasnkumar commented 4 years ago

This looks like it succeeded.

-- Vikas Kumar vikas@vikaskumar.org

On Tue, Jan 7, 2020, at 11:27 PM, fjzzhongyi wrote:

I follow instructions to set ptrace_scope to 0 which enforces no restriction to ptrace. However, it doesn't work still. Would other issues claim it? And it notes that the standard output is a little different. I just attach it here.

Options Given: Verbose Level: 1 Process PID: 3053 Symbol name: mysym Library name: ./libhotpatchtest.so Dry run: false [ld_load_maps:278] Max number of mappings present: 50 [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so matching /lib64/ld-linux-x86-64.so.2 [ld_find_library:376] Doing best substring search for libc. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so matching libc [ld_find_library:376] Doing best substring search for libdl. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so matching libdl [ld_find_library:376] Doing best substring search for libpthread. [ld_find_library:447] Library libpthread not found in procmaps [hotpatch_gather_functions:104] libpthread not mapped. [hotpatch_gather_functions:106] Found malloc at 0x7fee7ede7070 in libc [hotpatch_gather_functions:107] Found realloc at 0x7fee7ede8c30 in libc [hotpatch_gather_functions:108] Found free at 0x7fee7ede7950 in libc [hotpatch_gather_functions:122] Found dlopen at 0x7fee7f141fe0 in libdl [hotpatch_gather_functions:123] Found dlclose at 0x7fee7f142080 in libdl [hotpatch_gather_functions:124] Found dlsym at 0x7fee7f1420f0 in libdl [hotpatch_inject_library:620] Allocating 1024 bytes in the target. [hotpatch_inject_library:741] Dll opened at 0x55db6da03e70 [hotpatch_inject_library:755] Symbol mysym found at 0x7fee7d93d5ad [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) Dll was injected at 0x55db6da03e70 Invocation of mysym() returned (nil)

In Ubuntu, ptrace is blocked as a security feature. More details here under ptrace scope section: https://wiki.ubuntu.com/Security/Features You have to turn the security feature off for Hotpatch to work on Ubuntu. Other versions do not have this problem. The behavior is controllable through the /proc/sys/kernel/yama/ptrace_scope Sysctl. You can toggle that value to see if it works. … <#> -- Vikas Kumar vikas@vikaskumar.org On Tue, Jan 7, 2020, at 7:05 AM, fjzzhongyi wrote: I run the command and the response is as follows: No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.1 LTS Release: 18.04 Codename: bionic I had tried to run it using "sudo". On 2020/1/7 下午7:42, Vikas N Kumar wrote: > Hi > Can you specify OS details here using lsb_release -a ? Ubuntu > specifically blocks this nowadays using some kernel parameters in > /proc so you have to use root to allow for ptrace() to work. > > > -- > Vikas Kumar > > > > > On Tue, Jan 7, 2020, at 4:10 AM, fjzzhongyi wrote: > > > > > Hi, I tried to run as commands written in README, i,e., bash> > ./hotpatcher -l ./libhotpatchtest.so -s mysym -v1 $$; but this > invocation of injection didn't create any file nor write anything. > > The following is standard output from my bash. > > > > > Options Given: > Verbose Level: 1 > Process PID: 3840 > Symbol name: mysym > Library name: ./libhotpatchtest.so > Dry run: false > [ld_load_maps:278] Max number of mappings present: 53 > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so > matching /lib64/ld-linux-x86-64.so.2 > [ld_find_library:376] Doing best substring search for libc. > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so > matching libc > [ld_find_library:376] Doing best substring search for libdl. > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so > matching libdl > [ld_find_library:376] Doing best substring search for libpthread. > [ld_find_library:447] Library libpthread not found in procmaps > [hotpatch_gather_functions:104] libpthread not mapped. > [hotpatch_gather_functions:106] Found malloc at 0x7f8d8b5fb070 in libc > [hotpatch_gather_functions:107] Found realloc at 0x7f8d8b5fcc30 in libc > [hotpatch_gather_functions:108] Found free at 0x7f8d8b5fb950 in libc > [hotpatch_gather_functions:122] Found dlopen at 0x7f8d8b955fe0 in libdl > [hotpatch_gather_functions:123] Found dlclose at 0x7f8d8b956080 in libdl > [hotpatch_gather_functions:124] Found dlsym at 0x7f8d8b9560f0 in libdl > [hotpatch_inject_library:620] Allocating 1024 bytes in the target. > [hotpatch_inject_library:741] Dll opened at 0x55b287077a30 > [hotpatch_inject_library:755] Symbol mysym found at 0x7f8d89f4f5ad > [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) > Dll was injected at 0x55b287077a30 > Invocation of mysym() returned (nil) > > > > Could anyone help me out of this trap? > > > — > > You are receiving this because you are subscribed to this thread. > > Reply to this email directly, view it on GitHub > <#17 https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WCCY2UUPE53YWERV33Q4RBIHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IEN2LWQ>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/AAAC6WH5C5NVSJWY7C2EFG3Q4RBIHANCNFSM4KDVHUTQ. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <#17 https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=ABXRQM2AUXOEMOUAVH4CAFLQ4RTEHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIITMMA#issuecomment-571553328>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/ABXRQM254SVKV6BH45YNCCLQ4RTEHANCNFSM4KDVHUTQ. > — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#17 https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WHRPVZI52D2JEJHIATQ4RVYVA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIIVAUI#issuecomment-571560017>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WHESP2CLS7TUI3BV63Q4RVYVANCNFSM4KDVHUTQ.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WGG3IEU6KFDKFUABGLQ4VI4FA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEILEVZY#issuecomment-571886311, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WBVW3UV4GGLYRHLTF3Q4VI4FANCNFSM4KDVHUTQ.

fjzzhongyi commented 4 years ago

However, I can't find any modification to tmp/hotpatchtest.log even if I have specified absolute path and created this file in advance. I applied my own program, but it seems not in line with expectations.

This looks like it succeeded. -- Vikas Kumar vikas@vikaskumar.org On Tue, Jan 7, 2020, at 11:27 PM, fjzzhongyi wrote: I follow instructions to set ptrace_scope to 0 which enforces no restriction to ptrace. However, it doesn't work still. Would other issues claim it? And it notes that the standard output is a little different. I just attach it here. Options Given: Verbose Level: 1 Process PID: 3053 Symbol name: mysym Library name: ./libhotpatchtest.so Dry run: false [ld_load_maps:278] Max number of mappings present: 50 [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so matching /lib64/ld-linux-x86-64.so.2 [ld_find_library:376] Doing best substring search for libc. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so matching libc [ld_find_library:376] Doing best substring search for libdl. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so matching libdl [ld_find_library:376] Doing best substring search for libpthread. [ld_find_library:447] Library libpthread not found in procmaps [hotpatch_gather_functions:104] libpthread not mapped. [hotpatch_gather_functions:106] Found malloc at 0x7fee7ede7070 in libc [hotpatch_gather_functions:107] Found realloc at 0x7fee7ede8c30 in libc [hotpatch_gather_functions:108] Found free at 0x7fee7ede7950 in libc [hotpatch_gather_functions:122] Found dlopen at 0x7fee7f141fe0 in libdl [hotpatch_gather_functions:123] Found dlclose at 0x7fee7f142080 in libdl [hotpatch_gather_functions:124] Found dlsym at 0x7fee7f1420f0 in libdl [hotpatch_inject_library:620] Allocating 1024 bytes in the target. [hotpatch_inject_library:741] Dll opened at 0x55db6da03e70 [hotpatch_inject_library:755] Symbol mysym found at 0x7fee7d93d5ad [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) Dll was injected at 0x55db6da03e70 Invocation of mysym() returned (nil)

In Ubuntu, ptrace is blocked as a security feature. More details here under ptrace scope section: https://wiki.ubuntu.com/Security/Features You have to turn the security feature off for Hotpatch to work on Ubuntu. Other versions do not have this problem. The behavior is controllable through the /proc/sys/kernel/yama/ptrace_scope Sysctl. You can toggle that value to see if it works. > … <#> > -- Vikas Kumar @.*** > On Tue, Jan 7, 2020, at 7:05 AM, fjzzhongyi wrote: I run the command and the response is as follows: No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.1 LTS Release: 18.04 Codename: bionic I had tried to run it using "sudo". On 2020/1/7 下午7:42, Vikas N Kumar wrote: > Hi > Can you specify OS details here using lsb_release -a ? Ubuntu > specifically blocks this nowadays using some kernel parameters in > /proc so you have to use root to allow for ptrace() to work. > > > -- > Vikas Kumar > > > > > On Tue, Jan 7, 2020, at 4:10 AM, fjzzhongyi wrote: > > > > > Hi, I tried to run as commands written in README, i,e., bash> > ./hotpatcher -l ./libhotpatchtest.so -s mysym -v1 $$; but this > invocation of injection didn't create any file nor write anything. > > The following is standard output from my bash. > > > > > Options Given: > Verbose Level: 1 > Process PID: 3840 > Symbol name: mysym > Library name: ./libhotpatchtest.so > Dry run: false > [ld_load_maps:278] Max number of mappings present: 53 > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so > matching /lib64/ld-linux-x86-64.so.2 > [ld_find_library:376] Doing best substring search for libc. > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so > matching libc > [ld_find_library:376] Doing best substring search for libdl. > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so > matching libdl > [ld_find_library:376] Doing best substring search for libpthread. > [ld_find_library:447] Library libpthread not found in procmaps > [hotpatch_gather_functions:104] libpthread not mapped. > [hotpatch_gather_functions:106] Found malloc at 0x7f8d8b5fb070 in libc > [hotpatch_gather_functions:107] Found realloc at 0x7f8d8b5fcc30 in libc > [hotpatch_gather_functions:108] Found free at 0x7f8d8b5fb950 in libc > [hotpatch_gather_functions:122] Found dlopen at 0x7f8d8b955fe0 in libdl > [hotpatch_gather_functions:123] Found dlclose at 0x7f8d8b956080 in libdl > [hotpatch_gather_functions:124] Found dlsym at 0x7f8d8b9560f0 in libdl > [hotpatch_inject_library:620] Allocating 1024 bytes in the target. > [hotpatch_inject_library:741] Dll opened at 0x55b287077a30 > [hotpatch_inject_library:755] Symbol mysym found at 0x7f8d89f4f5ad > [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) > Dll was injected at 0x55b287077a30 > Invocation of mysym() returned (nil) > > > > Could anyone help me out of this trap? > > > — > > You are receiving this because you are subscribed to this thread. > > Reply to this email directly, view it on GitHub > <#17 <#17>?email_source=notifications&email_token=AAAC6WCCY2UUPE53YWERV33Q4RBIHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IEN2LWQ>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/AAAC6WH5C5NVSJWY7C2EFG3Q4RBIHANCNFSM4KDVHUTQ. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <#17 <#17>?email_source=notifications&email_token=ABXRQM2AUXOEMOUAVH4CAFLQ4RTEHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIITMMA#issuecomment-571553328>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/ABXRQM254SVKV6BH45YNCCLQ4RTEHANCNFSM4KDVHUTQ. > — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#17 <#17>?email_source=notifications&email_token=AAAC6WHRPVZI52D2JEJHIATQ4RVYVA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIIVAUI#issuecomment-571560017>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WHESP2CLS7TUI3BV63Q4RVYVANCNFSM4KDVHUTQ. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#17?email_source=notifications&email_token=AAAC6WGG3IEU6KFDKFUABGLQ4VI4FA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEILEVZY#issuecomment-571886311>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WBVW3UV4GGLYRHLTF3Q4VI4FANCNFSM4KDVHUTQ.

vikasnkumar commented 4 years ago

What is the goal for your use of Hotpatch ? There are other ways to load a DLL on Linux such as with the tool named Frida https://www.frida.re/ or using the LD_PRELOAD environment variable. I have not tested on Ubuntu 18.xx and can maybe try on the weekend.

-- Vikas Kumar vikas@vikaskumar.org

On Wed, Jan 8, 2020, at 11:06 PM, fjzzhongyi wrote:

However, I can't find any modification to tmp/hotpatchtest.log even if I have specified absolute path and created this file in advance. I applied my own program, but it seems not in line with expectations.

This looks like it succeeded. -- Vikas Kumar vikas@vikaskumar.org On Tue, Jan 7, 2020, at 11:27 PM, fjzzhongyi wrote: I follow instructions to set ptrace_scope to 0 which enforces no restriction to ptrace. However, it doesn't work still. Would other issues claim it? And it notes that the standard output is a little different. I just attach it here. Options Given: Verbose Level: 1 Process PID: 3053 Symbol name: mysym Library name: ./libhotpatchtest.so Dry run: false [ld_load_maps:278] Max number of mappings present: 50 [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so matching /lib64/ld-linux-x86-64.so.2 [ld_find_library:376] Doing best substring search for libc. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so matching libc [ld_find_library:376] Doing best substring search for libdl. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so matching libdl [ld_find_library:376] Doing best substring search for libpthread. [ld_find_library:447] Library libpthread not found in procmaps [hotpatch_gather_functions:104] libpthread not mapped. [hotpatch_gather_functions:106] Found malloc at 0x7fee7ede7070 in libc [hotpatch_gather_functions:107] Found realloc at 0x7fee7ede8c30 in libc [hotpatch_gather_functions:108] Found free at 0x7fee7ede7950 in libc [hotpatch_gather_functions:122] Found dlopen at 0x7fee7f141fe0 in libdl [hotpatch_gather_functions:123] Found dlclose at 0x7fee7f142080 in libdl [hotpatch_gather_functions:124] Found dlsym at 0x7fee7f1420f0 in libdl [hotpatch_inject_library:620] Allocating 1024 bytes in the target. [hotpatch_inject_library:741] Dll opened at 0x55db6da03e70 [hotpatch_inject_library:755] Symbol mysym found at 0x7fee7d93d5ad [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) Dll was injected at 0x55db6da03e70 Invocation of mysym() returned (nil) … <#>

In Ubuntu, ptrace is blocked as a security feature. More details here under ptrace scope section: https://wiki.ubuntu.com/Security/Features You have to turn the security feature off for Hotpatch to work on Ubuntu. Other versions do not have this problem. The behavior is controllable through the /proc/sys/kernel/yama/ptrace_scope Sysctl. You can toggle that value to see if it works. > … <#> > -- Vikas Kumar @.*** > On Tue, Jan 7, 2020, at 7:05 AM, fjzzhongyi wrote: I run the command and the response is as follows: No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.1 LTS Release: 18.04 Codename: bionic I had tried to run it using "sudo". On 2020/1/7 下午7:42, Vikas N Kumar wrote: > Hi > Can you specify OS details here using lsb_release -a ? Ubuntu > specifically blocks this nowadays using some kernel parameters in > /proc so you have to use root to allow for ptrace() to work. > > > -- > Vikas Kumar > > > > > On Tue, Jan 7, 2020, at 4:10 AM, fjzzhongyi wrote: > > > > > Hi, I tried to run as commands written in README, i,e., bash> > ./hotpatcher -l ./libhotpatchtest.so -s mysym -v1 $$; but this > invocation of injection didn't create any file nor write anything. > > The following is standard output from my bash. > > > > > Options Given: > Verbose Level: 1 > Process PID: 3840 > Symbol name: mysym > Library name: ./libhotpatchtest.so > Dry run: false > [ld_load_maps:278] Max number of mappings present: 53 > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so > matching /lib64/ld-linux-x86-64.so.2 > [ld_find_library:376] Doing best substring search for libc. > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so > matching libc > [ld_find_library:376] Doing best substring search for libdl. > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so > matching libdl > [ld_find_library:376] Doing best substring search for libpthread. > [ld_find_library:447] Library libpthread not found in procmaps > [hotpatch_gather_functions:104] libpthread not mapped. > [hotpatch_gather_functions:106] Found malloc at 0x7f8d8b5fb070 in libc > [hotpatch_gather_functions:107] Found realloc at 0x7f8d8b5fcc30 in libc > [hotpatch_gather_functions:108] Found free at 0x7f8d8b5fb950 in libc > [hotpatch_gather_functions:122] Found dlopen at 0x7f8d8b955fe0 in libdl > [hotpatch_gather_functions:123] Found dlclose at 0x7f8d8b956080 in libdl > [hotpatch_gather_functions:124] Found dlsym at 0x7f8d8b9560f0 in libdl > [hotpatch_inject_library:620] Allocating 1024 bytes in the target. > [hotpatch_inject_library:741] Dll opened at 0x55b287077a30 > [hotpatch_inject_library:755] Symbol mysym found at 0x7f8d89f4f5ad > [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) > Dll was injected at 0x55b287077a30 > Invocation of mysym() returned (nil) > > > > Could anyone help me out of this trap? > > > — > > You are receiving this because you are subscribed to this thread. > > Reply to this email directly, view it on GitHub > <#17 https://github.com/vikasnkumar/hotpatch/issues/17 <#17 https://github.com/vikasnkumar/hotpatch/issues/17>?email_source=notifications&email_token=AAAC6WCCY2UUPE53YWERV33Q4RBIHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IEN2LWQ>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/AAAC6WH5C5NVSJWY7C2EFG3Q4RBIHANCNFSM4KDVHUTQ. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <#17 https://github.com/vikasnkumar/hotpatch/issues/17 <#17 https://github.com/vikasnkumar/hotpatch/issues/17>?email_source=notifications&email_token=ABXRQM2AUXOEMOUAVH4CAFLQ4RTEHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIITMMA#issuecomment-571553328>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/ABXRQM254SVKV6BH45YNCCLQ4RTEHANCNFSM4KDVHUTQ. > — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#17 https://github.com/vikasnkumar/hotpatch/issues/17 <#17 https://github.com/vikasnkumar/hotpatch/issues/17>?email_source=notifications&email_token=AAAC6WHRPVZI52D2JEJHIATQ4RVYVA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIIVAUI#issuecomment-571560017>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WHESP2CLS7TUI3BV63Q4RVYVANCNFSM4KDVHUTQ. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#17 https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WGG3IEU6KFDKFUABGLQ4VI4FA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEILEVZY#issuecomment-571886311>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WBVW3UV4GGLYRHLTF3Q4VI4FANCNFSM4KDVHUTQ.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WFHF3OZU32DX6UKMSLQ42PGBA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIO37QQ#issuecomment-572374978, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WAPZVQVTVNQEWXB6VDQ42PGBANCNFSM4KDVHUTQ.

fjzzhongyi commented 4 years ago
    I would like to replace partial lines of code, specifically a certain function in runtime. Do you have some suggestions? In addition, could hotpatch be used to update some variables in the program during runtime. 

    Outlook for iOS

On Thu, Jan 9, 2020 at 12:12 PM +0800, "Vikas N Kumar" notifications@github.com wrote:

What is the goal for your use of Hotpatch ? There are other ways to load a DLL on Linux such as with the tool named Frida https://www.frida.re/ or using the LD_PRELOAD environment variable.

I have not tested on Ubuntu 18.xx and can maybe try on the weekend.

--

Vikas Kumar

vikas@vikaskumar.org

On Wed, Jan 8, 2020, at 11:06 PM, fjzzhongyi wrote:

However, I can't find any modification to tmp/hotpatchtest.log even if I have specified absolute path and created this file in advance. I applied my own program, but it seems not in line with expectations.

This looks like it succeeded.

-- Vikas Kumar vikas@vikaskumar.org

On Tue, Jan 7, 2020, at 11:27 PM, fjzzhongyi wrote: I follow instructions to set ptrace_scope to 0 which enforces no restriction to ptrace. However, it doesn't work still. Would other issues claim it? And it notes that the standard output is a little different. I just attach it here. Options Given: Verbose Level: 1 Process PID: 3053 Symbol name: mysym Library name: ./libhotpatchtest.so Dry run: false [ld_load_maps:278] Max number of mappings present: 50 [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so matching /lib64/ld-linux-x86-64.so.2 [ld_find_library:376] Doing best substring search for libc. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so matching libc [ld_find_library:376] Doing best substring search for libdl. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so matching libdl [ld_find_library:376] Doing best substring search for libpthread. [ld_find_library:447] Library libpthread not found in procmaps [hotpatch_gather_functions:104] libpthread not mapped. [hotpatch_gather_functions:106] Found malloc at 0x7fee7ede7070 in libc [hotpatch_gather_functions:107] Found realloc at 0x7fee7ede8c30 in libc [hotpatch_gather_functions:108] Found free at 0x7fee7ede7950 in libc [hotpatch_gather_functions:122] Found dlopen at 0x7fee7f141fe0 in libdl [hotpatch_gather_functions:123] Found dlclose at 0x7fee7f142080 in libdl [hotpatch_gather_functions:124] Found dlsym at 0x7fee7f1420f0 in libdl [hotpatch_inject_library:620] Allocating 1024 bytes in the target. [hotpatch_inject_library:741] Dll opened at 0x55db6da03e70 [hotpatch_inject_library:755] Symbol mysym found at 0x7fee7d93d5ad [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) Dll was injected at 0x55db6da03e70 Invocation of mysym() returned (nil)

… <#>

In Ubuntu, ptrace is blocked as a security feature. More details here under ptrace scope section: https://wiki.ubuntu.com/Security/Features You have to turn the security feature off for Hotpatch to work on Ubuntu. Other versions do not have this problem. The behavior is controllable through the /proc/sys/kernel/yama/ptrace_scope Sysctl. You can toggle that value to see if it works. > … <#> > -- Vikas Kumar @.*** > On Tue, Jan 7, 2020, at 7:05 AM, fjzzhongyi wrote: I run the command and the response is as follows: No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.1 LTS Release: 18.04 Codename: bionic I had tried to run it using "sudo". On 2020/1/7 下午7:42, Vikas N Kumar wrote: > Hi > Can you specify OS details here using lsb_release -a ? Ubuntu > specifically blocks this nowadays using some kernel parameters in > /proc so you have to use root to allow for ptrace() to work. > > > -- > Vikas Kumar > > > > > On Tue, Jan 7, 2020, at 4:10 AM, fjzzhongyi wrote: > > > > > Hi, I tried to run as commands written in README, i,e., bash> > ./hotpatcher -l ./libhotpatchtest.so -s mysym -v1 $$; but this > invocation of injection didn't create any file nor write anything. > > The following is standard output from my bash. > > > > > Options Given: > Verbose Level: 1 > Process PID: 3840 > Symbol name: mysym > Library name: ./libhotpatchtest.so > Dry run: false > [ld_load_maps:278] Max number of mappings present: 53 > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so > matching /lib64/ld-linux-x86-64.so.2 > [ld_find_library:376] Doing best substring search for libc. > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so > matching libc > [ld_find_library:376] Doing best substring search for libdl. > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so > matching libdl > [ld_find_library:376] Doing best substring search for libpthread. > [ld_find_library:447] Library libpthread not found in procmaps > [hotpatch_gather_functions:104] libpthread not mapped. > [hotpatch_gather_functions:106] Found malloc at 0x7f8d8b5fb070 in libc > [hotpatch_gather_functions:107] Found realloc at 0x7f8d8b5fcc30 in libc > [hotpatch_gather_functions:108] Found free at 0x7f8d8b5fb950 in libc > [hotpatch_gather_functions:122] Found dlopen at 0x7f8d8b955fe0 in libdl > [hotpatch_gather_functions:123] Found dlclose at 0x7f8d8b956080 in libdl > [hotpatch_gather_functions:124] Found dlsym at 0x7f8d8b9560f0 in libdl > [hotpatch_inject_library:620] Allocating 1024 bytes in the target. > [hotpatch_inject_library:741] Dll opened at 0x55b287077a30 > [hotpatch_inject_library:755] Symbol mysym found at 0x7f8d89f4f5ad > [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) > Dll was injected at 0x55b287077a30 > Invocation of mysym() returned (nil) > > > > Could anyone help me out of this trap? > > > — > > You are receiving this because you are subscribed to this thread. > > Reply to this email directly, view it on GitHub > <#17 https://github.com/vikasnkumar/hotpatch/issues/17 <#17 https://github.com/vikasnkumar/hotpatch/issues/17>?email_source=notifications&email_token=AAAC6WCCY2UUPE53YWERV33Q4RBIHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IEN2LWQ>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/AAAC6WH5C5NVSJWY7C2EFG3Q4RBIHANCNFSM4KDVHUTQ. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <#17 https://github.com/vikasnkumar/hotpatch/issues/17 <#17 https://github.com/vikasnkumar/hotpatch/issues/17>?email_source=notifications&email_token=ABXRQM2AUXOEMOUAVH4CAFLQ4RTEHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIITMMA#issuecomment-571553328>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/ABXRQM254SVKV6BH45YNCCLQ4RTEHANCNFSM4KDVHUTQ. > — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#17 https://github.com/vikasnkumar/hotpatch/issues/17 <#17 https://github.com/vikasnkumar/hotpatch/issues/17>?email_source=notifications&email_token=AAAC6WHRPVZI52D2JEJHIATQ4RVYVA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIIVAUI#issuecomment-571560017>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WHESP2CLS7TUI3BV63Q4RVYVANCNFSM4KDVHUTQ. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#17 https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WGG3IEU6KFDKFUABGLQ4VI4FA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEILEVZY#issuecomment-571886311>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WBVW3UV4GGLYRHLTF3Q4VI4FANCNFSM4KDVHUTQ.

You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WFHF3OZU32DX6UKMSLQ42PGBA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIO37QQ#issuecomment-572374978, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WAPZVQVTVNQEWXB6VDQ42PGBANCNFSM4KDVHUTQ.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

vikasnkumar commented 4 years ago

I think Frida solves what you want especially if you have control of the application in question.

Hotpatch can only be used to patch functions not variables unless you’re trying to change static variables for which you have the address.

-- Vikas Kumar vikas@vikaskumar.org

On Thu, Jan 9, 2020, at 2:11 AM, fjzzhongyi wrote:

I would like to replace partial lines of code, specifically a certain function in runtime. Do you have some suggestions? In addition, could hotpatch be used to update some variables in the program during runtime.

Outlook for iOS

On Thu, Jan 9, 2020 at 12:12 PM +0800, "Vikas N Kumar" notifications@github.com wrote:

What is the goal for your use of Hotpatch ? There are other ways to load a DLL on Linux such as with the tool named Frida https://www.frida.re/ or using the LD_PRELOAD environment variable.

I have not tested on Ubuntu 18.xx and can maybe try on the weekend.

--

Vikas Kumar

vikas@vikaskumar.org

On Wed, Jan 8, 2020, at 11:06 PM, fjzzhongyi wrote:

However, I can't find any modification to tmp/hotpatchtest.log even if I have specified absolute path and created this file in advance. I applied my own program, but it seems not in line with expectations.

This looks like it succeeded.

-- Vikas Kumar vikas@vikaskumar.org

On Tue, Jan 7, 2020, at 11:27 PM, fjzzhongyi wrote: I follow instructions to set ptrace_scope to 0 which enforces no restriction to ptrace. However, it doesn't work still. Would other issues claim it? And it notes that the standard output is a little different. I just attach it here. Options Given: Verbose Level: 1 Process PID: 3053 Symbol name: mysym Library name: ./libhotpatchtest.so Dry run: false [ld_load_maps:278] Max number of mappings present: 50 [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so matching /lib64/ld-linux-x86-64.so.2 [ld_find_library:376] Doing best substring search for libc. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so matching libc [ld_find_library:376] Doing best substring search for libdl. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so matching libdl [ld_find_library:376] Doing best substring search for libpthread. [ld_find_library:447] Library libpthread not found in procmaps [hotpatch_gather_functions:104] libpthread not mapped. [hotpatch_gather_functions:106] Found malloc at 0x7fee7ede7070 in libc [hotpatch_gather_functions:107] Found realloc at 0x7fee7ede8c30 in libc [hotpatch_gather_functions:108] Found free at 0x7fee7ede7950 in libc [hotpatch_gather_functions:122] Found dlopen at 0x7fee7f141fe0 in libdl [hotpatch_gather_functions:123] Found dlclose at 0x7fee7f142080 in libdl [hotpatch_gather_functions:124] Found dlsym at 0x7fee7f1420f0 in libdl [hotpatch_inject_library:620] Allocating 1024 bytes in the target. [hotpatch_inject_library:741] Dll opened at 0x55db6da03e70 [hotpatch_inject_library:755] Symbol mysym found at 0x7fee7d93d5ad [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) Dll was injected at 0x55db6da03e70 Invocation of mysym() returned (nil)

… <#>

In Ubuntu, ptrace is blocked as a security feature. More details here under ptrace scope section: https://wiki.ubuntu.com/Security/Features You have to turn the security feature off for Hotpatch to work on Ubuntu. Other versions do not have this problem. The behavior is controllable through the /proc/sys/kernel/yama/ptrace_scope Sysctl. You can toggle that value to see if it works. > … <#> > -- Vikas Kumar @.*** > On Tue, Jan 7, 2020, at 7:05 AM, fjzzhongyi wrote: I run the command and the response is as follows: No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.1 LTS Release: 18.04 Codename: bionic I had tried to run it using "sudo". On 2020/1/7 下午7:42, Vikas N Kumar wrote: > Hi > Can you specify OS details here using lsb_release -a ? Ubuntu > specifically blocks this nowadays using some kernel parameters in > /proc so you have to use root to allow for ptrace() to work. > > > -- > Vikas Kumar > > > > > On Tue, Jan 7, 2020, at 4:10 AM, fjzzhongyi wrote: > > > > > Hi, I tried to run as commands written in README, i,e., bash> > ./hotpatcher -l ./libhotpatchtest.so -s mysym -v1 $$; but this > invocation of injection didn't create any file nor write anything. > > The following is standard output from my bash. > > > > > Options Given: > Verbose Level: 1 > Process PID: 3840 > Symbol name: mysym > Library name: ./libhotpatchtest.so > Dry run: false > [ld_load_maps:278] Max number of mappings present: 53 > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so > matching /lib64/ld-linux-x86-64.so.2 > [ld_find_library:376] Doing best substring search for libc. > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so > matching libc > [ld_find_library:376] Doing best substring search for libdl. > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so > matching libdl > [ld_find_library:376] Doing best substring search for libpthread. > [ld_find_library:447] Library libpthread not found in procmaps > [hotpatch_gather_functions:104] libpthread not mapped. > [hotpatch_gather_functions:106] Found malloc at 0x7f8d8b5fb070 in libc > [hotpatch_gather_functions:107] Found realloc at 0x7f8d8b5fcc30 in libc > [hotpatch_gather_functions:108] Found free at 0x7f8d8b5fb950 in libc > [hotpatch_gather_functions:122] Found dlopen at 0x7f8d8b955fe0 in libdl > [hotpatch_gather_functions:123] Found dlclose at 0x7f8d8b956080 in libdl > [hotpatch_gather_functions:124] Found dlsym at 0x7f8d8b9560f0 in libdl > [hotpatch_inject_library:620] Allocating 1024 bytes in the target. > [hotpatch_inject_library:741] Dll opened at 0x55b287077a30 > [hotpatch_inject_library:755] Symbol mysym found at 0x7f8d89f4f5ad > [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) > Dll was injected at 0x55b287077a30 > Invocation of mysym() returned (nil) > > > > Could anyone help me out of this trap? > > > — > > You are receiving this because you are subscribed to this thread. > > Reply to this email directly, view it on GitHub > <#17 https://github.com/vikasnkumar/hotpatch/issues/17 <#17 https://github.com/vikasnkumar/hotpatch/issues/17>?email_source=notifications&email_token=AAAC6WCCY2UUPE53YWERV33Q4RBIHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IEN2LWQ>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/AAAC6WH5C5NVSJWY7C2EFG3Q4RBIHANCNFSM4KDVHUTQ. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <#17 https://github.com/vikasnkumar/hotpatch/issues/17 <#17 https://github.com/vikasnkumar/hotpatch/issues/17>?email_source=notifications&email_token=ABXRQM2AUXOEMOUAVH4CAFLQ4RTEHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIITMMA#issuecomment-571553328>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/ABXRQM254SVKV6BH45YNCCLQ4RTEHANCNFSM4KDVHUTQ. > — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#17 https://github.com/vikasnkumar/hotpatch/issues/17 <#17 https://github.com/vikasnkumar/hotpatch/issues/17>?email_source=notifications&email_token=AAAC6WHRPVZI52D2JEJHIATQ4RVYVA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIIVAUI#issuecomment-571560017>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WHESP2CLS7TUI3BV63Q4RVYVANCNFSM4KDVHUTQ. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#17 https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WGG3IEU6KFDKFUABGLQ4VI4FA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEILEVZY#issuecomment-571886311>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WBVW3UV4GGLYRHLTF3Q4VI4FANCNFSM4KDVHUTQ.

You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WFHF3OZU32DX6UKMSLQ42PGBA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIO37QQ#issuecomment-572374978, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WAPZVQVTVNQEWXB6VDQ42PGBANCNFSM4KDVHUTQ.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WB2O6LML6QTLVGVJKDQ43E35A5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIPH44Q#issuecomment-572423794, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WAH6JZWHICIZ7JQQCDQ43E35ANCNFSM4KDVHUTQ.

fjzzhongyi commented 4 years ago

Thanks, I would try it instead later. And I look forward to any new explanation or update for the current issue if possible.

From: noreply@github.com on behalf of Vikas N Kumar notifications@github.com Reply-To: vikasnkumar/hotpatch reply@reply.github.com Date: Thursday, January 9, 2020 at 7:43 PM To: vikasnkumar/hotpatch hotpatch@noreply.github.com Cc: 黄宏毅 fjzzhongyi@163.com, Author author@noreply.github.com Subject: Re: [vikasnkumar/hotpatch] fail to run test (#17)

I think Frida solves what you want especially if you have control of the application in question.

Hotpatch can only be used to patch functions not variables unless you’re trying to change static variables for which you have the address.

-- Vikas Kumar vikas@vikaskumar.org

On Thu, Jan 9, 2020, at 2:11 AM, fjzzhongyi wrote:

I would like to replace partial lines of code, specifically a certain function in runtime. Do you have some suggestions? In addition, could hotpatch be used to update some variables in the program during runtime.

Outlook for iOS

On Thu, Jan 9, 2020 at 12:12 PM +0800, "Vikas N Kumar" notifications@github.com wrote:

What is the goal for your use of Hotpatch ? There are other ways to load a DLL on Linux such as with the tool named Frida https://www.frida.re/ or using the LD_PRELOAD environment variable.

I have not tested on Ubuntu 18.xx and can maybe try on the weekend.

--

Vikas Kumar

vikas@vikaskumar.org

On Wed, Jan 8, 2020, at 11:06 PM, fjzzhongyi wrote:

However, I can't find any modification to tmp/hotpatchtest.log even if I have specified absolute path and created this file in advance. I applied my own program, but it seems not in line with expectations.

This looks like it succeeded.

-- Vikas Kumar vikas@vikaskumar.org

On Tue, Jan 7, 2020, at 11:27 PM, fjzzhongyi wrote: I follow instructions to set ptrace_scope to 0 which enforces no restriction to ptrace. However, it doesn't work still. Would other issues claim it? And it notes that the standard output is a little different. I just attach it here. Options Given: Verbose Level: 1 Process PID: 3053 Symbol name: mysym Library name: ./libhotpatchtest.so Dry run: false [ld_load_maps:278] Max number of mappings present: 50 [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so matching /lib64/ld-linux-x86-64.so.2 [ld_find_library:376] Doing best substring search for libc. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so matching libc [ld_find_library:376] Doing best substring search for libdl. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so matching libdl [ld_find_library:376] Doing best substring search for libpthread. [ld_find_library:447] Library libpthread not found in procmaps [hotpatch_gather_functions:104] libpthread not mapped. [hotpatch_gather_functions:106] Found malloc at 0x7fee7ede7070 in libc [hotpatch_gather_functions:107] Found realloc at 0x7fee7ede8c30 in libc [hotpatch_gather_functions:108] Found free at 0x7fee7ede7950 in libc [hotpatch_gather_functions:122] Found dlopen at 0x7fee7f141fe0 in libdl [hotpatch_gather_functions:123] Found dlclose at 0x7fee7f142080 in libdl [hotpatch_gather_functions:124] Found dlsym at 0x7fee7f1420f0 in libdl [hotpatch_inject_library:620] Allocating 1024 bytes in the target. [hotpatch_inject_library:741] Dll opened at 0x55db6da03e70 [hotpatch_inject_library:755] Symbol mysym found at 0x7fee7d93d5ad [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) Dll was injected at 0x55db6da03e70 Invocation of mysym() returned (nil)

… <#>

In Ubuntu, ptrace is blocked as a security feature. More details here under ptrace scope section: https://wiki.ubuntu.com/Security/Features You have to turn the security feature off for Hotpatch to work on Ubuntu. Other versions do not have this problem. The behavior is controllable through the /proc/sys/kernel/yama/ptrace_scope Sysctl. You can toggle that value to see if it works. > … <#> > -- Vikas Kumar @.*** > On Tue, Jan 7, 2020, at 7:05 AM, fjzzhongyi wrote: I run the command and the response is as follows: No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.1 LTS Release: 18.04 Codename: bionic I had tried to run it using "sudo". On 2020/1/7 下午7:42, Vikas N Kumar wrote: > Hi > Can you specify OS details here using lsb_release -a ? Ubuntu > specifically blocks this nowadays using some kernel parameters in > /proc so you have to use root to allow for ptrace() to work. > > > -- > Vikas Kumar > > > > > On Tue, Jan 7, 2020, at 4:10 AM, fjzzhongyi wrote: > > > > > Hi, I tried to run as commands written in README, i,e., bash> > ./hotpatcher -l ./libhotpatchtest.so -s mysym -v1 $$; but this > invocation of injection didn't create any file nor write anything. > > The following is standard output from my bash. > > > > > Options Given: > Verbose Level: 1 > Process PID: 3840 > Symbol name: mysym > Library name: ./libhotpatchtest.so > Dry run: false > [ld_load_maps:278] Max number of mappings present: 53 > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so > matching /lib64/ld-linux-x86-64.so.2 > [ld_find_library:376] Doing best substring search for libc. > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so > matching libc > [ld_find_library:376] Doing best substring search for libdl. > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so > matching libdl > [ld_find_library:376] Doing best substring search for libpthread. > [ld_find_library:447] Library libpthread not found in procmaps > [hotpatch_gather_functions:104] libpthread not mapped. > [hotpatch_gather_functions:106] Found malloc at 0x7f8d8b5fb070 in libc > [hotpatch_gather_functions:107] Found realloc at 0x7f8d8b5fcc30 in libc > [hotpatch_gather_functions:108] Found free at 0x7f8d8b5fb950 in libc > [hotpatch_gather_functions:122] Found dlopen at 0x7f8d8b955fe0 in libdl > [hotpatch_gather_functions:123] Found dlclose at 0x7f8d8b956080 in libdl > [hotpatch_gather_functions:124] Found dlsym at 0x7f8d8b9560f0 in libdl > [hotpatch_inject_library:620] Allocating 1024 bytes in the target. > [hotpatch_inject_library:741] Dll opened at 0x55b287077a30 > [hotpatch_inject_library:755] Symbol mysym found at 0x7f8d89f4f5ad > [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) > Dll was injected at 0x55b287077a30 > Invocation of mysym() returned (nil) > > > > Could anyone help me out of this trap? > > > — > > You are receiving this because you are subscribed to this thread. > > Reply to this email directly, view it on GitHub > <#17 https://github.com/vikasnkumar/hotpatch/issues/17 <#17 https://github.com/vikasnkumar/hotpatch/issues/17>?email_source=notifications&email_token=AAAC6WCCY2UUPE53YWERV33Q4RBIHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IEN2LWQ>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/AAAC6WH5C5NVSJWY7C2EFG3Q4RBIHANCNFSM4KDVHUTQ. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <#17 https://github.com/vikasnkumar/hotpatch/issues/17 <#17 https://github.com/vikasnkumar/hotpatch/issues/17>?email_source=notifications&email_token=ABXRQM2AUXOEMOUAVH4CAFLQ4RTEHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIITMMA#issuecomment-571553328>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/ABXRQM254SVKV6BH45YNCCLQ4RTEHANCNFSM4KDVHUTQ. > — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#17 https://github.com/vikasnkumar/hotpatch/issues/17 <#17 https://github.com/vikasnkumar/hotpatch/issues/17>?email_source=notifications&email_token=AAAC6WHRPVZI52D2JEJHIATQ4RVYVA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIIVAUI#issuecomment-571560017>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WHESP2CLS7TUI3BV63Q4RVYVANCNFSM4KDVHUTQ. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#17 https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WGG3IEU6KFDKFUABGLQ4VI4FA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEILEVZY#issuecomment-571886311>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WBVW3UV4GGLYRHLTF3Q4VI4FANCNFSM4KDVHUTQ.

You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WFHF3OZU32DX6UKMSLQ42PGBA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIO37QQ#issuecomment-572374978, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WAPZVQVTVNQEWXB6VDQ42PGBANCNFSM4KDVHUTQ.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WB2O6LML6QTLVGVJKDQ43E35A5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIPH44Q#issuecomment-572423794, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WAH6JZWHICIZ7JQQCDQ43E35ANCNFSM4KDVHUTQ.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

vikasnkumar commented 4 years ago

It worked for me.

Here is what I did.

$ cd hotpatch 
$ make clean
$ make release
$ cd Release
$ ./src/hotpatcher -vvvv -l $PWD/test/libhotpatchtest.so -s mysym $$

This worked for me. I had to turn off the ptrace sysctl first.

I think you need the full path of the library. I will update the README. Thanks.

-- Vikas Kumar vikas@vikaskumar.org

On Fri, Jan 10, 2020, at 2:17 AM, fjzzhongyi wrote:

Thanks, I would try it instead later. And I look forward to any new explanation or update for the current issue if possible.

From: noreply@github.com on behalf of Vikas N Kumar notifications@github.com Reply-To: vikasnkumar/hotpatch reply@reply.github.com Date: Thursday, January 9, 2020 at 7:43 PM To: vikasnkumar/hotpatch hotpatch@noreply.github.com Cc: 黄宏毅 fjzzhongyi@163.com, Author author@noreply.github.com Subject: Re: [vikasnkumar/hotpatch] fail to run test (#17)

I think Frida solves what you want especially if you have control of the application in question.

Hotpatch can only be used to patch functions not variables unless you’re trying to change static variables for which you have the address.

-- Vikas Kumar vikas@vikaskumar.org

On Thu, Jan 9, 2020, at 2:11 AM, fjzzhongyi wrote:

I would like to replace partial lines of code, specifically a certain function in runtime. Do you have some suggestions? In addition, could hotpatch be used to update some variables in the program during runtime.

Outlook for iOS

On Thu, Jan 9, 2020 at 12:12 PM +0800, "Vikas N Kumar" notifications@github.com wrote:

What is the goal for your use of Hotpatch ? There are other ways to load a DLL on Linux such as with the tool named Frida https://www.frida.re/ or using the LD_PRELOAD environment variable.

I have not tested on Ubuntu 18.xx and can maybe try on the weekend.

--

Vikas Kumar

vikas@vikaskumar.org

On Wed, Jan 8, 2020, at 11:06 PM, fjzzhongyi wrote:

However, I can't find any modification to tmp/hotpatchtest.log even if I have specified absolute path and created this file in advance. I applied my own program, but it seems not in line with expectations.

This looks like it succeeded.

-- Vikas Kumar vikas@vikaskumar.org

On Tue, Jan 7, 2020, at 11:27 PM, fjzzhongyi wrote: I follow instructions to set ptrace_scope to 0 which enforces no restriction to ptrace. However, it doesn't work still. Would other issues claim it? And it notes that the standard output is a little different. I just attach it here. Options Given: Verbose Level: 1 Process PID: 3053 Symbol name: mysym Library name: ./libhotpatchtest.so Dry run: false [ld_load_maps:278] Max number of mappings present: 50 [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so matching /lib64/ld-linux-x86-64.so.2 [ld_find_library:376] Doing best substring search for libc. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so matching libc [ld_find_library:376] Doing best substring search for libdl. [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so matching libdl [ld_find_library:376] Doing best substring search for libpthread. [ld_find_library:447] Library libpthread not found in procmaps [hotpatch_gather_functions:104] libpthread not mapped. [hotpatch_gather_functions:106] Found malloc at 0x7fee7ede7070 in libc [hotpatch_gather_functions:107] Found realloc at 0x7fee7ede8c30 in libc [hotpatch_gather_functions:108] Found free at 0x7fee7ede7950 in libc [hotpatch_gather_functions:122] Found dlopen at 0x7fee7f141fe0 in libdl [hotpatch_gather_functions:123] Found dlclose at 0x7fee7f142080 in libdl [hotpatch_gather_functions:124] Found dlsym at 0x7fee7f1420f0 in libdl [hotpatch_inject_library:620] Allocating 1024 bytes in the target. [hotpatch_inject_library:741] Dll opened at 0x55db6da03e70 [hotpatch_inject_library:755] Symbol mysym found at 0x7fee7d93d5ad [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) Dll was injected at 0x55db6da03e70 Invocation of mysym() returned (nil)

… <#>

In Ubuntu, ptrace is blocked as a security feature. More details here under ptrace scope section: https://wiki.ubuntu.com/Security/Features You have to turn the security feature off for Hotpatch to work on Ubuntu. Other versions do not have this problem. The behavior is controllable through the /proc/sys/kernel/yama/ptrace_scope Sysctl. You can toggle that value to see if it works. > … <#> > -- Vikas Kumar @.*** > On Tue, Jan 7, 2020, at 7:05 AM, fjzzhongyi wrote: I run the command and the response is as follows: No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.1 LTS Release: 18.04 Codename: bionic I had tried to run it using "sudo". On 2020/1/7 下午7:42, Vikas N Kumar wrote: > Hi > Can you specify OS details here using lsb_release -a ? Ubuntu > specifically blocks this nowadays using some kernel parameters in > /proc so you have to use root to allow for ptrace() to work. > > > -- > Vikas Kumar > > > > > On Tue, Jan 7, 2020, at 4:10 AM, fjzzhongyi wrote: > > > > > Hi, I tried to run as commands written in README, i,e., bash> > ./hotpatcher -l ./libhotpatchtest.so -s mysym -v1 $$; but this > invocation of injection didn't create any file nor write anything. > > The following is standard output from my bash. > > > > > Options Given: > Verbose Level: 1 > Process PID: 3840 > Symbol name: mysym > Library name: ./libhotpatchtest.so > Dry run: false > [ld_load_maps:278] Max number of mappings present: 53 > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/ld-2.27.so > matching /lib64/ld-linux-x86-64.so.2 > [ld_find_library:376] Doing best substring search for libc. > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libc-2.27.so > matching libc > [ld_find_library:376] Doing best substring search for libdl. > [ld_find_library:440] Found entry /lib/x86_64-linux-gnu/libdl-2.27.so > matching libdl > [ld_find_library:376] Doing best substring search for libpthread. > [ld_find_library:447] Library libpthread not found in procmaps > [hotpatch_gather_functions:104] libpthread not mapped. > [hotpatch_gather_functions:106] Found malloc at 0x7f8d8b5fb070 in libc > [hotpatch_gather_functions:107] Found realloc at 0x7f8d8b5fcc30 in libc > [hotpatch_gather_functions:108] Found free at 0x7f8d8b5fb950 in libc > [hotpatch_gather_functions:122] Found dlopen at 0x7f8d8b955fe0 in libdl > [hotpatch_gather_functions:123] Found dlclose at 0x7f8d8b956080 in libdl > [hotpatch_gather_functions:124] Found dlsym at 0x7f8d8b9560f0 in libdl > [hotpatch_inject_library:620] Allocating 1024 bytes in the target. > [hotpatch_inject_library:741] Dll opened at 0x55b287077a30 > [hotpatch_inject_library:755] Symbol mysym found at 0x7f8d89f4f5ad > [hotpatch_inject_library:769] Return value from invoking mysym(): (nil) > Dll was injected at 0x55b287077a30 > Invocation of mysym() returned (nil) > > > > Could anyone help me out of this trap? > > > — > > You are receiving this because you are subscribed to this thread. > > Reply to this email directly, view it on GitHub > <#17 https://github.com/vikasnkumar/hotpatch/issues/17 <#17 https://github.com/vikasnkumar/hotpatch/issues/17>?email_source=notifications&email_token=AAAC6WCCY2UUPE53YWERV33Q4RBIHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IEN2LWQ>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/AAAC6WH5C5NVSJWY7C2EFG3Q4RBIHANCNFSM4KDVHUTQ. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <#17 https://github.com/vikasnkumar/hotpatch/issues/17 <#17 https://github.com/vikasnkumar/hotpatch/issues/17>?email_source=notifications&email_token=ABXRQM2AUXOEMOUAVH4CAFLQ4RTEHA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIITMMA#issuecomment-571553328>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/ABXRQM254SVKV6BH45YNCCLQ4RTEHANCNFSM4KDVHUTQ. > — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#17 https://github.com/vikasnkumar/hotpatch/issues/17 <#17 https://github.com/vikasnkumar/hotpatch/issues/17>?email_source=notifications&email_token=AAAC6WHRPVZI52D2JEJHIATQ4RVYVA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIIVAUI#issuecomment-571560017>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WHESP2CLS7TUI3BV63Q4RVYVANCNFSM4KDVHUTQ. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#17 https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WGG3IEU6KFDKFUABGLQ4VI4FA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEILEVZY#issuecomment-571886311>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WBVW3UV4GGLYRHLTF3Q4VI4FANCNFSM4KDVHUTQ.

You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WFHF3OZU32DX6UKMSLQ42PGBA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIO37QQ#issuecomment-572374978, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WAPZVQVTVNQEWXB6VDQ42PGBANCNFSM4KDVHUTQ.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WB2O6LML6QTLVGVJKDQ43E35A5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIPH44Q#issuecomment-572423794, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WAH6JZWHICIZ7JQQCDQ43E35ANCNFSM4KDVHUTQ.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WE6DHWW7AO2H4CKEODQ5AOIZA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIS5ROA#issuecomment-572905656, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WC4GG4PT7D3GJ3CEBLQ5AOIZANCNFSM4KDVHUTQ.

fjzzhongyi commented 4 years ago

May I infer hotpatch is to patch its code to running host process, invoke specific function within patch and return control back to host process? So would these actions be notified to host process? And what interactions could be perform between patch code and host code?

I think Frida solves what you want especially if you have control of the application in question. Hotpatch can only be used to patch functions not variables unless you’re trying to change static variables for which you have the address.

vikasnkumar commented 4 years ago

Yes that’s correct. Hotpatch allows you to inject your code into an already running process. The host process does not get notified unless they explicitly keep checking the list of all the .so files loaded in their memory which almost no process does.

-- Vikas Kumar vikas@vikaskumar.org

On Fri, Jan 17, 2020, at 9:49 PM, fjzzhongyi wrote:

May I infer hotpatch is to patch its code to running host process, invoke specific function within patch and return control back to host process? So would these actions be notified to host process? And what interactions could be perform between patch code and host code?

I think Frida solves what you want especially if you have control of the application in question. Hotpatch can only be used to patch functions not variables unless you’re trying to change static variables for which you have the address. … <#>

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WDFBJB33ZBI7WMAWCDQ6JUZ3A5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJJOUZA#issuecomment-575859300, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WCOREYNDLPWHY5K6ZTQ6JUZ3ANCNFSM4KDVHUTQ.

fjzzhongyi commented 4 years ago

OK. It's quite intelligible now. But if process keeps unconscious of the injected library, what would be the most representative cases using hotpatch since it seems to have no influence on running state of injected process?

Yes that’s correct. Hotpatch allows you to inject your code into an already running process. The host process does not get notified unless they explicitly keep checking the list of all the .so files loaded in their memory which almost no process does.

vikasnkumar commented 4 years ago

That is open to the user. You can use it to add functionality to a running process in a separate thread, you can use it to listen/read/write on file descriptors that are open or closed etc. You can overwrite a function address with your own. You can copy encryption keys if you want to. Since it is case by case I don’t give any code for those cases. The user must do this themselves.

-- Vikas Kumar vikas@vikaskumar.org

On Sat, Jan 18, 2020, at 9:06 AM, fjzzhongyi wrote:

OK. It's quite intelligible now. But if process keeps unconscious of the injected library, what would be the most representative cases using hotpatch since it seems to have no influence on running state of injected process?

Yes that’s correct. Hotpatch allows you to inject your code into an already running process. The host process does not get notified unless they explicitly keep checking the list of all the .so files loaded in their memory which almost no process does. … <#>

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vikasnkumar/hotpatch/issues/17?email_source=notifications&email_token=AAAC6WARP435RPPDE2RGZOTQ6MEGJA5CNFSM4KDVHUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJJY42Y#issuecomment-575901291, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAC6WDRQDRMXR77Y7O4VTTQ6MEGJANCNFSM4KDVHUTQ.

vikasnkumar commented 4 years ago

Closing since no more requests from developer.