Navid Malekghaini's Personal Blog

My personal weblog for sharing and storing some of my activities related to computer science over the internet

Navid Malekghaini's Personal Blog

My personal weblog for sharing and storing some of my activities related to computer science over the internet

Navid Malekghaini's Personal Blog

Navid Malekghaini

Software Engineer @ Intelligent Cloud Infrastructure Laboratory
Prev. ML Researcher @ University of Waterloo x Orange Telecom

University of Waterloo
Department of computer science
200 University Ave W, Waterloo, ON N2L 3G1, Canada
cs.uwaterloo.ca

contact me
navidmalekedu (AT) gmail (DOT) com [ Primary Email ]
nmalekgh (AT) uwaterloo (DOT) ca

۷ مطلب با کلمه‌ی کلیدی «kernel» ثبت شده است

The main project that me and my colleague designed for Operating Systems course ( Spring 2018 ) - TA of OS

Project Description ( summary ):

The goal of this project is to gather information about incoming and outgoing packets in system. ( some kind of packet capturing )

The desired informations are :

  • Lenght of packet
  • Protocols of packet ( in all available layers of network except application layer, for example Ethernet,IP,TCP )
  • Hash value of packet
  • Total Processing time of packet


Phase one :

  1. implement a systemcall with a single integer input indicating what information you desire from packets and single output buffer to copy the data from kernel space to user space.
  2. an interactive user space program that talks to the user and systemcall call above ( clean input and output for user ).

    Phase two :
    1. implement a kernel module with a single proc entry file for input indicating what information you desire from packets and single proc entry file for output and to copy the data from kernel space to user space.
    2. an interactive user space program that talks to the user and kernel module and proc entry files above ( clean input and output for user ).

    Phase three :

    Performance comparsion of kernel module and system call ( the first two phases ).


    DOWNLOAD PROJECT DESCRIPTIONS IN DETAIL

    Approach Taken for answer:

    All of the desired informations are in sk_buff data structure.
    my approach was to clone sk_buff from driver, right before the driver ( here : e1000 ) wants to pass the packet to the next network layer handler ( application or the NIC ). with this approach i will have a clone for each packet.
    now that i have the information the rest is easy, just copy the desired information from the sk_buff to the output buffer and copy from there to user space.




    note: for the LKM you should use extern and export symbol.



    the idea for this approach was from here



    DOWNLOAD THE IMPLEMENTATION OF THIS APPROACH WITH DOCUMENTATION IN PERSIAN FROM STUDENTS ( WITH MY HELP )


    Second approach:

    second approach i believe is based on this idea from IBM.

    Download the Implementation of Second Approach From a Student With Document

موافقین ۰ مخالفین ۰ 27 January 19 ، 02:14

Part 2.3

Implementation of desired kernel module and user program


Download full tutorial from here

Implement the module

?Now What will this module do and how
.tops_init is the first routin that will be runned , the module is well commented so just read the comments to see what happens
 

Implement user program

Just do the writing and reading from file automatically!

 

Download full tutorial from here

موافقین ۰ مخالفین ۰ 29 September 17 ، 08:38

 

Part 2.2

Finding specified information and necessary functions to implement desired module

​​Download full tutorial from here

Goal:

  • find start and end of code segment in memory for a process

  • find start and end of data segment in memory for a process

  • find BSS virtual address for process

  • find entry point of a process

​​Download full tutorial from here

موافقین ۰ مخالفین ۰ 29 September 17 ، 08:25

Part 2.1

Implementation of Simple “hello world” Module and Run


 

TO GET THE FULL TUTORIAL CLICK HERE

Every module structure have two major functions:

  1. init

  • executed when the module is loaded into kernel

  1. cleanup

  • executed when the module is removed from kernel

the simple module implementation is here:



TO GET THE FULL TUTORIAL CLICK HERE

موافقین ۰ مخالفین ۰ 29 September 17 ، 04:00

Part 1.2

finding the important functions which gather information about some hardware's

DOWNLOAD FULL TUTORIAL WITH IMAGES FROM HERE

 

list of hardwares:

  • CPU

  • Memory

  • network interface

  • sound card

  • power supplier

inorder to implement our information on system we should find :

  1. what are the type of variables we want?

  2. What is implementing them?

  3. Where are they defined?

  4. How to implement from number 2, to number 1?

so in this part we have to answer these 4 questions.

 

DOWNLOAD FULL TUTORIAL WITH IMAGES FROM HERE

 
موافقین ۰ مخالفین ۰ 14 July 17 ، 03:12

Part 1.1

Adding simple system call to kernel from scratch


 

DOWNLOAD FULL TUTORIAL WITH IMAGES FROM HERE

First create a directory named linuxSRC to download linux source, and Change directory to the folder:

console:

mkdir /linuxSRC
cd linuxSRC

 

after that you should first download the linux source, inorder to download every source on the package repository of ubuntu you should go to your package list ,You need to uncomment the deb-src lines in the main file /etc/apt/sources.list not the extra files in/etc/apt/sources.list.d:
open software & updates
go to ubuntu software tab
check source code
save and exit

 

after that you should get your current version linux kernel and build dependencies:

console:

 

mkdir newKernel
cd newKernel

 

now download the linux source and decompress it:

console:

 

sudo apt-get install linux source
tar xjvf /usr/src/linux-source-<yourversion>tar.bz2

now go to the specified folder bellow :

 

/home/nubuntu/linuxSRC/linux-source-4.4.0/arch/x86/entry/syscalls

now open syscall_64.tbl or syscall_32.tbl (based on your system)(i use 64)

at the end add your hello syscall after the last number (here 333), with the following format, save and exit.
 

from here the tutorial have images, so I've created a nice PDF document with screen shots to download.

DOWNLOAD FULL TUTORIAL WITH IMAGES FROM HERE

 
موافقین ۰ مخالفین ۰ 11 July 17 ، 06:42




in these series of tutorials i want to play with Linux kernel and Loadable Kernel Modules (LKM) along with getting basic information about kernel architecture and system calls (part 1) , proc file system and processes information's (part 2), these tutorials are adopted from my operating system's class project.

there are two major parts as i mentioned before:

 
  1. Linux kernel (focusing on system calls)
  • Building kernel from source with adding a simple system call
  • Finding specified devices information and necessary functions to implement them
  • How to implement the system call and user space program to get info on specified drivers from kernel

     2. Loadable Kernel Modules (focusing on Proc File system)

  • Implementation of simple “hello world” module and run
  • Finding specified information and necessary functions to implement desired module
  • Implementation of desired kernel module and user program

requirements:

  • Ubuntu version: 16.04.2 (recommended not required)

  • Linux kernel : 4.x.x

  • Internet connection

  • about 30 or 40 gigabytes of space (first part)

  • lots of time for compile ! (first part)



i will start from the simple system call in the next post.

navidx
موافقین ۰ مخالفین ۰ 11 July 17 ، 06:12