[20210222]gdb ptrace Operation not permitted.txt
[20210222]gdb ptrace Operation not permitted.txt
--//嘗試使用gdb除錯,發現如下錯誤.
$ gdb -p 59148
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-119.0.1.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<
Attaching to process 59148
ptrace: Operation not permitted.
(gdb) quit
--//上網查了一下,都是報2個gdb程式attach的情況,還有就是有人使用strace.我這種情況不存在.
--//還有一種情況我這裡也不存在.連結
https://blog.csdn.net/fjh1997/article/details/101881649
解決gdb除錯在WSL環境下報錯"ptrace: Operation not permitted"
需要把下列檔案裡面的變數改成0(原來是1)
echo 0 > /proc/sys/kernel/yama/ptrace_scope
或者
echo kernel.yama.ptrace_scope = 0 > /etc/sysctl.d/10-ptrace.conf #這個是持久化
--//主動使用strace跟蹤發現:
87442 open("/proc/26016/status", O_RDONLY) = 7
87442 fstat(7, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
87442 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f6ff8db4000
87442 read(7, "Name:\toracle_26016_dy\nUmask:\t002"..., 1024) = 1024
87442 close(7) = 0
87442 munmap(0x7f6ff8db4000, 4096) = 0
87442 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
87442 write(2, "ptrace: Operation not permitted.", 32) = 32
87442 write(2, "\n", 1) = 1
--//應該是執行到下劃線時報錯.
$ man rt_sigprocmask
SIGPROCMASK(2) Linux Programmer's Manual SIGPROCMASK(2)
NAME
sigprocmask - examine and change blocked signals
# cat /proc/76821/status | head
Name: oracle_76821_dy
Umask: 0022
State: S (sleeping)
Tgid: 76821
Ngid: 0
Pid: 76821
PPid: 1
TracerPid: 0
Uid: 1000 1001 1001 1001
Gid: 1001 1004 1004 1004
--//我對比發現多了1個Umask(與11g),注意name不再是oracle,而是變成了oracle_程式號_sid前2個字元.
49971 open("/proc/49969/status", O_RDONLY) = 7
49971 fstat(7, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
49971 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f201cd3f000
49971 read(7, "Name:\toracle\nState:\tt (tracing s"..., 1024) = 1024
49971 close(7) = 0
49971 munmap(0x7f201cd3f000, 4096) = 0
49971 wait4(49969, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGSTOP}], 0, NULL) = 49969
49971 fcntl(0, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE)
49971 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
49971 ioctl(0, TIOCGPGRP, [49970]) = 0
49971 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
49971 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
49971 rt_sigaction(SIGINT, {0x45daa0, [INT], SA_RESTORER|SA_RESTART, 0x3799030330}, {0x524e30, [INT], SA_RESTORER|SA_RESTART, 0x3799030330}, 8) = 0
49971 rt_sigaction(SIGINT, {0x524e30, [INT], SA_RESTORER|SA_RESTART, 0x3799030330}, {0x45daa0, [INT], SA_RESTORER|SA_RESTART, 0x3799030330}, 8) = 0
49971 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
49971 brk(0x2dd4000) = 0x2dd4000
49971 ptrace(PTRACE_GETREGS, 49969, 0, 0x7fff445538c0) = 0
--//換成root使用者執行gdb,OK. 再次使用strace 跟蹤,注不知道為什麼不能加入-f引數.
open("/proc/89651/status", O_RDONLY) = 7
fstat(7, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f93c8df0000
read(7, "Name:\toracle_89651_dy\nUmask:\t002"..., 1024) = 1024
close(7) = 0
munmap(0x7f93c8df0000, 4096) = 0
wait4(89651, [{WIFSTOPPED(s) && WSTOPSIG(s) == SIGSTOP}], 0, NULL) = 89651
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {sa_handler=0x6ce6a0, sa_mask=[INT], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f93c6a0f400}, {sa_handler=0x5e5aa0, sa_mask=[INT], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f93c6a0f400}, 8) = 0
rt_sigaction(SIGINT, {sa_handler=0x5e5aa0, sa_mask=[INT], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f93c6a0f400}, {sa_handler=0x6ce6a0, sa_mask=[INT], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f93c6a0f400}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--//僅僅確定執行rt_sigprocmask時報錯.也許是許可權的問題.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2758514/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 在Docker內部使用gdb偵錯程式報錯-Operation not permittedDockerMIT
- [Javascript] ++operationJavaScript
- tidb Error: Operation aborted by user answer '' (cliutil.operation_aborted)TiDBError
- gdb
- Linux ptrace詳細分析系列(二)Linux
- gdb (lldb)LLDB
- Python GDBPython
- ptrace attach 修改程序記憶體記憶體
- macOS: sudo : Operation not permittedMacMIT
- [Javascript] Encapsulate chunk operationJavaScript
- [原創] Linux ptrace詳細分析系列(一)Linux
- gdb 基礎
- gdb除錯除錯
- FSMO(Flexible Single Master Operation)FlexAST
- 3.4.3 Restoring the System to Normal OperationRESTORM
- group by event_name, operation
- 實現交叉編譯gdb和gdbserver(gdb-7.6)編譯Server
- 反除錯 -- 利用ptrace阻止偵錯程式附加除錯
- cuda runtime error (801) : operation not supportedError
- [20230103]COUNT STOPKEY operation.txtTopK
- GDB除錯指令除錯
- Debuggers 1012:Introductory GDB
- GDB交叉編譯編譯
- 升級redhat 6.8 預設gdb 7.2到gdb 8.3.1操作指南Redhat
- 多執行緒:Operation和OperationQueue執行緒
- Oracle 18.3 Resize operation completed for file#Oracle
- NFS mount results in "vmount: operation not permitted" errorNFSMITError
- GDB 除錯程式碼除錯
- GDB學習筆記筆記
- gdb 如何呼叫函式?函式
- gdb除錯多程序除錯
- gdb 檢視 jsoncpp物件JSON物件
- gdb除錯總結除錯
- gdb除錯快速上手除錯
- gdb 常用命令
- 如何利用Ptrace攔截和模擬Linux系統呼叫Linux
- 使用 Ptrace 去攔截和模擬 Linux 系統呼叫Linux
- iOS:The operation couldn’t be completed. (DVTCoreSimulatorAdditionsErrorDomain eiOSErrorAI