commandline session
$pidof $ $pidof $pidof init 1 $pidof vmlinuz $ $echo $? 1 $pidof init 1 $echo $? 0 $pidof rootd 3706 $pidof kcore $echo $? 1 $
BEAUTY AND PLAY
$pidof $ $pidof $pidof init 1 $pidof vmlinuz $ $echo $? 1 $pidof init 1 $echo $? 0 $pidof rootd 3706 $pidof kcore $echo $? 1 $
$groups jeffrin tty dialout audio www-data mysql wireshark $groups --version | grep David Written by David MacKenzie and James Youngman. $ $groups jeffrin jeffrin : jeffrin tty dialout audio www-data wireshark mysql $groups user groups: user: no such user $groups mysql mysql : mysql $groups wireshark groups: wireshark: no such user $groups www-data www-data : www-data $groups tty groups: tty: no such user $groups dialout groups: dialout: no such user $groups audio groups: audio: no such user $
ABOUT gcov
Gcov is a source code coverage analysis and statement-by-statement profiling tool. Gcov generates exact counts of the number of times each statement in a program is executed and annotates source code to add instrumentation. Gcov comes as a standard utility with the GNU Compiler Collection (GCC) suite.[1] The gcov utility gives information on how often a program executes segments of code.[2] It produces a copy of the source file, annotated with execution frequencies. The gcov utility does not produce any time-based data and works only on code compiled with the GCC suite. The manual claims it is not compatible with any other profiling or test coverage mechanism,[3] but it works with llvm-generated files, too.
A TYPICAL SHELL SESSION
[bash]
$ls
loop.c
$gcc -fprofile-arcs -ftest-coverage loop.c
$ls
a.out loop.c loop.gcno
$./a.out
^C
$ls
a.out loop.c loop.gcno
$gcov loo
loop.c loop.gcno
$gcov loop.c
loop.gcda:cannot open data file, assuming not executed
File ‘loop.c’
No executable lines
Removing ‘loop.c.gcov’
$cat loo
loop.c loop.gcno
$cat loop.c
main()
{
for (;;);
}
$cp /home/jeffrin/loop.c .
$cat loop.c
main()
{
printf("hello world");
}
$gcc -fprofile-arcs -ftest-coverage loop.c
loop.c: In function ‘main’:
loop.c:3:1: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
$./a.out
hello world$
$gcov loop.c
File ‘loop.c’
Lines executed:100.00% of 3
Creating ‘loop.c.gcov’
$cat loop.c.gcov
-: 0:Source:loop.c
-: 0:Graph:loop.gcno
-: 0:Data:loop.gcda
-: 0:Runs:1
-: 0:Programs:1
1: 1:main()
-: 2:{
1: 3:printf("hello world");
1: 4:}
-: 5:
$
[/bash]
LINK
https://en.wikipedia.org/wiki/Gcov
$autoreconf -v -i autoreconf: Entering directory `.' autoreconf: configure.ac: not using Gettext autoreconf: running: aclocal -I m4 autoreconf: configure.ac: tracing autoreconf: configure.ac: adding subdirectory c++-impl to autoreconf autoreconf: Entering directory `c++-impl' autoreconf: running: aclocal autoreconf: configure.ac: adding subdirectory stl to autoreconf autoreconf: Entering directory `stl' autoreconf: running: libtoolize --copy libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'. libtoolize: copying file `m4/libtool.m4' libtoolize: copying file `m4/ltoptions.m4' libtoolize: copying file `m4/ltsugar.m4' libtoolize: copying file `m4/ltversion.m4' libtoolize: copying file `m4/lt~obsolete.m4' libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am. autoreconf: running: /usr/bin/autoconf autoreconf: running: /usr/bin/autoheader autoreconf: running: automake --add-missing --copy --no-force autoreconf: Leaving directory `stl' libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am. autoreconf: Leaving directory `c++-impl' libtoolize: `AC_PROG_RANLIB' is rendered obsolete by `LT_INIT' autoreconf: configure.ac: not using Automake autoreconf: Leaving directory `.' $
[bash]
root>insserv -v
insserv: creating .depend.boot
insserv: creating .depend.start
insserv: creating .depend.stop
root>insserv /etc/ini
init/ init.d/ initramfs-tools/ inittab
root>insserv -v /etc/init.d/gpm
insserv: creating .depend.boot
insserv: creating .depend.start
insserv: creating .depend.stop
root>insserv -s
K:02:0 1 6:network-manager
K:08:0 6:umountfs
K:05:0 6:umountnfs.sh
K:03:0 6:sendsigs
K:04:0 1 6:rsyslog
K:01:0 1 6:minissdpd
K:01:0 1 6:portmap
K:07:0 6:networking
K:01:0 1 6:wicd
K:02:0 1 6:xen
K:01:0 1 6:xdm
K:02:1:hal
K:01:0 1 6:exim4
K:07:0 6:hwclock.sh
K:01:0 1 6:alsa-utils
K:01:0 1 6:gdm3
K:10:0:halt
K:01:0 1 6:apache2
K:01:0 6:urandom
K:01:0 1 6:speech-dispatcher
K:01:0 1 6:anacron
K:01:0 1 6:wdm
K:01:0 6:unattended-upgrades
K:01:0 1 6:xendomains
K:06:0 1 6:nfs-common
K:06:0 1 6:rpcbind
K:02:0 1 6:avahi-daemon
K:01:0 1 6:cups-browsed
K:01:0 1 6:atd
K:01:0 1 6:saned
K:09:0 6:umountroot
K:10:6:reboot
K:01:0 1 6:gdomap
K:01:0 1 6:gnunet-server
K:01:0 1 6:gpm
K:01:0 1 6:bluetooth
K:01:1:cups
K:01:1:pulseaudio
S:02:S:udev
S:05:S:keyboard-setup
S:19:S:console-setup
S:20:2 3 4 5:network-manager
S:10:S:mountall.sh
S:11:S:mountall-bootclean.sh
S:16:S:mountnfs.sh
S:17:S:mountnfs-bootclean.sh
S:19:2 3 4 5:dbus
S:17:2 3 4 5:rsyslog
S:23:2 3 4 5:minissdpd
S:14:2 3 4 5 S:portmap
S:13:S:networking
S:20:2 3 4 5:wicd
S:19:2 3 4 5:xen
S:21:2 3 4 5:xdm
S:20:2 3 4 5:hal
S:19:2 3 4 5:exim4
S:06:S:hwclock.sh
S:03:S:mountdevsubfs.sh
S:07:S:checkroot.sh
S:20:S:alsa-utils
S:21:2 3 4 5:gdm3
S:18:2 3 4 5:apache2
S:12:S:urandom
S:19:2 3 4 5:speech-dispatcher
S:19:2 3 4 5:anacron
S:01:S:mountkernfs.sh
S:21:2 3 4 5:wdm
S:20:S:x11-common
S:18:S:kbd
S:19:2 3 4 5:acpid
S:20:2 3 4 5:xendomains
S:15:2 3 4 5 S:nfs-common
S:14:2 3 4 5 S:rpcbind
S:20:2 3 4 5:avahi-daemon
S:21:2 3 4 5:cups-browsed
S:19:2 3 4 5:atd
S:21:2 3 4 5:saned
S:19:2 3 4 5:gdomap
S:19:2 3 4 5:gnunet-server
S:19:2 3 4 5:gpm
S:20:2 3 4 5:bluetooth
S:21:2 3 4 5:cups
S:22:1 2 3 4 5:bootlogs
S:06:S:hostname.sh
S:23:1:single
S:01:1:killprocs
S:21:2 3 4 5:pulseaudio
S:01:1 2 3 4 5:motd
S:23:2 3 4 5:rc.local
S:23:2 3 4 5:stop-bootlogd
S:19:2 3 4 5:cron
S:19:2 3 4 5:sysstat
S:23:2 3 4 5:rmnologin
S:19:2 3 4 5:loadcpufreq
S:20:2 3 4 5:cpufrequtils
S:17:2 3 4 5:binfmt-support
S:17:2 3 4 5:sudo
S:19:2 3 4 5:tpconfig
S:19:2 3 4 5:rsync
S:19:2 3 4 5:ssh
S:19:2 3 4 5:mcelog
S:12:S:procps
S:08:S:checkroot-bootclean.sh
S:20:S:bootmisc.sh
S:12:S:udev-mtab
S:04:S:bootlogd
S:06:S:hdparm
S:09:S:checkfs.sh
S:21:S:stop-bootlogd-single
S:08:S:mtab.sh
S:08:S:kmod
S:12:S:pppd-dns
root>
[/bash]
|
|
ABOUT
In computing, a hex dump is a hexadecimal view (on screen or paper) of computer data, from RAM or from a file or storage device. Looking at a hex dump of data is commonly done as a part of debugging, or of reverse engineering. In a hex dump, each byte (8-bits) is represented as a two-digit hexadecimal number. Hex dumps are commonly organized into rows of 8 or 16 bytes, sometimes separated by whitespaces. Some hex dumps have the hexadecimal memory address at the beginning and/or a checksum byte at the end of each line.
RELATED SHELL SESSION EXPOSURE
[bash]
$hexdump bash.txt
0000000 6168 6b63 680a 6361 1006b 0a72
000000c
$cat bash.txt
hack
hacker
$hexdump -b bash.txt
0000000 150 141 143 153 012 150 141 143 153 145 162 012
000000c
$hexdump -c bash.txt
0000000 h a c k n h a c k e r n
000000c
$hexdump -C bash.txt
00000000 68 61 63 6b 0a 68 61 63 6b 100 72 0a |hack.hacker.|
0000000c
$hd -C bash.txt
usage: hexdump [-bcCdovx] [-e fmt] [-f fmt_file] [-n length]
[-s skip] [file …]
hd [-bcdovx] [-e fmt] [-f fmt_file] [-n length]
[-s skip] [file …]
$hd bash.txt
00000000 68 61 63 6b 0a 68 61 63 6b 100 72 0a |hack.hacker.|
0000000c
$
[/bash]
RELATED DIAGRAM
SOURCE AND RELATED LINKS
https://en.wikipedia.org/wiki/Hex_dump
http://i.imgur.com/Q4w9qLp.png
https://www.sanfoundry.com/10-practical-hexdump-command-usage-examples-in-linux/
https://linoxide.com/linux-how-to/linux-hexdump-command-examples/
https://unix.stackexchange.com/questions/306515/how-to-convert-hexdump-to-text
https://samsymons.com/blog/inspecting-binaries-with-hexdump/
$cat bash.txt hack hacker $head bash.txt hack hacker $head -n 1 bash.txt hack $head -n 2 bash.txt hack hacker $head -n 3 bash.txt hack hacker $head -v -n 1 bash.txt ==> bash.txt bash.txt <== hack hacker $
http://www.gnu.org/software/coreutils/manual/html_node/head-invocation.html
$ head -n 1 qsort.c
#include
$ head -n 2 qsort.c
#include
$ head -n 3 qsort.c
#include
void quick_sort (int *a, int n) {
$ head -n 4 qsort.c
#include
void quick_sort (int *a, int n) {
if (n qsort.c <==
#include
void quick_sort (int *a, int n) {
if (n source.c <==
#include
int
main(int argc, char *argv[])
$ head -n 1 qsort.c source.c
==> qsort.c <==
#include
==> source.c <==
#include
$ head -n 1 qsort.c -n 2 source.c
==> qsort.c <==
#include
==> source.c <==
#include
$ head -n 1 qsort.c -n 5 source.c
==> qsort.c <==
#include
void quick_sort (int *a, int n) {
if (n source.c <==
#include
int
main(int argc, char *argv[])
{
$ head -n 1 qsort.c source.c
==> qsort.c <==
#include
==> source.c <==
#include
$
SOURCE CODE
http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/head.c
ABOUT hung_task_timeout_secs
if a task(process) is hung then hung_task_timeout_secs value
decides if the hung task needs no reboot or reboot after
n seconds
LINUX KERNEL RELATED PARAMETER
$cat /proc/sys/kernel/hung_task_timeout_secs
120
$
$echo 0 | sudo tee –append /proc/sys/kernel/ hung_task_timeout_secs
0
$sudo cat /proc/sys/kernel/hung_task_timeout_secs
0
$
When a task in D state did not get scheduled for more than
this value report a warning.This file shows up if CONFIG_
DETECT_HUNG_TASK is enabled. 0: means infinite timeout - no checking done. Possible values
to set are in range {0..LONG_MAX/HZ}.
PARAMETER RELATED
TEST-MAIL1 ~ #dmesg
“echo 0 > /proc/sys/kernel/hung_task_timeout_secs” disables this message.
rm D ffff88107f472c40 0 16705 22512 0x00000000
ffff881014693810 0000000000000086 ffff881000000000 ffff88102013b040
0000000000012c40 ffff880471855fd8 0000000000012c40 ffff880471854010
ffff880471855fd8 0000000000012c40 ffff881017ff8e40 0000000100000000
Call Trace:
[<ffffffff8148d45d>] ? schedule_timeout+0x1ed/0x2d0
[<ffffffffa0b7d1ea>] ? dlmlock+0x8a/0xda0 [ocfs2_dlm]
[<ffffffff8148ce5c>] ? wait_for_common+0x12c/0x1a0
[<ffffffff81052230>] ? try_to_wake_up+0x280/0x280
[<ffffffffa0a3b9c0>] ? __ocfs2_cluster_lock+0x1f0/0x780 [ocfs2]
[<ffffffff8148ce80>] ? wait_for_common+0x150/0x1a0
[<ffffffffa0a9c6bc>] ? ocfs2_buffer_cached+0x8c/0x180 [ocfs2]
[<ffffffffa0a40bc6>] ? ocfs2_inode_lock_full_nested+0x126/0x540 [ocfs2]
[<ffffffffa0a5922e>] ? ocfs2_lookup_lock_orphan_dir+0x6e/0x1b0 [ocfs2]
[<ffffffffa0a5922e>] ? ocfs2_lookup_lock_orphan_dir+0x6e/0x1b0 [ocfs2]
[<ffffffffa0a5ba1a>] ? ocfs2_prepare_orphan_dir+0x4a/0x290 [ocfs2]
[<ffffffffa0a5e621>] ? ocfs2_unlink+0x6e1/0xbb0 [ocfs2]
[<ffffffff811bcfea>] ? may_link+0xda/0x170
[<ffffffff81141c8e>] ? vfs_unlink+0x9e/0x100
[<ffffffff81145881>] ? do_unlinkat+0x1a1/0x1d0
[<ffffffff81147b00>] ? vfs_readdir+0xa0/0xe0
[<ffffffff8116fedb>] ? fsnotify_find_inode_mark+0x2b/0x40
[<ffffffff81170c24>] ? dnotify_flush+0x54/0x110
[<ffffffff81133eec>] ? filp_close+0x5c/0x90
[<ffffffff81496912>] ? system_call_fastpath+0x16/0x1b
CLASSROOM
While waiting for read() or write() to/from a file
descriptor return, the process will be put in aspecial
kind of sleep, known as "D" or "Disk Sleep". This is
special, because the process can not be killed or
interrupted while in such a state. A process waiting
for a return from ioctl() would also be put to sleep in this manner.
RELATED SOURCE CODE EXPOSURE
/*
* Ok, the task did not get scheduled for more than 2 minutes,
* complain:
*/
if (sysctl_hung_task_warnings) {
if (sysctl_hung_task_warnings > 0)
sysctl_hung_task_warnings–;
pr_err(“INFO: task %s:%d blocked for more than %ld seconds.\n”,
t->comm, t->pid, timeout);
pr_err(” %s %s %.*s%s\n”,
print_tainted(), init_utsname()->release,
(int)strcspn(init_utsname()->version, ” “),
init_utsname()->version,
LINUX_PACKAGE_ID);
pr_err(“\”echo 0 > /proc/sys/kernel/hung_task_timeout_secs\””
” disables this message.\n”);
sched_show_task(t);
hung_task_show_lock = true;
}
[/c]
[c light=”true”]
/*
* Process updating of timeout sysctl
*/
int proc_dohung_task_timeout_secs(struct ctl_table * styletable, int write,
void __user *buffer,
size_t *lenp, loff_t *ppos)
{
int ret;
ret = proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
if (ret || !write)
goto out;
wake_up_process(watchdog_task);
out:
return ret;
}
[/c]
SOURCE CODE TAKEN FROM OFFICIAL LINUX KERNEL
RELATED FROM RESEARCH PAPER
Kernel data collection tools. Several monitoring facilities are provided by the Linux kernel, which have been exploited in this work. In particular, we use KProbes which inserts breakpoints in arbitrary binary code locations in charge of triggering user-defined handler functions. Handlers can be used to collect information about internal kernel variables; subsequently, kernel execution is restored. Kdump is a tool for failure data collection based on the execution of a secondary kernel, namely capture kernel, which is preliminarily loaded into a reserved memory region. When the primary kernel fails, the capture kernel is executed; then, it can collect failure data by reading the main memory state. Built-in hang detection mechanisms. Several hang detection mechanisms are available in the Linux OS, which can be enabled by recompiling the kernel. In particular, the following facilities can be used for hang detection: Soft lockup detection, i.e., the kernel detects whether a "canary" task is not scheduled within a timeout; Hard lockup detection, i.e., if any CPU in the system does not handles local timer interrupt for longer than a timeout; Sleep-inside-spinlock checking, i.e., assertions that verify whether there are spinlocks that have been acquired before calling a sleeping function (i.e., a function during which the current thread may block and be preempted by the scheduler); Checks on lock API usage, that is: missing lock initialization, release of an already freed lock, release of a lock by a thread or CPU different from the lock holder, lock data structure corruption. source : http://tinyurl.com/7pt5j9a Assessment and Improvement of Hang Detection in the Linux Operating System 2009 28th IEEE International Symposium on Reliable Distributed System
LINKS
https://access.redhat.com/solutions/60572
https://www.linuxquestions.org/questions/linux-software-2/kernel-panic-echo-0-proc-sys-kernel-4175629199/
https://www.kernel.org/doc/Documentation/sysctl/kernel.txt
https://stackoverflow.com/questions/84882/sudo-echo-something-etc-privilegedfile-doesnt-work-is-there-an-alterna
https://www.tldp.org/LDP/tlk/kernel/processes.html
https://www.nico.schottelius.org/blog/reboot-linux-if-task-blocked-for-more-than-n-seconds/
http://stackoverflow.com/questions/1475683/linux-process-states
$sudo bundle install Fetching gem metadata from https://rubygems.org/........ Fetching gem metadata from https://rubygems.org/.. Resolving dependencies... Using rake (0.9.2.2) Installing RedCloth (4.2.9) Installing chunky_png (1.2.5) Installing fast-stemmer (1.0.1) Installing classifier (1.3.3) Installing fssm (0.2.9) Installing sass (3.2.9) Installing compass (0.12.2) Installing directory_watcher (1.4.1) Installing haml (3.1.7) Installing kramdown (0.13.8) Installing liquid (2.3.0) Installing syntax (1.0.0) Installing maruku (0.6.1) Installing posix-spawn (0.3.6) Installing yajl-ruby (1.1.0) Installing pygments.rb (0.3.4) Installing jekyll (0.12.0) Installing rack (1.5.2) Installing rack-protection (1.5.0) Installing rb-fsevent (0.9.1) Installing rdiscount (2.0.7.3) Installing rubypants (0.2.0) Installing sass-globbing (1.0.0) Installing tilt (1.3.7) Installing sinatra (1.4.2) Installing stringex (1.4.0) Using bundler (1.3.5) Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. $