171
http://bit.ly/33NpWEk Linux Systems Linux Systems Troubleshooting Troubleshooting Thomas Uphill Thomas Uphill [email protected] [email protected]

Troubleshooting L inux Systems - usenix.org

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Linux SystemsLinux SystemsTroubleshootingTroubleshooting

Thomas UphillThomas [email protected]@uphillian.com

Page 2: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

MeMe

[email protected]@uphillian.com

Page 3: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ResourcesResources

tutorial.mdtutorial.md

https://github.com/uphillian/lisa2019https://github.com/uphillian/lisa2019

https://github.com/uphillian/troubleshootinglinuxhttps://github.com/uphillian/troubleshootinglinux

Page 4: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

A storyA story

Page 5: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Page 6: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

DB

Page 7: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

DB ⇨

Page 8: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

DB ⇨ gethostname

Page 9: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

DB ⇨ gethostname

Page 10: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

DB ⇨ gethostname

Backup

Page 11: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

DB ⇨ gethostname

Backup ⇨

Page 12: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

DB ⇨ gethostname

Backup ⇨ gethostname

Page 13: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

DB ⇨ gethostname

Backup ⇨ gethostname

Page 14: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

DB ⇨ gethostname

Backup ⇨ gethostname

Page 15: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

DB ⇨ gethostname

Backup ⇨ gethostname

Page 16: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

DB ⇨ gethostname

Backup ⇨ gethostname

Page 17: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Where to start?Where to start?

Page 18: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ltraceltrace

Page 19: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ltraceltraceWhy?

Page 20: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ltraceltrace

Page 21: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ltraceltrace Because UNIX is old

Page 22: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Page 23: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Page 24: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Page 25: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Love KenLove Ken

Page 26: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Love KenLove KenKISSKISS

Page 27: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

How it all worksHow it all works

Page 28: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

KernelKernel

Page 29: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

KernelKernel

Page 30: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

KernelKernel

hardware

Page 31: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

KernelKernel

⇳ driver/module ⇳

hardware

Page 32: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

KernelKernelapplication

⇳ driver/module ⇳

hardware

Page 33: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

KernelKernelapplication

⇳ system calls ⇳

⇳ driver/module ⇳

hardware

Page 34: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

KernelKernelapplication user

⇳ system calls ⇳

⇳ driver/module ⇳

hardware

Page 35: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

KernelKernelapplication user

⇳ system calls ⇳

kernel

⇳ driver/module ⇳

hardware

Page 36: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

System CallsSystem Calls

Page 37: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

DocumentationDocumentation

Page 38: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

DocumentationDocumentation

Page 39: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

DocumentationDocumentation

man syscalls man syscalls

Page 40: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

DocumentationDocumentation

man syscalls man syscalls ⇒⇒

Page 41: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Shared LibrariesShared Libraries

Page 42: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Shared LibrariesShared Librariesglibcglibc

Page 43: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Shared LibrariesShared Librariesglibcglibc

libc.solibc.so

Page 44: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ltraceltrace

Page 45: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ltraceltrace...�nally...�nally

Page 46: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

[root@localhost ~]# ltrace hostname _libc_start_main(0x401230, 1, 0x7ffd4a91dd48, 0x401ea0 <unfinished ..rindex("hostname", '/') = nistrcmp("hostname", "domainname") = 4 strcmp("hostname", "ypdomainname") = -1strcmp("hostname", "nisdomainname") = -6getopt_long(1, 0x7ffd4a91dd48, "aAdfbF:h?iIsVy", 0x4028a0, nil) = -1__errno_location() = 0xmalloc(128) = 0xgethostname("localhost.localdomain", 128) = 0 memchr("localhost.localdomain", '\0', 128) = 0xputs("localhost.localdomain"localhost.localdomain) = 22+++ exited (status 0) +++

Page 47: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

[root@localhost ~]# ltrace -S hostname brk@SYS(nil) mmap@SYS(nil, 4096, 3, 34, -1, 0) access@SYS("/etc/ld.so.preload", 04) open@SYS("/etc/ld.so.cache", 524288, 01) fstat@SYS(3, 0x7ffcfb5c0830) mmap@SYS(nil, 22425, 1, 2, 3, 0) close@SYS(3) open@SYS("/lib64/libnsl.so.1", 524288, 022033410520) read@SYS(3, "\177ELF\002\001\001", 832) fstat@SYS(3, 0x7ffcfb5c0890) mmap@SYS(nil, 2202232, 5, 2050, 3, 0) mprotect@SYS(0x7f28902ba000, 2097152, 0) mmap@SYS(0x7f28904ba000, 8192, 3, 2066, 3, 90112) mmap@SYS(0x7f28904bc000, 6776, 3, 50, -1, 0) close@SYS(3) open@SYS("/lib64/libc.so.6", 524288, 022033410520) read@SYS(3, "\177ELF\002\001\001\003", 832) fstat@SYS(3, 0x7ffcfb5c0860) mmap@SYS(nil, 3981792, 5, 2050, 3, 0) mprotect@SYS(0x7f2890099000, 2097152, 0) mmap@SYS(0x7f2890299000, 24576, 3, 2066, 3, 1843200) mmap@SYS(0x7f289029f000, 16864, 3, 50, -1, 0) close@SYS(3)

Page 48: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

# file /bin/hostname /bin/hostname: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), d

Page 49: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Page 50: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ExecutableExecutableand

LinkableLinkableFormatFormat

Page 51: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

LinkerLinkerld.sold.so

/etc/ld.so.conf/etc/ld.so.conf/lib64/ld-linux-x86_64.so.2/lib64/ld-linux-x86_64.so.2

man ld.soman ld.so

Page 52: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

# ldd /bin/hostname linux-vdso.so.1 => (0x00007ffcda7dd000) libnsl.so.1 => /lib64/libnsl.so.1 (0x00007f43c4f06000) libc.so.6 => /lib64/libc.so.6 (0x00007f43c4b39000) /lib64/ld-linux-x86-64.so.2 (0x00007f43c5120000) # objdump -R /bin/hostname /bin/hostname: file format elf64-x86-64 DYNAMIC RELOCATION RECORDS OFFSET TYPE VALUE ... 0000000000603140 R_X86_64_JUMP_SLOT gethostname@GLIBC_2.2.5 # man ld.so

Page 53: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

man ld.soman ld.soLD_PRELOADLD_PRELOAD

A list of additional, user-specified, ELF shared librariesto be loaded before all others.

Page 54: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

man ld.soman ld.soLD_DEBUGLD_DEBUG

# LD_DEBUG=help /bin/true Valid options for the LD_DEBUG environment variable are: libs display library search paths reloc display relocation processing files display progress for input file ... # LD_DEBUG=versions /bin/true checking for version `GLIBC_2.3' in file /lib64/libc.so.6 [0] checking for version `GLIBC_2.3.4' in file /lib64/libc.so.6 [0checking for version `GLIBC_2.14' in file /lib64/libc.so.6 [0]

Page 55: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

man ld.soman ld.soLD_DEBUGLD_DEBUG

⇒ ⇒⇒ ⇒

# LD_DEBUG=help /bin/true Valid options for the LD_DEBUG environment variable are: libs display library search paths reloc display relocation processing files display progress for input file ... # LD_DEBUG=versions /bin/true checking for version `GLIBC_2.3' in file /lib64/libc.so.6 [0] checking for version `GLIBC_2.3.4' in file /lib64/libc.so.6 [0checking for version `GLIBC_2.14' in file /lib64/libc.so.6 [0]

Page 56: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Terminal

Page 57: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

You cannot escapeYou cannot escape

wikipedia.org

Page 58: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

getip.cgetip.c#include <netdb.h>#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <netinet/in.h>#include <sys/socket.h>#include <sys/types.h>#include <arpa/inet.h> int main() { char hostname[256]; char *IPbuffer; struct hostent *hostStruct; int h; gethostname(hostname, sizeof(hostname)); hostStruct = gethostbyname(hostname);

Page 59: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

gethostnamegethostname#include <unistd.h> int gethostname(char *name, size_t len);

Page 60: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

gethostname_wrap.cgethostname_wrap.c#include <unistd.h>#include <string.h>#include <stdio.h>#include <stdlib.h> int gethostname (char *name, size_t len) { char newname[] = "getip_hostname"; int name_len = strlen(newname); memcpy(name,newname, name_len < len ? name_len : len); return 0; }

Page 61: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

SolutionSolution⇐⇐

Page 62: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

SolutionSolution⇐⇐

Page 63: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

It's a machine, Skroeder.It doesn't get pissed off.It doesn't get happy,it doesn't get sad,it doesn't laugh at your jokes.It just runs programs.

Short Circuit

Page 64: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

More backgroundMore background

Page 65: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Booting processBooting process

Page 66: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Booting processBooting processBIOS

Page 67: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Booting processBooting processBIOS Bootsector

0

Page 68: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Booting processBooting processBIOS Bootsector

0Bootloader512

Page 69: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Booting processBooting processBIOS Bootsector

0Bootloader512

Kernel[0]

Page 70: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Booting processBooting processBIOS Bootsector

0Bootloader512

Kernel[0]

init1

Page 71: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ProcessesProcesses

Page 72: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ProcessesProcessesforkfork

Page 73: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ProcessesProcessesforkfork

Page 74: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

parent/childparent/child $ ps -eo "ppid pid stat cmd" |sort -n |less $ psx $ psk

Page 75: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

parent/childparent/child

⇒⇒

$ ps -eo "ppid pid stat cmd" |sort -n |less $ psx $ psk

Page 76: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

fake �lesystemsfake �lesystems

Page 77: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

fake �lesystemsfake �lesystems

Page 78: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

fake �lesystemsfake �lesystems

/proc

Page 79: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

fake �lesystemsfake �lesystems

/proc /sys

Page 80: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

fake �lesystemsfake �lesystems

/proc /sys

⇒⇒

Page 81: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

File DescriptorsFile Descriptors

Page 82: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

File DescriptorsFile Descriptors

STDIN

0

Page 83: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

File DescriptorsFile Descriptors

STDIN STDOUT

0 1

Page 84: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

File DescriptorsFile Descriptors

STDIN STDOUT STDERR

0 1 2

Page 85: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

File DescriptorsFile Descriptorseverything is a �le...everything is a �le...

STDIN STDOUT STDERR

0 1 2

Page 86: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

File DescriptorsFile Descriptorseverything is a �le...everything is a �le...

STDIN STDOUT STDERR

0 1 2

⇒⇒

Page 87: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ProcessesProcesses

Page 88: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ProcessesProcessesfork

Page 89: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ProcessesProcessesfork double fork

Page 90: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ProcessesProcessesfork double fork

Page 91: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ProcessesProcessesfork double fork

Page 92: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ProcessesProcessesfork double fork zombie

Page 93: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

fork

#!/usr/bin/env python import os import time pid = os.fork() if pid == 0: print("Child") while True: time.sleep(10) else: print("Parent, Child PID: %s" % pid) while True: time.sleep(10)

Page 94: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

doublefork

#!/usr/bin/env python import os import time pid = os.fork() if pid == 0: pid = os.fork() if pid == 0: print("I am the Grandchild(%s)\n" % os.getpid()) while True: time.sleep(10) else: print("I am the Child(%s), Grandchild(%s)\n" % (os.getpid(),pid))else: print("I am the Parent(%s), my Child(%s)\n" % (os.getpid(),pid))

Page 95: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

zombie

#!/usr/bin/env python import os import sys import time import signal def sigalrm(signum, frame): print("Received %d" % signum) signal.signal(signal.SIGALRM, sigalrm) pid = os.fork() if pid == 0: print("Child exiting") sys.exit(0) else: print("Parent PID %s, Child PID: %s\nWaiting for Signal" % (os.getp signal.pause() os.wait() print("Zombie is gone\n") sys.exit(0)

Page 96: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

⇒⇒

Page 97: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ThreadsThreads $ ./thread.py $ pst thread PPID PID STAT CMD SPID 4671 6760 - /usr/bin/python ./thread.py - - - Tl - 6760 - - Tl - 6761 - - Tl - 6762 - - Tl - 6763 - - Tl - 6764 - - Tl - 6765 - - Tl - 6766 - - Tl - 6767 - - Tl - 6768 - - Tl - 6769 - - Tl - 6770 $ ls /proc/6760/task 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770

Page 98: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

LimitsLimits⇒⇒

Page 99: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

PAMPAMPluggablePluggable

AuthenticationAuthenticationModulesModules

Page 100: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

PAMPAMPluggablePluggable

AuthenticationAuthenticationModulesModulesman pamman pam

Page 101: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Terminal

Page 102: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Another storyAnother story

Page 103: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Page 104: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

inodesinodes

Page 105: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

inodesinodes $ stat /lib64/libc.so.6 File: /lib64/libc.so.6 -> libc-2.29.so Size: 12 Blocks: 0 IO Block: 4096 symbolic link Device: fd01h/64769d Inode: 2268443 Links: 1 Access: (0777/lrwxrwxrwx) Uid:(0/root) Gid:(0/root)Context: system_u:object_r:lib_t:s0 Access: 2019-10-24 20:01:01.282015177 -0700 Modify: 2019-09-04 12:33:47.000000000 -0700 Change: 2019-09-08 19:57:02.255027798 -0700 Birth: 2019-09-08 19:57:02.254027799 -0700

Page 106: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

UnlinkUnlink

Page 107: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

UnlinkUnlink # man 2 unlink DESCRIPTION unlink() deletes a name from the filesystem. If that name was the last link to a file and no processes have the file open, the file is deleted and the space it was using is made available for reuse. If the name was the last link to a file but any processes still have the file open, the file will remain in existence until the last file descriptor referring to it is closed.

Page 108: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Page 109: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

gdbgdb

Page 110: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

gdbgdb

Page 111: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

... /usr/include/fcntl.h

... /usr/include/bits/fcntl.h

# man open SYNOPSIS #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h>

/* Get the definitions of O_*, F_*, FD_*: all the numbers and flag bits for `open', `fcntl', et al. */ #include <bits/fcntl.h>

#define O_RDWR 02 #ifndef O_CREAT # define O_CREAT 0100 /* Not fcntl. */ #endif

Page 112: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

# man dup2 int dup2(int oldfd, int newfd); dup2() The dup2() system call performs the same task as dup(), but instead of using the lowest-numbered unused file descriptor, it uses the file descriptor number specified in newfd. If the file descriptor newfd was previ‐ ously open, it is silently closed before being reused.

Page 113: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

⇐⇐

Page 114: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

⇐⇐

Page 115: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

TroubleshootingTroubleshooting

Page 116: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

TroubleshootingTroubleshooting...�nally...�nally

Page 117: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Have a PlanHave a PlanWhat is broken?

Did it ever work?How do I know when it's fixed?

What are the requirements?How can I test the requirements?

When did it last work?

Page 118: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Troubleshooting StepsTroubleshooting StepsMake a backupMake a backupRead LogsRead LogsJust one thing.Just one thing.

Page 119: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Troubleshooting StepsTroubleshooting StepsMake a backupMake a backupRead LogsRead LogsJust one thing.Just one thing.

Page 120: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Page 121: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

change onething

Page 122: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

change onething

verifystatus

Page 123: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

change onething

verifystatus

if unfixed, undochange

Page 124: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

change onething

verifystatus

if unfixed, undochange

repeat

Page 125: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

TraceTraceltraceman <call>SEE ALSO

Page 126: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

TraceTraceltraceman <call>SEE ALSO...keep reading

Page 127: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Page 128: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

imdb.com

Page 129: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Page 130: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Processes

Page 131: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ProcessesUsers/Groups

Page 132: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ProcessesUsers/GroupsPermissions

Page 133: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ProcessesUsers/GroupsPermissionsrunuser

Page 134: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ProcessesUsers/GroupsPermissionsrunuser

Space

Page 135: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ProcessesUsers/GroupsPermissionsrunuser

SpaceNSS

Page 136: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ProcessesUsers/GroupsPermissionsrunuser

SpaceNSSNetwork

Page 137: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Always check permissionsAlways check permissionsrunuserrunuser

Page 138: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Please check permissionsPlease check permissionsHokey religions and ancient weaponsHokey religions and ancient weapons

are no match forare no match for

Page 139: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Please check permissionsPlease check permissionsHokey religions and ancient weaponsHokey religions and ancient weapons

are no match forare no match for

BASIC UNIX PERMISSIONSBASIC UNIX PERMISSIONS

Page 140: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

runuserrunuser # cat /var/www/html/index.html Hello World! # runuser apache -s /bin/bash -c 'cat /var/www/html/index.html' cat: /var/www/html/index.html: Permission denied

Page 141: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

NetworkingNetworking

Page 142: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

NetworkingNetworking

Page 143: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

nssnssname service switchname service switch

Page 144: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

nssnssname service switchname service switch

/etc/hosts/etc/hosts

Page 145: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

nssnssname service switchname service switch

/etc/hosts/etc/hosts

/etc/nsswitch.conf/etc/nsswitch.conf

Page 146: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Page 147: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname

Page 148: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname

passwd: db sss files systemd

Page 149: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

⇐ ⇐⇐ ⇐

Page 150: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

# ltrace tar cf lisa2019:f.tar /etc/hosts 2>&1 |grep gethost gethostbyname("lisa2019" <unfinished ...=""> </unfinished>

Page 151: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

# ltrace tar cf lisa2019:f.tar /etc/hosts 2>&1 |grep gethost gethostbyname("lisa2019" <unfinished ...=""> </unfinished>

# ltrace -S ping -w1 -c1 lisa2019 2>&1 |grep nss open@SYS("/etc/nsswitch.conf", 524288, 0666) = 4 read@SYS(4, "#\n# /etc/nsswitch.conf\n#\n# An ex"..., 4096) = open@SYS("/lib64/libnss_files.so.2", 524288, 020165240000) = 4

Page 152: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ncnc

Page 153: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

ncnc

Page 154: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

⇐ ⇐ ⇐⇐ ⇐ ⇐

Page 155: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

tcpdump / wiresharktcpdump / wiresharkmtr / traceroutemtr / traceroute

Page 156: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Encryption / Certi�catesEncryption / Certi�catesx509x509

large primeslarge primes

Page 157: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Page 158: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

CA / verifyCA / verify $ openssl verify -CAfile ca.pem getip.example.com.pem getip.example.com.pem: OK

Page 159: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

CA / verifyCA / verify $ openssl verify -CAfile ca.pem getip.example.com.pem getip.example.com.pem: OK

$ cat ca.pem crl-revoked.pem >ca_crl.pem $ openssl verify -CAfile ca_crl.pem -crl_check getip.example.cgetip.example.com.pem: CN = getip.example.com error 11 at 0 depth lookup:CRL is not yet valid CN = getip.example.com error 23 at 0 depth lookup:certificate revoked

Page 160: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

$ openssl x509 -in getip.example.com.pem -noout -modulus Modulus=ACCBE50557F389F778505BD8C147FAD75A91DDA346D6CB4D006496... $ openssl x509 -in getip.example.com.pem -noout -modulus |sha22688b20c253241e1e291f4cab938d6a1b43a68ac158da47ebba60cfa48e641

Page 161: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

$ openssl x509 -in getip.example.com.pem -noout -modulus Modulus=ACCBE50557F389F778505BD8C147FAD75A91DDA346D6CB4D006496... $ openssl x509 -in getip.example.com.pem -noout -modulus |sha22688b20c253241e1e291f4cab938d6a1b43a68ac158da47ebba60cfa48e641

$ openssl rsa -in private_keys/getip.example.com.pem -noout 2688b20c253241e1e291f4cab938d6a1b43a68ac158da47ebba60cfa48e641

Page 162: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

$ gnutls-cli -p <port> <host> $ openssl s_client <host>:<port></port></host></host></port>

Page 163: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

SummarySummary

Page 164: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

SummarySummaryTrust no oneTrust no one

Page 165: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

SummarySummaryTrust no oneTrust no one

Check permissions (runuser)Check permissions (runuser)

Page 166: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

SummarySummaryTrust no oneTrust no one

Check permissions (runuser)Check permissions (runuser)Read: Logs, DocsRead: Logs, Docs

Page 167: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

SummarySummaryTrust no oneTrust no one

Check permissions (runuser)Check permissions (runuser)Read: Logs, DocsRead: Logs, Docs

One thingOne thing

Page 168: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Questions?Questions?

Page 169: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Questions?Questions?Thank-youThank-you

Page 170: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk

Questions?Questions?Thank-youThank-you

[email protected]@uphillian.com

Page 171: Troubleshooting L inux Systems - usenix.org

http://bit.ly/33NpWEk