SlideShare una empresa de Scribd logo
1 de 29
Descargar para leer sin conexión
Hacking Linux Kernel



Amerigo Wang
Associate Software Engineer




                              1
Where is Linux kernel?
  Official website: http://www.kernel.org
  Bug report: http://bugzilla.kernel.org
  Mail archive: http://lkml.org
  Patch work (new): http://patchwork.kernel.org/
  Git trees: http://git.kernel.org/
  kernel.org has more than just the kernel.




                                                   2
Finding Kernel tar balls
  The latest versions information is located at:
  http://www.kernel.org/kdist/finger_banner
  2.6 stable kernels and patches are available at:
  http://www.kernel.org/pub/linux/kernel/v2.6/
  -rc kernels and patches for 2.6 are in:
  http://www.kernel.org/pub/linux/kernel/v2.6/testing/
  2.4 stable kernels and patches (maintained by Willy Tarreau)
  available at: http://www.kernel.org/pub/linux/kernel/v2.4/
  -rt kernel patches are here:
  http://www.kernel.org/pub/linux/kernel/projects/rt/




                                                                 3
Compiling Linux Kernel
  tar -xvjf linux-2.6.x.y.tar.bz2
  cd linux-2.6.x.y
  cp /boot/config-`uname -r` .config
  make oldconfig
  make && make modules
  make modules_install && make install




                                         4
Tips
  yes “”| make oldconfig
  make menuconfig/make xconfig/make defconfig
  zcat /proc/config.gz >.config
  mkinitfs for Ubuntu
  mkinitcpio for Archlinux
  make randconfig/make allyesconfig
  make tags/make cscope




                                                5
6
7
Linux Kernel Development




                           8
Kernel Versioning
Up to version 2.5, the minor version
number identified the type of kernel.
This is not true since 2.6.
2.6.x(.y) kernels are all stable release.
2.6.x kernels are the base stable releases
released by Linus.
2.6.x.y kernels are -stable kernels
released by stable team (Greg KH &Chris
Wright), where 'y' denotes patch level.
2.6.x-rcX, 2.6.x-rcX-mmY, 2.6.x-mmX
are development kernels.



                                             9
10
-mm tree and linux-next tree
  They are both staging trees, run on your own risk.
  You are welcome to test them.
  -mm is maintained by Andrew Morton, with quilt.
  -mmotm is a snapshot of Andrew's -mm patch queue, which is
  available at: http://userweb.kernel.org/~akpm/mmotm/
  linux-next is a snapshot of what the mainline is expected to look
  like after the next merge window closes, maintained by Stephen
  Rothwell, with git.
  http://www.kernel.org/pub/linux/kernel/people/sfr/linux-next/
  http://linux.f-seidel.de/linux-next/pmwiki/




                                                                      11
Kernel Development Model
  Changes are submitted as patches, with emails, to LKML.
  Patches are reviewed by other people and/or the maintainers.
  Patches are collected by relevant subsystem maintainers, or go to
  Andrew Morton by default.
  Subsystem maintainers submit their queued patches to Linus,
  Linus is the highest level maintainer.
  Anyone can submit patches to LKML. Trivial pactches are also
  welcome.
  Stable releases are independent, stable@kernel.org
  The kernel community is driven by credits and reputations.




                                                                      12
13
Stable release
  Rule 1: It must be obviously correct and tested.
  Rule 2: It can not bigger than 100 lines, with context.
  Rule 3: It must fix only one problem that is critical.
  Rule 4: It can not contain any "trivial" fixes in it.
  Rule 5: It must be accepted by the relevant subsystem maintainer.
  When the -stable team decides for a review cycle, the patches
  will be sent to the review committee.
  The review committee has a short time in which to ACK or
  NACK the patch. The acked patches will be added to the latest
  -stable release.
  Depends on the major distributions, long-time supported stable
  releases are selected.

                                                                      14
15
Submitting patches




                     16
Patch
  A patch is a small text document containing a delta of changes
  between two different versions of a source tree.
  Patches are created with the 'diff' program (or git-diff, quilt etc.)
  `diff -up` or `diff -Nrup` is recommended.
  Demo
  Apply a patch with the `patch' program (or git-applypatch).
  Patches for the Linux kernel are generated relative to the parent
  directory holding the kernel source dir.
  Demo




                                                                          17
Patches for kernel releases
  Stable kernel patches apply to the base kernels.
  Base kernel release patches only apply to the previous base
  kernel version.
  Incremental patches upgrade from a specific release to the next
  release.
  The -rc patches are not incremental, they apply to a base 2.6.x
  kernel.
  The -mm kernels apply to either a base 2.6.x kernel or to a Linus
  -rc kernel.
  Example




                                                                      18
Submitting Your Patches
  Before you submit patches, please do read these files:
  Documentation/Changes, Documentation/CodingStyle,
  Documentation/SubmittingPatches,
  Documentation/SubmittingDrivers.
  “Patches are delivered via email only. Downloading them from
  internet servers is a pain.” -- Andrew Morton
  Check your email client. Read Documentation/email-clients.txt.
  Select the right destinations, Cc list. Always Cc the maintainers.
  Run scripts/get_maintainer.pl.
  The major list: linux-kernel@vger.kernel.org
  Make your patch in a right format accepted by the community.



                                                                       19
Patch Format
  Subject format: [PATCH $version $n/$total] $subsystem: one-line
  summary
  Email body contents: description, your patch and your Signed-
  off-by.
  If your patch is too big, split it into pieces, send them separately.
  _Always_ make your email text/plain.
  No MIME, no links, no compression and no attachments, if
  possible.
  Run scripts/checkpatch.pl to check your patch before sending.
  Example.




                                                                          20
Getting Your Patch Merged
  Be nice to every reviewers, especially the maintainers. :-)
  Keep on following your threads.
  Update your patch upon other people's suggestions, send the next
  version of it.
  If no one answers you, wait for some days and resend, with more
  relevant people Cc'ed.
  Making your patch description more detailed can also help.
  Be persistent, be patient, please.




                                                                     21
Tools
  Git
  Quilt
  mutt/alpine
  wiggle




                22
What else I can do




                     23
Testing Development Kernels
  Test the latest Linus tree, current -mm tree, everyday's linux-next
  tree.
  LTP is a good tool.
  Report bugs, regressions, or other problems to lkml.
  Or file a bug report in kernel bugzilla.
  Try your best to reproduce the bug.
  Bisect the git tree.
  If you can, try to fix it.




                                                                        24
Reviewing Patches
  Careful code reviews can prevent bugs.
  Review the patches that you are interested in.
  Test them by hands if possible.
  Put feedbacks to the author.
  Keep on moving with the author.




                                                   25
Getting Started
  Trivial fixes or coding style fixes are a good start.
  kernelnewbies.org
  Fix compiler warnings, sparse warnings.
  Read the source code. :)
  Subscribe lkml.
  Alan Cox:“Ignore everyone who tells you kernel hacking is
  hard, special or different. It's a large program, and bug fixing or
  driver tweaking can be a best starting point. It is however not
  magic, nor written in a secret language that only deep initiates
  with beards can read.”




                                                                        26
References




             27
References
  Greg KH, Linux Kernel in a Nutshell , O'Reilly, 2006.
  Greg KH, Myths, Lies, and Truths about the Linux kernel,
  http://www.kroah.com/log/linux/ols_2006_keynote.html
  Documentation/development-process/*




                                                             28
Thanks mate! Happy Hacking!



         Questions?



                              29

Más contenido relacionado

La actualidad más candente

Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel DevelopmentPriyank Kapadia
 
Container security
Container securityContainer security
Container securityAnthony Chow
 
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)William Liang
 
Docker, Linux Containers (LXC), and security
Docker, Linux Containers (LXC), and securityDocker, Linux Containers (LXC), and security
Docker, Linux Containers (LXC), and securityJérôme Petazzoni
 
Security of Linux containers in the cloud
Security of Linux containers in the cloudSecurity of Linux containers in the cloud
Security of Linux containers in the cloudDobrica Pavlinušić
 
Tokyo OpenStack Summit 2015: Unraveling Docker Security
Tokyo OpenStack Summit 2015: Unraveling Docker SecurityTokyo OpenStack Summit 2015: Unraveling Docker Security
Tokyo OpenStack Summit 2015: Unraveling Docker SecurityPhil Estes
 
Presentation for RHCE in linux
Presentation  for  RHCE in linux Presentation  for  RHCE in linux
Presentation for RHCE in linux Kuldeep Tiwari
 
Deploy microservices in containers with Docker and friends - KCDC2015
Deploy microservices in containers with Docker and friends - KCDC2015Deploy microservices in containers with Docker and friends - KCDC2015
Deploy microservices in containers with Docker and friends - KCDC2015Jérôme Petazzoni
 
Using Jenkins as Native Packages Factory - Jenkins User Conference Paris 2012
Using Jenkins as Native Packages Factory - Jenkins User Conference Paris 2012Using Jenkins as Native Packages Factory - Jenkins User Conference Paris 2012
Using Jenkins as Native Packages Factory - Jenkins User Conference Paris 2012Henri Gomez
 
Slide sistem operasi
Slide sistem operasiSlide sistem operasi
Slide sistem operasitheogrouptech
 
Lightweight Virtualization in Linux
Lightweight Virtualization in LinuxLightweight Virtualization in Linux
Lightweight Virtualization in LinuxSadegh Dorri N.
 
Lavigne bsdmag-jan13
Lavigne bsdmag-jan13Lavigne bsdmag-jan13
Lavigne bsdmag-jan13Dru Lavigne
 
Easy backup & restore with Clonezilla - Tips form Basic to Advanced
Easy backup & restore with Clonezilla - Tips form Basic to AdvancedEasy backup & restore with Clonezilla - Tips form Basic to Advanced
Easy backup & restore with Clonezilla - Tips form Basic to AdvancedChenkai Sun
 
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...Jérôme Petazzoni
 
Linuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best PracticesLinuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best Practiceschristophm
 
Kernel Recipes 2015 - Hardened kernels for everyone
Kernel Recipes 2015 - Hardened kernels for everyoneKernel Recipes 2015 - Hardened kernels for everyone
Kernel Recipes 2015 - Hardened kernels for everyoneAnne Nicolas
 
Operating project
Operating projectOperating project
Operating projectISMAT CH
 
Lxc- Linux Containers
Lxc- Linux ContainersLxc- Linux Containers
Lxc- Linux Containerssamof76
 

La actualidad más candente (20)

Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel Development
 
Bsd ss
Bsd ssBsd ss
Bsd ss
 
Container security
Container securityContainer security
Container security
 
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
 
Docker, Linux Containers (LXC), and security
Docker, Linux Containers (LXC), and securityDocker, Linux Containers (LXC), and security
Docker, Linux Containers (LXC), and security
 
Security of Linux containers in the cloud
Security of Linux containers in the cloudSecurity of Linux containers in the cloud
Security of Linux containers in the cloud
 
Tokyo OpenStack Summit 2015: Unraveling Docker Security
Tokyo OpenStack Summit 2015: Unraveling Docker SecurityTokyo OpenStack Summit 2015: Unraveling Docker Security
Tokyo OpenStack Summit 2015: Unraveling Docker Security
 
Presentation for RHCE in linux
Presentation  for  RHCE in linux Presentation  for  RHCE in linux
Presentation for RHCE in linux
 
Deploy microservices in containers with Docker and friends - KCDC2015
Deploy microservices in containers with Docker and friends - KCDC2015Deploy microservices in containers with Docker and friends - KCDC2015
Deploy microservices in containers with Docker and friends - KCDC2015
 
Using Jenkins as Native Packages Factory - Jenkins User Conference Paris 2012
Using Jenkins as Native Packages Factory - Jenkins User Conference Paris 2012Using Jenkins as Native Packages Factory - Jenkins User Conference Paris 2012
Using Jenkins as Native Packages Factory - Jenkins User Conference Paris 2012
 
Portin g
Portin gPortin g
Portin g
 
Slide sistem operasi
Slide sistem operasiSlide sistem operasi
Slide sistem operasi
 
Lightweight Virtualization in Linux
Lightweight Virtualization in LinuxLightweight Virtualization in Linux
Lightweight Virtualization in Linux
 
Lavigne bsdmag-jan13
Lavigne bsdmag-jan13Lavigne bsdmag-jan13
Lavigne bsdmag-jan13
 
Easy backup & restore with Clonezilla - Tips form Basic to Advanced
Easy backup & restore with Clonezilla - Tips form Basic to AdvancedEasy backup & restore with Clonezilla - Tips form Basic to Advanced
Easy backup & restore with Clonezilla - Tips form Basic to Advanced
 
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...
 
Linuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best PracticesLinuxcon Barcelon 2012: LXC Best Practices
Linuxcon Barcelon 2012: LXC Best Practices
 
Kernel Recipes 2015 - Hardened kernels for everyone
Kernel Recipes 2015 - Hardened kernels for everyoneKernel Recipes 2015 - Hardened kernels for everyone
Kernel Recipes 2015 - Hardened kernels for everyone
 
Operating project
Operating projectOperating project
Operating project
 
Lxc- Linux Containers
Lxc- Linux ContainersLxc- Linux Containers
Lxc- Linux Containers
 

Destacado

Basic explanation to md5 implementation in C
Basic explanation to md5 implementation in CBasic explanation to md5 implementation in C
Basic explanation to md5 implementation in CSourav Punoriyar
 
Data Center Transformation
Data Center TransformationData Center Transformation
Data Center TransformationGregSchindler
 
Ignite: When You Need A DevOps Team
Ignite: When You Need A DevOps TeamIgnite: When You Need A DevOps Team
Ignite: When You Need A DevOps TeamMark Rendell
 
Overcoming Continuous Delivery Impedance
Overcoming Continuous Delivery ImpedanceOvercoming Continuous Delivery Impedance
Overcoming Continuous Delivery ImpedanceMark Rendell
 
Scrum in dev ops teams - Presentation from Scrum Gathering Bangalore
Scrum in dev ops teams - Presentation from Scrum Gathering BangaloreScrum in dev ops teams - Presentation from Scrum Gathering Bangalore
Scrum in dev ops teams - Presentation from Scrum Gathering BangaloreMirco Hering
 
Next Generation IT Delivery - What it means to deliver atthe speed of the Dig...
Next Generation IT Delivery - What it means to deliver atthe speed of the Dig...Next Generation IT Delivery - What it means to deliver atthe speed of the Dig...
Next Generation IT Delivery - What it means to deliver atthe speed of the Dig...Mirco Hering
 
Data Center Infrastructure Management Demystified
Data Center Infrastructure Management Demystified Data Center Infrastructure Management Demystified
Data Center Infrastructure Management Demystified Sunbird DCIM
 
Data Center Transformation
Data Center TransformationData Center Transformation
Data Center TransformationArraya Solutions
 
Continuous Delivery for IT Operations Teams
Continuous Delivery for IT Operations TeamsContinuous Delivery for IT Operations Teams
Continuous Delivery for IT Operations TeamsMark Rendell
 
ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?Tetsuyuki Kobayashi
 
Data Center Transformation Program Planning and Design
Data Center Transformation Program Planning and DesignData Center Transformation Program Planning and Design
Data Center Transformation Program Planning and DesignJoseph Schwartz
 
10 Steps to Data Center Infrastructure Management Success
10 Steps to Data Center Infrastructure Management Success10 Steps to Data Center Infrastructure Management Success
10 Steps to Data Center Infrastructure Management SuccessRaritan
 
Breaking the 2 Pizza Paradox with your Platform as an Application
Breaking the 2 Pizza Paradox with your Platform as an ApplicationBreaking the 2 Pizza Paradox with your Platform as an Application
Breaking the 2 Pizza Paradox with your Platform as an ApplicationMark Rendell
 
DevOps - Why 50 deploys per day is essential
DevOps - Why 50 deploys per day is essentialDevOps - Why 50 deploys per day is essential
DevOps - Why 50 deploys per day is essentialMartin Croker
 
Next Generation Data Center - IT Transformation
Next Generation Data Center - IT TransformationNext Generation Data Center - IT Transformation
Next Generation Data Center - IT TransformationDamian Hamilton
 
Data Center Infrastructure Management
Data Center Infrastructure ManagementData Center Infrastructure Management
Data Center Infrastructure Managementshahzad ahmed
 

Destacado (20)

Sockets and Socket-Buffer
Sockets and Socket-BufferSockets and Socket-Buffer
Sockets and Socket-Buffer
 
Qemu
QemuQemu
Qemu
 
Basic explanation to md5 implementation in C
Basic explanation to md5 implementation in CBasic explanation to md5 implementation in C
Basic explanation to md5 implementation in C
 
Data Center Transformation
Data Center TransformationData Center Transformation
Data Center Transformation
 
Ignite: When You Need A DevOps Team
Ignite: When You Need A DevOps TeamIgnite: When You Need A DevOps Team
Ignite: When You Need A DevOps Team
 
Overcoming Continuous Delivery Impedance
Overcoming Continuous Delivery ImpedanceOvercoming Continuous Delivery Impedance
Overcoming Continuous Delivery Impedance
 
The Future Data Center
The Future Data CenterThe Future Data Center
The Future Data Center
 
Scrum in dev ops teams - Presentation from Scrum Gathering Bangalore
Scrum in dev ops teams - Presentation from Scrum Gathering BangaloreScrum in dev ops teams - Presentation from Scrum Gathering Bangalore
Scrum in dev ops teams - Presentation from Scrum Gathering Bangalore
 
Next Generation IT Delivery - What it means to deliver atthe speed of the Dig...
Next Generation IT Delivery - What it means to deliver atthe speed of the Dig...Next Generation IT Delivery - What it means to deliver atthe speed of the Dig...
Next Generation IT Delivery - What it means to deliver atthe speed of the Dig...
 
Data Center Infrastructure Management Demystified
Data Center Infrastructure Management Demystified Data Center Infrastructure Management Demystified
Data Center Infrastructure Management Demystified
 
Data Center Transformation
Data Center TransformationData Center Transformation
Data Center Transformation
 
Continuous Delivery for IT Operations Teams
Continuous Delivery for IT Operations TeamsContinuous Delivery for IT Operations Teams
Continuous Delivery for IT Operations Teams
 
ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?
 
Data Center Transformation Program Planning and Design
Data Center Transformation Program Planning and DesignData Center Transformation Program Planning and Design
Data Center Transformation Program Planning and Design
 
10 Steps to Data Center Infrastructure Management Success
10 Steps to Data Center Infrastructure Management Success10 Steps to Data Center Infrastructure Management Success
10 Steps to Data Center Infrastructure Management Success
 
DCIM
DCIMDCIM
DCIM
 
Breaking the 2 Pizza Paradox with your Platform as an Application
Breaking the 2 Pizza Paradox with your Platform as an ApplicationBreaking the 2 Pizza Paradox with your Platform as an Application
Breaking the 2 Pizza Paradox with your Platform as an Application
 
DevOps - Why 50 deploys per day is essential
DevOps - Why 50 deploys per day is essentialDevOps - Why 50 deploys per day is essential
DevOps - Why 50 deploys per day is essential
 
Next Generation Data Center - IT Transformation
Next Generation Data Center - IT TransformationNext Generation Data Center - IT Transformation
Next Generation Data Center - IT Transformation
 
Data Center Infrastructure Management
Data Center Infrastructure ManagementData Center Infrastructure Management
Data Center Infrastructure Management
 

Similar a Hacking Linux Kernel Title Under 40 Characters

Kernel maintainance in Linux distributions: Debian
Kernel maintainance in Linux distributions: DebianKernel maintainance in Linux distributions: Debian
Kernel maintainance in Linux distributions: DebianAnne Nicolas
 
Linux Kernel - Let's Contribute!
Linux Kernel - Let's Contribute!Linux Kernel - Let's Contribute!
Linux Kernel - Let's Contribute!Levente Kurusa
 
Intro to Kernel Debugging - Just make the crashing stop!
Intro to Kernel Debugging - Just make the crashing stop!Intro to Kernel Debugging - Just make the crashing stop!
Intro to Kernel Debugging - Just make the crashing stop!All Things Open
 
Tuning systemd for embedded
Tuning systemd for embeddedTuning systemd for embedded
Tuning systemd for embeddedAlison Chaiken
 
Systemd for developers
Systemd for developersSystemd for developers
Systemd for developersAlison Chaiken
 
Instalando Cacti no CentOS 5
Instalando Cacti no CentOS 5Instalando Cacti no CentOS 5
Instalando Cacti no CentOS 5Carlos Eduardo
 
Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)Tushar B Kute
 
Maintenance des branches stables du noyau
Maintenance des branches stables du noyauMaintenance des branches stables du noyau
Maintenance des branches stables du noyauAnne Nicolas
 
Select, manage, and backport the long term stable kernels
Select, manage, and backport the long term stable kernelsSelect, manage, and backport the long term stable kernels
Select, manage, and backport the long term stable kernelsSZ Lin
 
Linaro and Android Kernel
Linaro and Android KernelLinaro and Android Kernel
Linaro and Android KernelJohn Lee
 
BSides Algiers - Linux Kernel and Recent Security Protections - Djallal Harouni
BSides Algiers - Linux Kernel and Recent Security Protections - Djallal HarouniBSides Algiers - Linux Kernel and Recent Security Protections - Djallal Harouni
BSides Algiers - Linux Kernel and Recent Security Protections - Djallal HarouniShellmates
 
Threats, Vulnerabilities & Security measures in Linux
Threats, Vulnerabilities & Security measures in LinuxThreats, Vulnerabilities & Security measures in Linux
Threats, Vulnerabilities & Security measures in LinuxAmitesh Bharti
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveAlison Chaiken
 
The Lives of Others: Open-Source Development Practices Elsewhere
The Lives of Others: Open-Source Development Practices ElsewhereThe Lives of Others: Open-Source Development Practices Elsewhere
The Lives of Others: Open-Source Development Practices ElsewherePeter Eisentraut
 
L lpic2201-pdf
L lpic2201-pdfL lpic2201-pdf
L lpic2201-pdfG&P
 
Linux host review
Linux host reviewLinux host review
Linux host reviewrglaal
 

Similar a Hacking Linux Kernel Title Under 40 Characters (20)

Linux internals v4
Linux internals v4Linux internals v4
Linux internals v4
 
Kernel maintainance in Linux distributions: Debian
Kernel maintainance in Linux distributions: DebianKernel maintainance in Linux distributions: Debian
Kernel maintainance in Linux distributions: Debian
 
Linux Kernel - Let's Contribute!
Linux Kernel - Let's Contribute!Linux Kernel - Let's Contribute!
Linux Kernel - Let's Contribute!
 
Intro to Kernel Debugging - Just make the crashing stop!
Intro to Kernel Debugging - Just make the crashing stop!Intro to Kernel Debugging - Just make the crashing stop!
Intro to Kernel Debugging - Just make the crashing stop!
 
Tuning systemd for embedded
Tuning systemd for embeddedTuning systemd for embedded
Tuning systemd for embedded
 
Appa
AppaAppa
Appa
 
Systemd for developers
Systemd for developersSystemd for developers
Systemd for developers
 
Instalando Cacti no CentOS 5
Instalando Cacti no CentOS 5Instalando Cacti no CentOS 5
Instalando Cacti no CentOS 5
 
Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)
 
Maintenance des branches stables du noyau
Maintenance des branches stables du noyauMaintenance des branches stables du noyau
Maintenance des branches stables du noyau
 
Select, manage, and backport the long term stable kernels
Select, manage, and backport the long term stable kernelsSelect, manage, and backport the long term stable kernels
Select, manage, and backport the long term stable kernels
 
Linaro and Android Kernel
Linaro and Android KernelLinaro and Android Kernel
Linaro and Android Kernel
 
BSides Algiers - Linux Kernel and Recent Security Protections - Djallal Harouni
BSides Algiers - Linux Kernel and Recent Security Protections - Djallal HarouniBSides Algiers - Linux Kernel and Recent Security Protections - Djallal Harouni
BSides Algiers - Linux Kernel and Recent Security Protections - Djallal Harouni
 
Threats, Vulnerabilities & Security measures in Linux
Threats, Vulnerabilities & Security measures in LinuxThreats, Vulnerabilities & Security measures in Linux
Threats, Vulnerabilities & Security measures in Linux
 
Building
BuildingBuilding
Building
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to love
 
The Lives of Others: Open-Source Development Practices Elsewhere
The Lives of Others: Open-Source Development Practices ElsewhereThe Lives of Others: Open-Source Development Practices Elsewhere
The Lives of Others: Open-Source Development Practices Elsewhere
 
L lpic2201-pdf
L lpic2201-pdfL lpic2201-pdf
L lpic2201-pdf
 
Intro to linux
Intro to linuxIntro to linux
Intro to linux
 
Linux host review
Linux host reviewLinux host review
Linux host review
 

Hacking Linux Kernel Title Under 40 Characters

  • 1. Hacking Linux Kernel Amerigo Wang Associate Software Engineer 1
  • 2. Where is Linux kernel? Official website: http://www.kernel.org Bug report: http://bugzilla.kernel.org Mail archive: http://lkml.org Patch work (new): http://patchwork.kernel.org/ Git trees: http://git.kernel.org/ kernel.org has more than just the kernel. 2
  • 3. Finding Kernel tar balls The latest versions information is located at: http://www.kernel.org/kdist/finger_banner 2.6 stable kernels and patches are available at: http://www.kernel.org/pub/linux/kernel/v2.6/ -rc kernels and patches for 2.6 are in: http://www.kernel.org/pub/linux/kernel/v2.6/testing/ 2.4 stable kernels and patches (maintained by Willy Tarreau) available at: http://www.kernel.org/pub/linux/kernel/v2.4/ -rt kernel patches are here: http://www.kernel.org/pub/linux/kernel/projects/rt/ 3
  • 4. Compiling Linux Kernel tar -xvjf linux-2.6.x.y.tar.bz2 cd linux-2.6.x.y cp /boot/config-`uname -r` .config make oldconfig make && make modules make modules_install && make install 4
  • 5. Tips yes “”| make oldconfig make menuconfig/make xconfig/make defconfig zcat /proc/config.gz >.config mkinitfs for Ubuntu mkinitcpio for Archlinux make randconfig/make allyesconfig make tags/make cscope 5
  • 6. 6
  • 7. 7
  • 9. Kernel Versioning Up to version 2.5, the minor version number identified the type of kernel. This is not true since 2.6. 2.6.x(.y) kernels are all stable release. 2.6.x kernels are the base stable releases released by Linus. 2.6.x.y kernels are -stable kernels released by stable team (Greg KH &Chris Wright), where 'y' denotes patch level. 2.6.x-rcX, 2.6.x-rcX-mmY, 2.6.x-mmX are development kernels. 9
  • 10. 10
  • 11. -mm tree and linux-next tree They are both staging trees, run on your own risk. You are welcome to test them. -mm is maintained by Andrew Morton, with quilt. -mmotm is a snapshot of Andrew's -mm patch queue, which is available at: http://userweb.kernel.org/~akpm/mmotm/ linux-next is a snapshot of what the mainline is expected to look like after the next merge window closes, maintained by Stephen Rothwell, with git. http://www.kernel.org/pub/linux/kernel/people/sfr/linux-next/ http://linux.f-seidel.de/linux-next/pmwiki/ 11
  • 12. Kernel Development Model Changes are submitted as patches, with emails, to LKML. Patches are reviewed by other people and/or the maintainers. Patches are collected by relevant subsystem maintainers, or go to Andrew Morton by default. Subsystem maintainers submit their queued patches to Linus, Linus is the highest level maintainer. Anyone can submit patches to LKML. Trivial pactches are also welcome. Stable releases are independent, stable@kernel.org The kernel community is driven by credits and reputations. 12
  • 13. 13
  • 14. Stable release Rule 1: It must be obviously correct and tested. Rule 2: It can not bigger than 100 lines, with context. Rule 3: It must fix only one problem that is critical. Rule 4: It can not contain any "trivial" fixes in it. Rule 5: It must be accepted by the relevant subsystem maintainer. When the -stable team decides for a review cycle, the patches will be sent to the review committee. The review committee has a short time in which to ACK or NACK the patch. The acked patches will be added to the latest -stable release. Depends on the major distributions, long-time supported stable releases are selected. 14
  • 15. 15
  • 17. Patch A patch is a small text document containing a delta of changes between two different versions of a source tree. Patches are created with the 'diff' program (or git-diff, quilt etc.) `diff -up` or `diff -Nrup` is recommended. Demo Apply a patch with the `patch' program (or git-applypatch). Patches for the Linux kernel are generated relative to the parent directory holding the kernel source dir. Demo 17
  • 18. Patches for kernel releases Stable kernel patches apply to the base kernels. Base kernel release patches only apply to the previous base kernel version. Incremental patches upgrade from a specific release to the next release. The -rc patches are not incremental, they apply to a base 2.6.x kernel. The -mm kernels apply to either a base 2.6.x kernel or to a Linus -rc kernel. Example 18
  • 19. Submitting Your Patches Before you submit patches, please do read these files: Documentation/Changes, Documentation/CodingStyle, Documentation/SubmittingPatches, Documentation/SubmittingDrivers. “Patches are delivered via email only. Downloading them from internet servers is a pain.” -- Andrew Morton Check your email client. Read Documentation/email-clients.txt. Select the right destinations, Cc list. Always Cc the maintainers. Run scripts/get_maintainer.pl. The major list: linux-kernel@vger.kernel.org Make your patch in a right format accepted by the community. 19
  • 20. Patch Format Subject format: [PATCH $version $n/$total] $subsystem: one-line summary Email body contents: description, your patch and your Signed- off-by. If your patch is too big, split it into pieces, send them separately. _Always_ make your email text/plain. No MIME, no links, no compression and no attachments, if possible. Run scripts/checkpatch.pl to check your patch before sending. Example. 20
  • 21. Getting Your Patch Merged Be nice to every reviewers, especially the maintainers. :-) Keep on following your threads. Update your patch upon other people's suggestions, send the next version of it. If no one answers you, wait for some days and resend, with more relevant people Cc'ed. Making your patch description more detailed can also help. Be persistent, be patient, please. 21
  • 22. Tools Git Quilt mutt/alpine wiggle 22
  • 23. What else I can do 23
  • 24. Testing Development Kernels Test the latest Linus tree, current -mm tree, everyday's linux-next tree. LTP is a good tool. Report bugs, regressions, or other problems to lkml. Or file a bug report in kernel bugzilla. Try your best to reproduce the bug. Bisect the git tree. If you can, try to fix it. 24
  • 25. Reviewing Patches Careful code reviews can prevent bugs. Review the patches that you are interested in. Test them by hands if possible. Put feedbacks to the author. Keep on moving with the author. 25
  • 26. Getting Started Trivial fixes or coding style fixes are a good start. kernelnewbies.org Fix compiler warnings, sparse warnings. Read the source code. :) Subscribe lkml. Alan Cox:“Ignore everyone who tells you kernel hacking is hard, special or different. It's a large program, and bug fixing or driver tweaking can be a best starting point. It is however not magic, nor written in a secret language that only deep initiates with beards can read.” 26
  • 28. References Greg KH, Linux Kernel in a Nutshell , O'Reilly, 2006. Greg KH, Myths, Lies, and Truths about the Linux kernel, http://www.kroah.com/log/linux/ols_2006_keynote.html Documentation/development-process/* 28
  • 29. Thanks mate! Happy Hacking! Questions? 29