Skip to content

Mac M1 Ptrace - warning: ptrace: Function not implemented #5191

@HenryHoggard

Description

@HenryHoggard

Expected behavior

  • Should be able to debug binary using gdb in Docker container.
  • The same Dockerfile and commands work on my older x86-64 mac, so either there is an issue with ptrace on Docker preview for M1 macs, or I'm doing something wrong.

Actual behavior

  • Cannot debug due to ptrace being unavailable with the below error:
gdb /bin/echo
> run
Starting program: /bin/echo
warning: Could not trace the inferior process.
warning: ptrace: Function not implemented
During startup program exited with code 127.

Information

  • macOS Version: 11.1 (20C69)
  • Docker for Mac Preview 20.10.0 / 0.0.0
  • MacBook Pro (13-inch, M1, 2020)
  • Container: Linux b619d811f2eb 4.19.104-linuxkit #1 SMP PREEMPT Sat Feb 15 00:49:47 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Steps to reproduce the behavior

Dockerfile

FROM phusion/baseimage:master-amd64

ENV DEBIAN_FRONTEND noninteractive

RUN dpkg --add-architecture i386 && \
    apt-get -y update && \
    apt install -y \
    vim \
    python3-dev \
    python3-pip \
    build-essential \
    strace \
    ltrace \
    nasm \
    gdb \
    netcat \
    git \
    zsh \
    wget \
    sudo \
    tmux \
    unzip

RUN pip3 install \
    pwntools \
    angr \
    r2pipe

RUN git clone --depth 1 https://github.com/pwndbg/pwndbg && \
    cd pwndbg && chmod +x setup.sh && ./setup.sh

WORKDIR /gdb/

RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true

CMD ["/bin/zsh"]

Run command:

docker run --rm -v $PWD:/gdb --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --security-opt apparmor=unconfined -d --name gdbdocker --privileged -i gdbdocker
 docker exec -it --privileged gdbdocker /bin/zsh

I have also tried the following command inside Docker but it makes no difference:

echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions