Giter Club home page Giter Club logo

reredirect's People

Contributors

domoritz avatar ebroder avatar glensc avatar graingert avatar ingramj avatar jaapdejong avatar jerome-pouiller avatar lgautrot avatar mephesto1337 avatar nelhage avatar pozdnychev avatar ptrcnull avatar robryk avatar rwmacleod avatar vi avatar wangenau avatar ychaouche avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reredirect's Issues

Lost information after redirect the log

I'm using command "reredirect -m /tmp/logfile.txt PID" for redirect log of the application to logfile.txt. But I was checked the log file after short time. Some information of the log file is lost. Example:
Log file before:
[20180806 19:00] String in log file
[20180806 19:01] String in log file
[20180806 19:02] String in log file
[20180806 19:03] String in log file
New log file in the short time when I get from the log file:
[20180806 19:01] String in log file
[20180806 19:02] String in log file
[20180806 19:03] String in log file
[20180806 19:04] String in log file
[20180806 19:05] String in log file
=>The string "[20180806 19:00] String in log file" is lost after redirect in the short time.
The log only store between 24h. If the log has two string the same time, reredirect will remove one string.
Please help me to check the issue. Thank you

Make reredirect MIPS compatible

Readme.md says that "Ports to other architectures should be straightforward, and should in most cases be as simple as adding an arch/ARCH.h file and adding a clause to the ifdef ladder in ptrace.c."
But I have no knowlesge of assembly. What should be done to create a valid mips.h?

Incomplete type of user struct during compilation?

During compilation on aarch64 target, I got an incomplete type for user struct:

ptrace.h:62:17: error: field ‘user’ has incomplete type
   62 |     struct user user;

Are you aware of any resolution for this?

Warning when compiling

attach.c: In function ‘child_open’:
attach.c:94:9: warning: ‘strncat’ specified bound 4097 equals destination size [-Wstringop-overflow=]
   94 |         strncat(buf, "/", sizeof(buf));
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Unable to open the file in the child

hello
I've been using reredirect with no issues on arm but i recently saw this error

Unable to open the file in the child

i traced the code but was not sure of the cause. does anyone have any thoughts?

thanks

Potential permanent blocking caused by SIGCONT following SIGSTOP

I ran into a bug that reredirect hung forever, and the strace(1) output is collected as followed:

# strace -fT reredirect -m rere-shim.log 365991
execve("/usr/local/bin/reredirect", ["reredirect", "-m", "rere-shim.log", "365991"], [/* 18 vars */]) = 0
<0.000142>
brk(NULL)                               = 0x1bc2000 <0.000010>
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory) <0.000012>
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory) <0.000010>
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 <0.000012>
fstat(3, {st_mode=S_IFREG|0644, st_size=36276, ...}) = 0 <0.000010>
mmap(NULL, 36276, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f8e37c34000 <0.000011>
close(3)                                = 0 <0.000010>
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory) <0.000010>
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 <0.000011>
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`\t\2\0\0\0\0\0"..., 832) = 832 <0.000010>
fstat(3, {st_mode=S_IFREG|0755, st_size=1868984, ...}) = 0 <0.000010>
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8e37c33000 <0.000010>
mmap(NULL, 3971488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f8e3764e000 <0.000010>
mprotect(0x7f8e3780e000, 2097152, PROT_NONE) = 0 <0.000013>
mmap(0x7f8e37a0e000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c0000) = 0x7f
8e37a0e000 <0.000013>
mmap(0x7f8e37a14000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f8e37a1
4000 <0.000011>
close(3)                                = 0 <0.000009>
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8e37c32000 <0.000010>
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8e37c31000 <0.000010>
arch_prctl(ARCH_SET_FS, 0x7f8e37c32700) = 0 <0.000009>
mprotect(0x7f8e37a0e000, 16384, PROT_READ) = 0 <0.000012>
mprotect(0x603000, 4096, PROT_READ)     = 0 <0.000011>
mprotect(0x7f8e37c3d000, 4096, PROT_READ) = 0 <0.000011>
munmap(0x7f8e37c34000, 36276)           = 0 <0.000015>
ptrace(PTRACE_ATTACH, 365991, NULL, NULL) = 0 <0.000024>
kill(365991, SIGCONT)                   = 0 <0.000015>
wait4(365991, 

There should have been a SIGCHLD triggered by SIGSTOP or SIGCONT, and the missing signal made wait4(2) hang forever.

This situation was likely caused by SIGSTOP followed by SIGCONT. According to the man7:
image
instant SIGCONT after SIGSTOP may be discarded, as a result the tracer won't receive any signal and will end with endless wait4(2).

I can demonstrate this by very simple programs.

First prepare a python script:

import os
import time
pid = os.fork()
if pid:
    print(pid)
    while 1:
        os.waitpid(-1, os.WSTOPPED|os.WCONTINUED)
        print('waited')
else:
    time.sleep(1000)

Then compose a c program:

#include <signal.h>
#include<stdlib.h>

void main(int argc, char **argv) {
  int pid = atoi(argv[1]);
  kill(pid, SIGSTOP);
  kill(pid, SIGCONT);
}

Then run the python script and run the c program to send signals to the child python process. On my test env, the sent signals won't trigger waitpid(2) at all.

My recommendation for revise is to use PTRACE_SEIZE instead of PTRACE_ATTACH + SIGCONT:
image
I believe that can eradicate the issue.

Doesn't compile on CentOS 6

This is the output of make:

cc -Wall -g   -c -o reredirect.o reredirect.c
cc -Wall -g   -c -o ptrace.o ptrace.c
In file included from ptrace.c:82:
arch/amd64.h:84: error: request for member ‘nr_dup’ in something not a structure or union
make: *** [ptrace.o] Error 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.