Code Monkey home page Code Monkey logo

appview-team / appview Goto Github PK

View Code? Open in Web Editor NEW
37.0 0.0 1.0 287.43 MB

Gain insight into any Linux command or application with no code modification

Home Page: https://appview.org

License: Apache License 2.0

Shell 0.99% JavaScript 0.06% Ruby 0.15% C++ 7.62% Python 1.42% Perl 7.76% C 78.49% PHP 0.01% Emacs Lisp 0.01% Java 0.87% OCaml 0.47% Smalltalk 0.01% Tcl 0.01% Go 0.49% C# 1.09% Assembly 0.54% Rust 0.01% PowerShell 0.02% eC 0.01% Awk 0.01%
instrument linux observability privacy security monitoring

appview's People

Contributors

abetones avatar avoitenkov avatar bdalpe avatar coccyx avatar dependabot[bot] avatar dritanbitincka avatar eddie-cribl avatar iapaddler avatar jakub-cribl avatar jlewczynski avatar jrcheli avatar ledbit avatar master-elodin avatar michalbiesek avatar mqkatz avatar pdugas avatar ricksalsa avatar seanvaleo avatar sobolewsk avatar techprincess21 avatar timothymwilson avatar tnguyen-cribl avatar vintikjeny avatar xpac1985 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

Forkers

yarikoptic

appview's Issues

Handle Go signals on aarch64

On aarch64 machines, go processes crash intermittently with a "bad g". This has only been seen on aarch64. This was uncovered in go integration tests (go_20) in test cases for "signalHandlerStatic" and "signalHandlerStaticStripped". By adding a go routine to constantly write to the console, these test now fail within a small number of iterations (on this branch). To see them ASAP, I'd recommend commenting out the other test cases and running the go_20 signalHandler tests in a loop to see the "bad g" failure.

We may not have a perfect understanding, but we believe that when a signal happens while we are on the switched stack (for pcre2), go tries to retrieve the "g" from the stack. It's not going to find "g" on the stack when we're currently on our own stack executing pcre2 code, so go crashes. Without the new go routine that writes to the console, the "bad g" happens very infrequently, but importantly "bad g" in the signalHandlerStatic tests has also been observed on branches that do not have the stack pool implementation here. To the best of our knowledge, we could see this any time a signal handler interrupts us while we're running our c code.

If this description is correct, we think a possible solution is to mimic how go knows if c code is currently running.
https://github.com/golang/go/blob/master/src/runtime/cgocall.go
https://github.com/golang/go/blob/master/src/runtime/asm_arm64.s

The coredumper library is not sufficient for generating coredumps in all cases

It is now possible for libscope.so to create a core dump in release 1.3 on glibc systems.

The current implementation (coredumper) has some discovered limitations:

  • musl is not supported by coredumper
  • go is not supported by coredumper
  • applications running on ubuntu 22 are not supported by coredumper

On the topic of coredumps, there are a number of other things that may need some consideration in the future:

  1. coredumps themselves need some context to be useful. By context, I mean the application itself and dynamic libraries it references. Do we need to have an option to capture all of this information too (for apps running in a container?)
  2. we currently don't attempt to transfer coredumps across a network connection, do we need to add this?
  3. we've seen coredumps in our java7 integration (debian 8) test take 60s to complete. Otherwise the creation seems to be very responsive. Does this merit further investigation? I'm inclined to think we should wait to see if we observe this anywhere else.
  4. Right now in snapshotSignalHandler(), we're delaying 2s before calling the appSignalHandler. And the daemon waits 1s after receiving a signal before trying to grab the output files created by the library. The synchronization between libscope.so and scope daemon should probably be improved. @michalbiesek has shown that if a process joins the same mount namespace as the crashing process, it can access to the any file in that namespace even after all other processes in that namespace have exited. (though there are limitations about searching or viewing directories after the container has stopped). Maybe this could help?

Running new lxc containers does not automatically set env or mounts

$ /bin/linux/aarch64/scope run -- lxc ls
ERROR: ld.so: object 'libscope.so' from /etc/ld.so.preload cannot be preloaded (failed to map segment from shared object): ignored.
(same result with LD_PRELOAD or ld.so.preload)

$ LD_DEBUG=libs lxc ls
results in numerous symbol errors. a few examples:
calling init: /lib/libscope.so

 20015:	/lib/libscope.so: error: symbol lookup error: undefined symbol: SSL_read (fatal)
 20015:	/lib/libscope.so: error: symbol lookup error: undefined symbol: SSL_write (fatal)
 20015:	/lib/libscope.so: error: symbol lookup error: undefined symbol: SSL_get_fd (fatal)

 20015:	/lib/libscope.so: error: symbol lookup error: undefined symbol: PR_SetError (fatal)

 20015:	/lib/libscope.so: error: symbol lookup error: undefined symbol: uv__read (fatal)

 20015:	/lib/libscope.so: error: symbol lookup error: undefined symbol: uv_fileno (fatal)

other libs exhibit symbol errors, such as librt. however, are not preloaded.

Scoped dockerd does not produce events, it only produces metrics

Steps To Reproduce

root@precision:/home/sean/sandbox# scope attach dockerd
WARNING: Session history will be stored in /root/.scope/history and owned by root
Attaching to process 3029
root@precision:/home/sean/sandbox# scope metrics
NAME             VALUE              TYPE     UNIT           PID     TAGS
proc.start       1                  Count    process        3029    args: /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sā€¦
proc.cpu         3.990642489e+09    Count    microsecond    3029    host: precision,proc: dockerd
proc.cpu_perc    39906.42489        Gauge    percent        3029    host: precision,proc: dockerd
proc.mem         3.905616e+06       Gauge    kibibyte       3029    host: precision,proc: dockerd
proc.thread      42                 Gauge    thread         3029    host: precision,proc: dockerd
proc.fd          25                 Gauge    file           3029    host: precision,proc: dockerd
proc.child       41                 Gauge    process        3029    host: precision,proc: dockerd
root@precision:/home/sean/sandbox# scope events
Empty event file.

Environment

- AppScope: 1.3.1
- OS: ubuntu 22.04
- Architecture: x86
- Kernel: 5.19.0-38-generic

Scope using LD_PRELOAD fails for redis glibc container

Steps To Reproduce

Scoping following container fails
Dockerfile.redis:

FROM redis:6

COPY --from=cribl/scope:1.3.2 /usr/local/bin/scope /usr/local/bin/scope
RUN /usr/local/bin/scope extract /usr/local/lib/

ENV LD_PRELOAD="/usr/local/lib/libscope.so"

# Expose Redis port
EXPOSE 6379

# Start Redis server
CMD ["redis-server"]
docker build --file Dockerfile.redis --tag myredis:latest .
docker run myredis:latest

There is no libscope.so in the redis process above

Scoping same container using different image works fine:

Dockerfile.alpine:

FROM redis:6-alpine

COPY --from=cribl/scope:1.3.2 /usr/local/bin/scope /usr/local/bin/scope
RUN /usr/local/bin/scope extract /usr/local/lib/

ENV LD_PRELOAD="/usr/local/lib/libscope.so"

# Expose Redis port
EXPOSE 6379

# Start Redis server
CMD ["redis-server"]
docker build --file Dockerfile.alpine --tag myredisalpine:latest .
docker run myredisalpine

Environment

- AppScope: 1.3.1
- OS: Ubuntu
- Architecture: x86_64
- Kernel: 5.19

The fs.read metric is not produced when we read a file

When we read a file with this test app (calling read or __read_chk), I observed that we do not produce an fs.read metric event. Also, in the fs.close event associated with the file read, file_read_bytes does not change from 0.

#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>

#define SIZE 512
static int fd;
static char buf[SIZE];

void verify_read(void) {
	//__read_chk(fd, buf, SIZE, SIZE);
	read(fd, buf, SIZE);
}

void setup(void) {
	memset(buf, '*', SIZE);
	fd = open("testfile", O_RDWR | O_CREAT, 0700);
	write(fd, buf, SIZE);
}

void cleanup(void) {
	if (fd > 0) close(fd);
}

int main() {
	setup();
	verify_read();
	cleanup();
}

We do see expected results using other commands:

SCOPE_EVENT_METRIC=true ./bin/linux/x86_64/scope head [some file]
scope events

Warning appears in scoped npm process

npm 8.5.1
ubuntu 22.04

$ scope npm install express
$ /usr/bin/npm is not a viable ELF file

The child node process is successfully scoped, but because npm runs a script, AppScope throws a warning about the file format.

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.