Quantcast
Channel: Active questions tagged linux-kernel - Stack Overflow
Viewing all 12318 articles
Browse latest View live

Raspberry Pi 4 U-Boot on booting hanging in Starting Kernel

$
0
0

I am working on a project where I want to create my own embedded linux with U-Boot. Therefore I am working with buildroot, which i recently start learning. After successfully creating my own rasberrypi4_defconfig i am currently struggling at the problem to get u-boot work correctly.

What versions I am working with:

  1. Rpi 4
  2. buildroot-2019.11
  3. u-boot (therefore i pull everyday the new changes)

Current State of the work:

I build on a Ubuntu(32bit). I configure buildroot with the raspberrypi4_defconfig and make it without changes. Then i make a u-boot defconfig for rpi_4_32b_defconfig and create the u-boot.bin with make CROSS_COMPILE=arm-linux-gnueabihf- u-boot.bin Now my next step was to configure the config.txt and exchange the content with following:

enable_uart=1
kernel=u-boot.bin

In addition i copyied my u-boot.bin into my sd-card.

The last step that i actually did is to build my own boot.scr.uimg with following content

mmc dev 0
fatload mmc O:1 ${fdt_addr_r} bcm2711-rpi-4-b.dtb
fatload mmc 0:1 ${kernel_addr_r} zImage
setenv bootargs console=ttyS0,115200 \
root=/dev/mmcblk0p2 rootfstype=ext4 rootwait rw
bootz ${kernel_addr_r} - ${fdt_addr_r}

Problem So far i am archieving to reach the U-boot menu but on booting i get stucked in Starting Kernel I actually thing that my boot.scr.uimg is maybe not correct but dont get it.

Environment

arch=arm
baudrate=115200
board=rpi
board_name=4 Model B
board_rev=0x11
board_rev_scheme=1
board_revision=0xC03111
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_efi_binary=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr ${fdtcontroladdr};fi;load ${devty
pe} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootarm.efi; if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${f
dt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=mmc0 mmc1 pxe dhcp
bootargs=console=ttyS0,115200 \
root=/dev/mmcblk0p2 rootfstype=ext4 rootwait rw
bootcmd=run distro_bootcmd
bootcmd_dhcp=if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;setenv efi_fdtfile ${fdtfile}; if test -z "${f
dtfile}" -a -n "${soc}"; then setenv efi_fdtfile ${soc}-${board}${boardver}.dtb; fi; setenv efi_old_vci ${bootp_vci};setenv efi_old_
arch ${bootp_arch};setenv bootp_vci PXEClient:Arch:00010:UNDI:003000;setenv bootp_arch 0xa;if dhcp ${kernel_addr_r}; then tftpboot $
{fdt_addr_r} dtb/${efi_fdtfile};if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r}; else bootefi ${kernel_addr_r
} ${fdtcontroladdr};fi;fi;setenv bootp_vci ${efi_old_vci};setenv bootp_arch ${efi_old_arch};setenv efi_fdtfile;setenv efi_old_arch;s
etenv efi_old_vci;
bootcmd_mmc0=devnum=0; run mmc_boot
bootcmd_mmc1=devnum=1; run mmc_boot
bootcmd_pxe=dhcp; if pxe get; then pxe boot; fi
bootdelay=2
bootfstype=fat
cpu=armv7
dhcpuboot=usb start; dhcp u-boot.uimg; bootm
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
ethaddr=dc:a6:32:45:1f:d1
fdt_addr=2eff5d00
fdt_addr_r=0x02600000
fdt_high=ffffffff
fdtcontroladdr=3af6ac98
fdtfile=bcm2711-rpi-4-b.dtb
fileaddr=2600000
filesize=9e6f
initrd_high=ffffffff
kernel_addr_r=0x00080000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0x00200000
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
pxefile_addr_r=0x02500000
ramdisk_addr_r=0x02700000
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done; setenv devplist
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; if test -z "${fdtfile}" -a -n "${soc}"; then setenv efi_fdtfile ${soc}-${board}${boardver}.dtb; fi; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootarm.efi; then echo Found EFI removable media binary efi/boot/bootarm.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing...; fi; setenv efi_fdtfile
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scriptaddr=0x02400000
serial#=10000000f58b842c
soc=bcm283x
stderr=serial,vidconsole
stdin=serial,usbkbd
stdout=serial,vidconsole
usbethaddr=dc:a6:32:45:1f:d1
vendor=raspberrypi

Environment size: 3996/16380 bytes

Boot Log

U-Boot 2020.01-rc4-00066-g7e5ee346fc (Dec 05 2019 - 16:55:27 +0100)

DRAM:  948 MiB
RPI 4 Model B (0xc03111)
MMC:   emmc2@7e340000: 0, mmcnr@7e300000: 1
Loading Environment from FAT... *** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   Net Initialization Skipped
No ethernet found.
Hit any key to stop autoboot:  0 
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr.uimg
297 bytes read in 18 ms (15.6 KiB/s)
## Executing script at 02400000
switch to partitions #0, OK
mmc0 is current device
40559 bytes read in 29 ms (1.3 MiB/s)
5601344 bytes read in 1084 ms (4.9 MiB/s)
Kernel image @ 0x080000 [ 0x000000 - 0x557840 ]
## Flattened Device Tree blob at 02600000
   Booting using the fdt blob at 0x2600000
   Using Device Tree in place at 02600000, end 0260ce6e

Starting kernel ...

how to find the mm_struct and address for a physical page

$
0
0

I'm studying in android io using nexus 6 and lineageOS-cm14.1.

I write a kernel module which jprobe on mmc driver and get the pages every time when a request is dispatched, and now I need to find which the pages belong to.

Just like the parameter for page fault handler (mm, vma, address, ...)

In NixOS, if a new config requires rebuilding the kernel, will old configurations still work?

$
0
0

The title really says it all, but just in case, here's some context:

Each time you change your configuration in NixOS, you need to run nixos rebuild to create a new boot image, which will be listed in Grub when you start the computer. A new configuration might require a new kernel. If it does, and you build it, will your old configurations continue to work?

In Ubuntu it appears that one can indeed host multiple kernels on the same machine. And I read somewhere the linux kernel can be pretty small, like 60 MB. Those two facts lead me to expect NixOS will retain the old kernels. But I haven't found anything online that really makes that explicit.

I am currently building a configuration that uses Musnix. If you ask for it, Musnix will build you a realtime kernel. I'm currently building such a new configuration, and hoping I'll still be able to boot my computer after it. I worry because GIthub user @magnetophon, who is involved in Musnix's development, said the Musnix realtime kernel is borken.

Turn of kernel logging to serial port but keep logging to oops ramlog

$
0
0

I'm working with a system that have one external serial port, this has been (and still is used in other configurations using the same kernel) for printing the kernel log (and application log). But now the serial port has to be used to communicate with an external device.

I found a way to make getty boot depending on a file on a configuration file on the file system, but I have not been able to turn of the logging to the serial port and still keep the logging to the crash dump, the crash dumps utilize the oops logs stored "persistent" in RAM (i.e. they survive a soft reboot) and stores them at the next boot.

If I use, dmesg --console-off it will turn of both the logging to the serial port as well as the logging to the oops logs.

Currently I have bootargs = "console=ttyPS0,115200 loglevel=7 ... the bootargs are shared with another product that, if possible, wishes to keep the log printouts over the serial interface.

Does anyone have any suggestion on how I can prevent the logs to be printed on the serial interface but still be logged in the oops logs? I have the possibility to edit all from the kernel, kernel module/drivers and user space apps.

How to increase max open files limit more than 1048576 in Ubuntu 18 [closed]

$
0
0

In Ubuntu 18

vi /etc/security/limits.conf  
* soft nofile 1048576  
* hard nofile 1048576  

I found the max open file count is 1048576.
If I set value more than 1048576, it's invalid, and will be reset to default value 1024.

ulimit -n
1024

How can I increase the limit as many as possible, like unlimit?

What is the relation between Linux kernel and GNU C library?

$
0
0

We know that Linux kernel is written in C. But does it also call standard C functions like malloc() or extra functions like mmap() which are provided by GNU C library (glibc)? In that case, it's strange, because direct low-level interaction with hardware, e.g. memory management, is supposed to be almost always the task of a kernel. So, which is dependent on the other? Which is more fundamental/low-level?

Setting up PHP Proxy Server to Monitor Web Traffic of a Home Network [duplicate]

$
0
0

I'm a complete beginner and wanted to know what the best way to setup a proxy server that routes all web traffic from my home network through itself and logs all websites and traffic in a neat user interface.

Right now, my idea is to use a web server I have hosted to monitor everything through squid, and then use a program like snapt or webmin to actually have a gui and way to interpret the information. Also, is there a way to do this with windows instead on linux.

SCSI Custom Kernel Module

$
0
0

I have a display device that connects to the host via USB and enumerates as a SCSI device, appearing in the /dev folder. I'd like to write a kernel module that will utilize the already available scsi interface but will add a layer of functionality on top of this.

I looked originally at writing a USB device driver but the device is probed by the scsi module before reaching my custom module. I also feel like it'd be silly to re-write the already available (and better) scsi interface.

So with that in mind, is there a type of module I can write that will be called when the device is connected and then can communicate to it via /dev/sda to add this additional layer of functionality between the userspace and the usb device? The necessity for this modules comes from a host of functionality that will make users life much easier when writing userspace programs - things like keeping a frame buffer, update routines on the display etc (this isn't a standard display device).

Thanks


n_gsm Line discipline problem with Telit LE910B1 Modem and CMUX

$
0
0

We are using a Telit LE910B1 modem on an embedded device running a Linux 5.1.0 kernel. We only have a single UART available for the modem so we are using n_gsm line discipline with CMUX on the modem. Once everything is setup, our app creates two virtual ttys, uses one to get modem information and the other is passed to pppd to start a PPP session. We can then start data RX/TX over TCP/IP. This all works fine for a short time, with small data transfers, but when we try to transfer large amounts of data, the PPP connection locks up and the only way to get things running again is to kill pppd, power cycle the modem, and restart the application.

Telit was able to reproduce the problem with two different versions of Ubuntu (18.04 and , and was able to obtain tracing information from the modem, which they pass to Intel for further diagnosis. Intel's response was that they think the "host application side" may not be making correct CMUX frames or is not respecting max frame size. Here are some extracts given to us by Telit from the analysis of the modem trace:

<-- Packet discarded because of flag("0xF9") missing in CMUX frame.
<-- Packet discarded because of dlc is not valid in frame.
<-- Packet discarded because of length size more then RD_BUF_SIZE = 1510
<-- Packet dropped because of in PPP frame FCS is not valid

In my case, the "host application side" is the n_gsm driver in Linux and the only things I can set are the mru and mtu sizes, which I've set to what Telit says is the modem's default (i.e. 121).

The code I use to configure the modem is pretty straight forward (error checking is omitted for brevity):

struct termios tio;
int serial_fd;

serial_fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY | O_NDELAY);
tcgetattr(serial_fd, &tio);
tio.c_iflag = 0;
tio.c_oflag = 0;
tio.c_cflag = CS8 | CREAD | CLOCAL;
tio.c_cflag |= CRTSCTS;
tio.c_lflag = 0;
tio.c_cc[VMIN] = 1;
tio.c_cc[VTIME] = 0;

cfsetospeed(&tio, B115200);
cfsetispeed(&tio, B115200);
tcsetattr(serial_fd, TCSANOW, &tio);

To configure the modem I use the following:

send_at_command(serial_fd, "ATE0V1&K3&D2\r");
send_at_command(serial_fd, "AT#CMUXMODE=5\r");
send_at_command(serial_fd, "AT+CMUX=0,0\r");

Once that's done, I enable n_gsm discipline

struct gsm_config gsm;

int ldisc = N_GSM0710;
ioctl(serial_fd, TIOCSETD, &ldisc);
ioctl(serial_fd, GSMIOC_GETCONF, &gsm) ;

gsm.initiator = 1;
gsm.encapsulation = 0;
gsm.mru = 121;
gsm.mtu = 121;

ioctl(serial_fd, GSMIOC_SETCONF, &gsm);
/* Create /dev/ttyGSM1 and /dev/ttyGSM2. Do not close /dev/ttyS1 */

Has anyone else used an LE910* modem with CMUX and n_gsm line discipline on a Linux 5.1.0 or later kernel? Have you had any problems? Are there any problem with the code I've shown or can you suggest something I could try?

Thanks.

How does Linux manage deleting temporary files?

$
0
0

I've been studying some Linux implementation and a question came up to my mind.

As far as I know, there is a bit which marks a file as a temporary file. When the process which generated that file dies, how does the kernel delete it? I've thinking that it might be related to the file descriptor table, but I'm not sure whatsoever.

If someone could give an explanation step-by-step, that would come in handy!

How do the likely/unlikely macros in the Linux kernel work and what is their benefit?

$
0
0

I've been digging through some parts of the Linux kernel, and found calls like this:

if (unlikely(fd < 0))
{
    /* Do something */
}

or

if (likely(!err))
{
    /* Do something */
}

I've found the definition of them:

#define likely(x)       __builtin_expect((x),1)
#define unlikely(x)     __builtin_expect((x),0)

I know that they are for optimization, but how do they work? And how much performance/size decrease can be expected from using them? And is it worth the hassle (and losing the portability probably) at least in bottleneck code (in userspace, of course).

Incorrect memory access: why is my kernel *not* crashing

$
0
0

I wanted to show to somebody an exemple of incorrect memory access (kernelspace trying to access userspace memory leading to a bug).

Thus, I took an old tutorial as a POC, the important part is :

static ssize_t dev_write(struct file *filep, const char *buffer, size_t len, loff_t *offset){
   sprintf(message, "%s(%zu letters)", buffer, len);   // appending received string with its length
   // [...]
}

This causes a crash in one of my environment tests, which is the expected behavior (I access to the buffer which is an userspace variable thus the memory protection mechanism is trigerred and my process is killed.

But in another machine, this snippet actually works fine which seems really odd to me. Both machines uses a 5.3 kernel with a quite similar kernel configuration.

Is the VM that does not crash broken ? Is my code actually an UB? Am I missing something?


Note: the full PoC code below (context there)

/**
 * @file   ebbchar.c
 * @author Derek Molloy
 * @date   7 April 2015
 * @version 0.1
 * @brief   An introductory character driver to support the second article of my series on
 * Linux loadable kernel module (LKM) development. This module maps to /dev/ebbchar and
 * comes with a helper C program that can be run in Linux user space to communicate with
 * this the LKM.
 * @see http://www.derekmolloy.ie/ for a full description and follow-up descriptions.
 */

#include <linux/init.h>           // Macros used to mark up functions e.g. __init __exit
#include <linux/module.h>         // Core header for loading LKMs into the kernel
#include <linux/device.h>         // Header to support the kernel Driver Model
#include <linux/kernel.h>         // Contains types, macros, functions for the kernel
#include <linux/fs.h>             // Header for the Linux file system support
#include <linux/uaccess.h>          // Required for the copy to user function
#define  DEVICE_NAME "ebbchar"    ///< The device will appear at /dev/ebbchar using this value
#define  CLASS_NAME  "ebb"        ///< The device class -- this is a character device driver

MODULE_LICENSE("GPL");            ///< The license type -- this affects available functionality
MODULE_AUTHOR("Derek Molloy");    ///< The author -- visible when you use modinfo
MODULE_DESCRIPTION("A simple Linux char driver for the BBB");  ///< The description -- see modinfo
MODULE_VERSION("0.1");            ///< A version number to inform users

static int    majorNumber;                  ///< Stores the device number -- determined automatically
static char   message[256] = {0};           ///< Memory for the string that is passed from userspace
static short  size_of_message;              ///< Used to remember the size of the string stored
static int    numberOpens = 0;              ///< Counts the number of times the device is opened
static struct class*  ebbcharClass  = NULL; ///< The device-driver class struct pointer
static struct device* ebbcharDevice = NULL; ///< The device-driver device struct pointer

// The prototype functions for the character driver -- must come before the struct definition
static int     dev_open(struct inode *, struct file *);
static int     dev_release(struct inode *, struct file *);
static ssize_t dev_read(struct file *, char *, size_t, loff_t *);
static ssize_t dev_write(struct file *, const char *, size_t, loff_t *);

/** @brief Devices are represented as file structure in the kernel. The file_operations structure from
 *  /linux/fs.h lists the callback functions that you wish to associated with your file operations
 *  using a C99 syntax structure. char devices usually implement open, read, write and release calls
 */
static struct file_operations fops =
{
   .open = dev_open,
   .read = dev_read,
   .write = dev_write,
   .release = dev_release,
};

/** @brief The LKM initialization function
 *  The static keyword restricts the visibility of the function to within this C file. The __init
 *  macro means that for a built-in driver (not a LKM) the function is only used at initialization
 *  time and that it can be discarded and its memory freed up after that point.
 *  @return returns 0 if successful
 */
static int __init ebbchar_init(void){
   printk(KERN_INFO "EBBChar: Initializing the EBBChar LKM\n");

   // Try to dynamically allocate a major number for the device -- more difficult but worth it
   majorNumber = register_chrdev(0, DEVICE_NAME, &fops);
   if (majorNumber<0){
      printk(KERN_ALERT "EBBChar failed to register a major number\n");
      return majorNumber;
   }
   printk(KERN_INFO "EBBChar: registered correctly with major number %d\n", majorNumber);

   // Register the device class
   ebbcharClass = class_create(THIS_MODULE, CLASS_NAME);
   if (IS_ERR(ebbcharClass)){                // Check for error and clean up if there is
      unregister_chrdev(majorNumber, DEVICE_NAME);
      printk(KERN_ALERT "Failed to register device class\n");
      return PTR_ERR(ebbcharClass);          // Correct way to return an error on a pointer
   }
   printk(KERN_INFO "EBBChar: device class registered correctly\n");

   // Register the device driver
   ebbcharDevice = device_create(ebbcharClass, NULL, MKDEV(majorNumber, 0), NULL, DEVICE_NAME);
   if (IS_ERR(ebbcharDevice)){               // Clean up if there is an error
      class_destroy(ebbcharClass);           // Repeated code but the alternative is goto statements
      unregister_chrdev(majorNumber, DEVICE_NAME);
      printk(KERN_ALERT "Failed to create the device\n");
      return PTR_ERR(ebbcharDevice);
   }
   printk(KERN_INFO "EBBChar: device class created correctly\n"); // Made it! device was initialized
   return 0;
}

/** @brief The LKM cleanup function
 *  Similar to the initialization function, it is static. The __exit macro notifies that if this
 *  code is used for a built-in driver (not a LKM) that this function is not required.
 */
static void __exit ebbchar_exit(void){
   device_destroy(ebbcharClass, MKDEV(majorNumber, 0));     // remove the device
   class_unregister(ebbcharClass);                          // unregister the device class
   class_destroy(ebbcharClass);                             // remove the device class
   unregister_chrdev(majorNumber, DEVICE_NAME);             // unregister the major number
   printk(KERN_INFO "EBBChar: Goodbye from the LKM!\n");
}

/** @brief The device open function that is called each time the device is opened
 *  This will only increment the numberOpens counter in this case.
 *  @param inodep A pointer to an inode object (defined in linux/fs.h)
 *  @param filep A pointer to a file object (defined in linux/fs.h)
 */
static int dev_open(struct inode *inodep, struct file *filep){
   numberOpens++;
   printk(KERN_INFO "EBBChar: Device has been opened %d time(s)\n", numberOpens);
   return 0;
}

/** @brief This function is called whenever device is being read from user space i.e. data is
 *  being sent from the device to the user. In this case is uses the copy_to_user() function to
 *  send the buffer string to the user and captures any errors.
 *  @param filep A pointer to a file object (defined in linux/fs.h)
 *  @param buffer The pointer to the buffer to which this function writes the data
 *  @param len The length of the b
 *  @param offset The offset if required
 */
static ssize_t dev_read(struct file *filep, char *buffer, size_t len, loff_t *offset){
   int error_count = 0;
   // copy_to_user has the format ( * to, *from, size) and returns 0 on success
   error_count = copy_to_user(buffer, message, size_of_message);

   if (error_count==0){            // if true then have success
      printk(KERN_INFO "EBBChar: Sent %d characters to the user\n", size_of_message);
      return (size_of_message=0);  // clear the position to the start and return 0
   }
   else {
      printk(KERN_INFO "EBBChar: Failed to send %d characters to the user\n", error_count);
      return -EFAULT;              // Failed -- return a bad address message (i.e. -14)
   }
}

/** @brief This function is called whenever the device is being written to from user space i.e.
 *  data is sent to the device from the user. The data is copied to the message[] array in this
 *  LKM using the sprintf() function along with the length of the string.
 *  @param filep A pointer to a file object
 *  @param buffer The buffer to that contains the string to write to the device
 *  @param len The length of the array of data that is being passed in the const char buffer
 *  @param offset The offset if required
 */
static ssize_t dev_write(struct file *filep, const char *buffer, size_t len, loff_t *offset){
   sprintf(message, "%s(%zu letters)", buffer, len);   // appending received string with its length
   size_of_message = strlen(message);                 // store the length of the stored message
   printk(KERN_INFO "EBBChar: Received %zu characters from the user\n", len);
   return len;
}

/** @brief The device release function that is called whenever the device is closed/released by
 *  the userspace program
 *  @param inodep A pointer to an inode object (defined in linux/fs.h)
 *  @param filep A pointer to a file object (defined in linux/fs.h)
 */
static int dev_release(struct inode *inodep, struct file *filep){
   printk(KERN_INFO "EBBChar: Device successfully closed\n");
   return 0;
}

/** @brief A module must use the module_init() module_exit() macros from linux/init.h, which
 *  identify the initialization function at insertion time and the cleanup function (as
 *  listed above)
 */
module_init(ebbchar_init);
module_exit(ebbchar_exit);

Kernel Sources for Android 4.0 - Ice Cream Sandwich

$
0
0

I have downloaded Android 4.0 sources as per the instructions given in the following link : http://source.android.com/source/initializing.html

I have downloaded the sources successfully without any issues. However, I did not find the kernel sources in it. Later I found that there are kernel sources available at the following link.

source.android.com/source/building-kernels.html

However, these sources are device specific except the following :

$ git clone https://android.googlesource.com/kernel/common.git

Am I correct?

Actually, I have my own board with ARM 926 EJ processor which is working fine with 2.6.10 kernel version and it is up and running with this kernel version.

My idea is to port the Android 4.0/earlier versions on to this board. My idea is as follows.

  1. I will take the latest kernel which is used for Android 4.0 and add my patches from 2.6.10 to the latest android kernel and boot it.
  2. Then, I will add the Android user space sources and try to boot Android from my board.

Questions: Which kernel sources shall I use i.e. from kernel.org or above common.git? Is Android 4.0 based on 2.6.29 kernel version?

Please let me know, if you need any more information.

message from syslogd: kernel:Call Trace: kernel:Code:

$
0
0

My RHEL6 computer was sitting overnight, and I returned to find this on the console:

kernel:Stack:

Message from syslogd@computer-name at Jan 15 01:52:41 ... kernel:Call Trace:

Message from syslogd@computer-name at Jan 15 01:52:41 ... kernel:Code: 01 74 05 e8 92 7a d8 ff c9 c3 55 48 89 e5 0f 1f 44 00 00 b8 00 00 01 00 f0 0f c1 07 0f b7 d0 c1 e8 10 39 c2 74 0e f3 90 0f b7 17 <eb> f5 83 3f 00 75 f4 eb df c9 c3 0f 1f 40 00 55 48 89 e5 0f 1f

It's the first time I've seen something like this. It looks similar to Syslogd kernel:code:, but I can't comment there to ask how jcomeau_ictx got that disassembly, nor what it means in my case.

What is going on in this code? How can I tell what caused it?

Cygwin: Linux kernel make clean not working

$
0
0

I am trying to compile Linux kernel on Windows using Cygwin. When I try make distclean it gives me the following error:

 make distclean
 make[1]: *** Documentation/Kbuild: Is a directory.  Stop.
 Makefile:1188: recipe for target '_clean_Documentation' failed
 make: *** [_clean_Documentation] Error 2

GDB: Looping through the kernel memory address space

$
0
0

First, I'm a novice in kernel development or debugging, therefore, I may have a fundamental misunderstanding here. I will try to explain the problem in detail.

My goal is to find a particular string (a process name) from the task_struct. Therefore, I'm planning to do a thorough search in the kernel address space followed by a memory examination to find a match with string (Not quite sure if this is the right approach or not but at the moment this is the only approach I can think off). I have a KVM running 64-bit Linux and I'm trying to debug this kernel from host remotely. I figure that 64-bit Linux kernel has an address range of 0xffff800000000000 - 0xffffffffffffffff. My understanding is with GDB I can access any memory location.

However, if I try to examine the first address of the kernel, it shows the following error.

enter image description here

Any help regarding why I can't access this memory location? or if this is a wrong approach which way should I take? Please help.

N.B : My guesst kernel version is 5.0.0-37-generic

Useage of skb_make_writable and skb_ensure_writable in Linux Kernel

$
0
0

I have written a netfilter hook to modify some data in application layer. I try to get the begin and end of the application data by:

sturct iphdr* iph = ip_hdr(skb);
struct tcphdr* tcph;
char *data_start, *data_end;
if(iph -> protocol != IPPROTO_TCP)
    return NF_ACCEPT;
tcph = tcp_hdr(skb);
data_start = (char *)tcph + tcph -> doff * 4;
data_end = (char *)tcph + ntohs(iph -> tot_len) - iph -> ihl * 4;

And then, for example, print the first char:

if(data_end - data_start >= 1)
    printk("%x\n", *data_start);

But I found the code did not always work well, as sometimes the application data seems not being put exactly behind the TCP header.

I have found the solution: use skb_ensure_writable (or skb_make_writable in old kernel) before reading application data and re-get headers and char pointers:

sturct iphdr* iph = ip_hdr(skb);
struct tcphdr* tcph;
char *data_start, *data_end;
if(iph -> protocol != IPPROTO_TCP)
    return NF_ACCEPT;
tcph = tcp_hdr(skb);
data_end = (char *)tcph + ntohs(iph -> tot_len) - iph -> ihl * 4;

skb_ensure_writable(skb, (char*)data_end - (char*)skb -> data);

iph = ip_hdr(skb);
tcph = tcp_hdr(skb);
data_start = (char *)tcph + tcph -> doff * 4;
data_end = (char *)tcph + ntohs(iph -> tot_len) - iph -> ihl * 4;

But I still have some questions:

  1. Why the application data is not being designed to lay at the behind of TCP header?
  2. May the TCP header also not lay behind the IP header? If yes, how can I get the second parameter for skb_ensure_writable?
  3. What exactly skb_ensure_writable or skb_make_writeable do? I could hardly found any document.

Which scripts read the system call table and what they do

$
0
0

I know that system call table for x64 is present at arch/x86/entry/syscalls/syscall_64.tbl

From this link, it says

https://brennan.io/2016/11/14/kernel-dev-ep3/

This table is read by scripts and used to generate some of the boilerplate code, which makes our lives a lot easier!

Where are these scripts present in the source code and what they do? Is the script: scripts/checksyscalls.sh I don't see much documentation on this. Can anyone provide good reference on it

Kernel keeps dying and restarting when running some lines in python Notebook

$
0
0

I get the error -->

/apps/anaconda3/bin/python: symbol lookup error: /apps/anaconda3/lib/python3.6/site-packages/mkl/../../../libmkl_intel_thread.so: undefined symbol: omp_get_num_procs

To fix this, I tried updating mkl package by doing a "conda update mkl", and then restarting the jupyterhub service. But still, the issue persists.

the libmkl_intel_thread.so file is located in the below paths -

/apps/anaconda3/envs/myEnv/lib/libmkl_intel_thread.so
/apps/anaconda3/lib/libmkl_intel_thread.so
/apps/anaconda3/pkgs/mkl-2017.0.1-0/lib/libmkl_intel_thread.so
/apps/anaconda3/pkgs/mkl-2019.4-243/lib/libmkl_intel_thread.so

my $PATH is -->

/apps/anaconda3/envs/myEnv/bin:/apps/anaconda3/condabin:/apps/anaconda3/bin:/opt/mssql-tools/bin:/apps/anaconda3/lib/python3.6/site-packages:/apps/anaconda3/envs/myEnv:/apps/anaconda3/envs/myEnv/bin:/apps/anaconda3/bin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

What could be wrong ?

ipip packet is not forwarded from one interface to another interface in linux networking stack [closed]

$
0
0

I am trying to send ipip packets between a client and a server via a router as below diagram. All entities are virtual machines using Ubuntu 18.04 with the 4.15.0-55-generic kernel.

client --(net1)-- router --(net2)-- server

net1: 10.10.10.0/24
net2: 50.10.10.0/24

client ip: 10.10.10.10
server ip: 50.10.10.10
router ip:
    net1-if: 10.10.10.1
    net2-if: 50.10.10.1

The routing table of the router is as below:

10.10.10.0/24 dev ens5 proto kernel scope link src 10.10.10.1
50.10.10.0/24 dev ens6 proto kernel scope link src 50.10.10.1

It seems the client sends ipip packet correctly to the router as shown in a tcpdump below:

15:51:55.996433 52:54:00:23:97:ef > 52:54:00:12:e8:4c, ethertype IPv4 (0x0800), length 94: (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto IPIP (4), length 80)
    172.16.242.206 > 50.10.10.10: (tos 0x0, ttl 63, id 21090, offset 0, flags [DF], proto TCP (6), length 60)
    192.168.150.10.50276 > 20.200.200.1.22: Flags [S], cksum 0x7ddd (correct), seq 1289943810, win 29200, options [mss 1460,sackOK,TS val 2434696983 ecr 0,nop,wscale 7], length 0
15:51:57.017960 52:54:00:23:97:ef > 52:54:00:12:e8:4c, ethertype IPv4 (0x0800), length 94: (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto IPIP (4), length 80)
    172.16.242.206 > 50.10.10.10: (tos 0x0, ttl 63, id 21091, offset 0, flags [DF], proto TCP (6), length 60)
    192.168.150.10.50276 > 20.200.200.1.22: Flags [S], cksum 0x79df (correct), seq 1289943810, win 29200, options [mss 1460,sackOK,TS val 2434698005 ecr 0,nop,wscale 7], length 0

But the problem is the router can't forward ipip packets to the server. It drops the packets before it calls the ip_recv() as shown the below kernel trace log. I expect the linux networking stack of the router calls the ip_recv() function to handle ipip packet.

This is the log of kernel call trace from the router when it receives ipip packets:

swapper     0 [003]  2339.377884: skb:kfree_skb: skbaddr=0xffff913f34574600 protocol=4 location=0xffffffffa6e5371f
            7fffa6e40696 kfree_skb ([kernel.kallsyms])
            7fffa6e5571f __netif_receive_skb_core ([kernel.kallsyms])
            7fffa6e55c08 __netif_receive_skb ([kernel.kallsyms])
            7fffa6e57f55 netif_receive_skb_internal ([kernel.kallsyms])
            7fffa6e58c55 napi_gro_receive ([kernel.kallsyms])
            7fffc004145a cp_rx_poll ([kernel.kallsyms])
            7fffa6e58380 net_rx_action ([kernel.kallsyms])
            7fffa72020e4 __softirqentry_text_start ([kernel.kallsyms])
            7fffa66969b8 irq_exit ([kernel.kallsyms])
            7fffa700462a do_IRQ ([kernel.kallsyms])
            7fffa7002904 ret_from_intr ([kernel.kallsyms])
            7fffa6fa3672 native_safe_halt ([kernel.kallsyms])
            7fffa6fa3330 default_idle ([kernel.kallsyms])
            7fffa663b035 arch_cpu_idle ([kernel.kallsyms])
            7fffa6fa3803 default_idle_call ([kernel.kallsyms])
            7fffa66d6db2 do_idle ([kernel.kallsyms])
            7fffa66d7013 cpu_startup_entry ([kernel.kallsyms])
            7fffa665b37b start_secondary ([kernel.kallsyms])
            7fffa66020d5 secondary_startup_64 ([kernel.kallsyms])

Am I missing something to config on the router?

thx~

Viewing all 12318 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>