In kgdb, I cannot set the breakpoint - linux

I'm using kgdb to debug the kernel.
I'm using qemu 2.11.0, and ubuntu 16.04.3 server version for guest.
I installed the kernel 4.16.0-rc6(mainline) and boot the guest os with this kernel with kgdb options(kgdbwait kgdboc=ttyS0,115200).
The gdb can connect to guest successfully.
However, setting a break point is fail with below error message.
Cannot access memory at address 0xffffffff8124b170
Actually, I used to debug the kernel with kgdb, and version of kernel is 4.8 below.
The kernel is in raw format virtual disk.
I compiled and installed this kernel in guest by mounting raw format virtual disk to guest, and open the vmlinux file with gdb by mounting raw format virtual disk to host.
Is there any fault?

I solved this problem.
It was because of KASLR.
This is solution.

Related

PPP over ttyUSB device

i have up ruining machine with Slackware 14.02 kernel 4.4.131
i want to compile my own kernel in to the machine, how ever i don't have the kernel .config file, so i'm using generic one from the Slackware website.
after the kernel boot i'm stack on the pppd proces that the device is runing, with the error massage:
/usr/sbin/pppd: unrecognized option 'ttyUSB2'
pppd version 2.4.7
what seem that the pppd cannot open terminal over the ttyUSB2 connection. and that why i don't have keyboard. however at the builtin kernel the pppd is establishing connect and things working well
i tried to enable all the cnonfig of the ppp at the .config file
CONFIG_PPP=y
CONFIG_PPP_BSDCOMP=y
CONFIG_PPP_DEFLATE=y
CONFIG_PPP_FILTER=y
CONFIG_PPP_MPPE=m
CONFIG_PPP_MULTILINK=y
CONFIG_PPPOATM=m
CONFIG_PPPOE=y
CONFIG_PPTP=m
CONFIG_PPPOL2TP=m
CONFIG_PPP_ASYNC=y
CONFIG_PPP_SYNC_TTY=y
Thanks

Does containers depends on to a specific host?

I have an application which have kernel space code and it is compiled in linux kernel 2.6.32-431.el6.x86_64 (centos 6.5). Then it is installed as kernel module to run the application. When I tried to containerized my application with Docker (which is installed in Amazon Linux AWS EC2 instance), it complains about the higher kernel version is incompatible with the module. Is it I have to install Docker in a host which have kernel version as 2.6.32-431.el6.x86_64? If yes, does our containers depend on to a specific host machine?
Containers include the application and all of its dependencies, but share the kernel with other containers. They run as an isolated process in userspace on the host operating system.
https://www.docker.com/what-docker
Docker containers use host's kernel. You may install the same version of the kernel required in the container as host's kernel, but you will not be able to run CentOS6 compiled kernel on Amazon Linux.
Considering your specific application requirements, I would suggest using
"real" virtualization solution such as XEN or KVM that allows you to use your own kernel in a VM.

How to update/check the ubuntu kernel configuration?

I am new to Linux, and currently I want to try Kubernetes in my laptop. The official tutorial says
You need to have docker installed on one machine.
Your kernel should support memory and swap accounting. Ensure that the following configs are turned on in your linux kernel:
CONFIG_RESOURCE_COUNTERS=y
CONFIG_MEMCG=y
CONFIG_MEMCG_SWAP=y
CONFIG_MEMCG_SWAP_ENABLED=y
CONFIG_MEMCG_KMEM=y
I just installed Ubuntu 14.04, and I dont know whether the above configs are already turned on or not, how to check them? and if some are still off, how to turn them on?

Kernel Code : where can I find and how to debug the kernel

Recently I have installed Ubuntu 12.04 LTS ISO image in my desktop. Below is the output of the kernel version I have installed:
# uname -r
3.5.0-41-generic
I am trying to develop a VFS and want the kernel source code version '3.5.0-41-generic' for reference purpose - where can I find the same?
What are the excellent kernel debugging options looking at logs and mapping them to kernel code?
How and which debugger I can use to debug a live kernel flow execution?
Are there ways I can add more printk methods and re-modify the modules? Say I want to know how a FS mount method works - I can modify the required FS code (adding more printk functions) re-compile and reload the modules. Now with aid of my new printk functions I can understand the flow
Why don't you install vanilla 3.5 kernel and try to develop on it?
As a kernel debugger you can use kGDB or just printk.
But... I suggest you to test your vfs on linux running on qemu. Qemu is able to debug the running linux - so you can connect gdb to it and debug the whole emulating system.

Kernel Panic When Booting in RedHat Linux under VMWare Fusion : Filesystem Not Found

This should be simple. Yet, it's giving me Hell.
Problem
I have compiled the latest kernel and when I reboot my box, it generates a kernel panic related to the filesystem.
Question
How do I get the new kernel to recognize the VMWare filesystem? There must be some setting somewhere that lets the Linux installation know that the "hard drive" is not really a drive but actually a file that represents a virtual machine.
Background
First and foremost, I am no Linux guru. This is my first time compiling the kernel. What I've done to get this problem:
Downloaded kernel version 2.6.34 from kernel.org
Unpacked the source into a directory
Followed the installation instructions here: http://www.cyberciti.biz/tips/compiling-linux-kernel-26.html
Basically, ran: make menuconfig, make, make modules, make modules_install, make install, reboot
I didn't really change anything in the make menuconfig section
Upon reboot, it failed with an error along the lines of:
No volume groups found
Volume group "VolGroup00" not found
Unable to access resume device (/dev/VolGroup00/LogVol01)
mount: could not find filesystem '/dev/root'
setuproot: moving /dev failed: No such file or directory
setuproot: error mounting /proc: No such file or directory
setuproot: error mounting /sys: No such file or directory
switchroot: mount failed: No such file or directory
Kernel panic - not syncing: Attempted to kill init!
Environment
I am running Red Hat Enterprise Linux Server (2.6.18-194.3.1.el5PAE) under VMWare Fusion Version 3.1.0 (261058) running on a MacBook Pro with OS X v10.5.8 running a 2.8 GHz Intel Core Duo processor with 4GB 1067 MHz DDR3 memory. The virtual machine is allocated 2 processor cores and 2048 MB of memory. The VM hard disk setting points to the file "Red Hat Enterprise Linux 5.vmdk" with "Bus Type" set to "SCSI", "Disk Size" set to 40Gb and "Split into 2Gb Files" option checked.
When I use the following /boot/grub/menu.lst file, everything works perfectly except that it boots into the wrong kernel (2.6.18-194.3.1.el5PAE instead of 2.6.34):
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.34)
root (hd0,0)
kernel /vmlinuz-2.6.34 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.34.img
title Red Hat Enterprise Linux Server (2.6.18-194.3.1.el5PAE)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.3.1.el5PAE ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.18-194.3.1.el5PAE.img
title Red Hat Enterprise Linux Server (2.6.18-194.el5PAE)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.el5PAE ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.18-194.el5PAE.img
When I use the following file (with the last lines commented out and a couple other small edits), it attempts to boot the correct kernel but the boot fails with the kernel panic described above:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.34)
root (hd0,0)
kernel /vmlinuz-2.6.34 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.34.img
savedefault
boot
#title Red Hat Enterprise Linux Server (2.6.18-194.3.1.el5PAE)
# root (hd0,0)
# kernel /vmlinuz-2.6.18-194.3.1.el5PAE ro root=/dev/VolGroup00/LogVol00 rhgb quiet
# initrd /initrd-2.6.18-194.3.1.el5PAE.img
#title Red Hat Enterprise Linux Server (2.6.18-194.el5PAE)
# root (hd0,0)
# kernel /vmlinuz-2.6.18-194.el5PAE ro root=/dev/VolGroup00/LogVol00 rhgb quiet
# initrd /initrd-2.6.18-194.el5PAE.img
I don't understand how, in one case, it can figure out VMWare's filesystem just fine while in the other case, it cannot. What am I missing? Is there some special VMWare-related compile option I should be choosing? Is there something on the VMWare Fusion side that I need to change? I can't figure this out!
Any and all suggestions are greatly appreciated!
I had a similar problem.
The kernel was much older than hardware. Hard drive was attached by SATA default. I reconfigured (in BIOS or in VM.Properties) hardware to connect by IDE. It worked for me, i'm happy :)
Your kernel is probably unable to load the modules needed to locate your volumes.
My best guess is your initrd is not in the right place. It needs to be in the same directory as the installed kernel.
Also, it's not a good idea to follow Debian instructions for a RedHat system. In general it's ok, but you are doing something that is relatively distribution specific.
I received the kernel panic in a different situation. I had a RHEL 5.5 workstation in which the BIOS/motherboard failed. Therefore, I moved the OS drive to another PC which is identical (Dell T5500) and to another which is one generation back (Dell T5400). I have done this in the past, since Linux contains drivers for many motherboards, and the PC usually boots right up. Both kernel panics were identical. I was very surprised. I mentioned your resolution to a friend, and he remembered a BIOS Setting which could cause this to occur. We changed the BIOS->Drives ->SATA Operation-> RAID SATA to RAID AHCI. After changing this BIOS Setting, both PCs booted up with the RHEL5.5 OS HD!! The replacement PCs had Windows prior. He told me that Windows needs the ATA BIOS Setting while Linux requires the other. Who knew!

Resources