<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Kernel on Chris J Arges</title><link>https://chrisarges.net/tags/kernel/</link><description>Recent content in Kernel on Chris J Arges</description><generator>Hugo</generator><language>en</language><lastBuildDate>Thu, 21 Mar 2019 11:54:37 -0500</lastBuildDate><atom:link href="https://chrisarges.net/tags/kernel/index.xml" rel="self" type="application/rss+xml"/><item><title>bpf for linux tracing</title><link>https://chrisarges.net/posts/2019-03-21-bpf-for-tracing/</link><pubDate>Thu, 21 Mar 2019 11:54:37 -0500</pubDate><guid>https://chrisarges.net/posts/2019-03-21-bpf-for-tracing/</guid><description>&lt;h2 id="overview"&gt;Overview&lt;/h2&gt;&#10;&lt;p&gt;Originally called eBPF for extended Berkeley Packet Filter, BPF is an in-kernel&#10;bytecode interpreter that is very multi-purpose. In this post, I&amp;rsquo;m going to&#10;focus on its tracing capabilities.&lt;/p&gt;&#10;&lt;p&gt;To use BPF one can use the bpf &lt;a href="http://man7.org/linux/man-pages/man2/bpf.2.html"&gt;syscall&lt;/a&gt;. This provides a way to both load&#10;BPF bytecode programs and also create memory maps for sharing data between&#10;kernel and user space.&lt;/p&gt;&#10;&lt;p&gt;Because of the complexity, using bpf in a DIY method becomes a bit complex.&#10;There are many ready to use tools such as &lt;a href="https://github.com/iovisor/bcc"&gt;BCC&lt;/a&gt; and libbpf that make usage&#10;way easier.&lt;/p&gt;</description></item><item><title>the magic of linux clone</title><link>https://chrisarges.net/posts/2019-01-14-the-magic-of-linux-clone/</link><pubDate>Mon, 14 Jan 2019 12:44:27 -0600</pubDate><guid>https://chrisarges.net/posts/2019-01-14-the-magic-of-linux-clone/</guid><description>&lt;p&gt;Processes and threads are concepts that have been used across many operating&#10;systems and programming languages. While we tend to think of &amp;lsquo;process&amp;rsquo; as a&#10;heavy thing and &amp;rsquo;thread&amp;rsquo; as a light thing, how they are implemented and handled&#10;depends on context. This article will focus on how the Linux operating system&#10;handles these concepts and the mechanisms used.&lt;/p&gt;&#10;&lt;h2 id="creating-a-new-process"&gt;Creating a new process&lt;/h2&gt;&#10;&lt;p&gt;Generally in Linux if you want to create a new process in C you can do the following:&lt;/p&gt;</description></item><item><title>tracing in linux</title><link>https://chrisarges.net/posts/2018-10-04-tracing-in-linux/</link><pubDate>Thu, 04 Oct 2018 09:39:10 -0500</pubDate><guid>https://chrisarges.net/posts/2018-10-04-tracing-in-linux/</guid><description>&lt;p&gt;Tracing in Linux is robust, flexible and has many options. So what mechanisms&#10;exist both in kernel and user space for instrumenting the kernel? In addition&#10;what is available in which kernel version, and what requirements does each&#10;technology require? Here we&amp;rsquo;ll mostly focus on syscall tracing.&lt;/p&gt;&#10;&lt;h2 id="overview"&gt;Overview&lt;/h2&gt;&#10;&lt;p&gt;A great overview on Linux tracing systems can be found &lt;a href="https://jvns.ca/blog/2017/07/05/linux-tracing-systems/"&gt;here&lt;/a&gt;. Overall&#10;thinking about tracing systems as data sources (in kernel), and frontends help&#10;explain why there are so many tools. Some data sources are &amp;rsquo;tracepoints&amp;rsquo; while&#10;other are &amp;lsquo;probes&amp;rsquo;. Tracepoints are low-overhead and can be activated or&#10;deactivated, they are compiled into the kernel so they cannot be dynamically&#10;instrumented. Probes are very flexible, but require larger overhead as you are&#10;replacing a &amp;rsquo;nop&amp;rsquo; instruction with a branch in order to redirect execution of&#10;probed function. In addition you must know the function name and can only&#10;instrument &amp;lsquo;real&amp;rsquo; (non-inlined) functions. Some good slides describing this are&#10;&lt;a href="https://blog.linuxplumbersconf.org/2014/ocw/system/presentations/1773/original/ftrace-kernel-hooks-2014.pdf"&gt;here&lt;/a&gt;. Other overviews of tracing technologies can be found &lt;a href="http://www.brendangregg.com/blog/2015-07-08/choosing-a-linux-tracer.html"&gt;here&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>flashing coreboot on an x60t</title><link>https://chrisarges.net/posts/2016-02-08-coreboot-on-an-x60t/</link><pubDate>Mon, 08 Feb 2016 08:48:47 -0600</pubDate><guid>https://chrisarges.net/posts/2016-02-08-coreboot-on-an-x60t/</guid><description>&lt;p&gt;I was gifted a dusty X60t and remembered how it was one of the more well&#10;supported targets for coreboot/libreboot. Thus I decided to take it apart and&#10;reflash the BIOS. The following articles explains how this is done. Note, that&#10;it is possible to flash the BIOS from a booted Linux install; I decided to do&#10;things the hard way.&lt;/p&gt;&#10;&lt;h1 id="disassembly"&gt;Disassembly&lt;/h1&gt;&#10;&lt;p&gt;This &lt;a href="https://libreboot.org/docs/install/x60tablet_unbrick.html"&gt;guide&lt;/a&gt; does a really good job of explaining how to take apart the X60t.&#10;I took pictures of before and after to remember where things were placed. The&#10;BIOS chip on my motherboard was on the backside so I had to remove it&#10;completely from the chassis.&lt;/p&gt;</description></item><item><title>using ktest.pl with ubuntu</title><link>https://chrisarges.net/posts/2014-07-01-using-ktestpl-with-ubuntu/</link><pubDate>Tue, 01 Jul 2014 13:10:00 -0700</pubDate><guid>https://chrisarges.net/posts/2014-07-01-using-ktestpl-with-ubuntu/</guid><description>&lt;p&gt;Bisecting the kernel is one of those tasks that&amp;rsquo;s time-consuming and error prone.&#10;Ktest.pl is a script that lives in the linux kernel source &lt;a href="http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/tools/testing/ktest?id=HEAD"&gt;tree&lt;/a&gt; that helps&#10;to automate this process. The script is extremely extensible and as&#10;such takes time to understand which variables need to be set and where. In this&#10;post, I&amp;rsquo;ll go over how to perform a kernel bisection using a VM as the target&#10;machine. In this example I&amp;rsquo;m using &amp;lsquo;ubuntu&amp;rsquo; as the VM name.&lt;/p&gt;</description></item><item><title>using kgraft with ubuntu</title><link>https://chrisarges.net/posts/2014-06-06-using-kgraft-with-ubuntu/</link><pubDate>Fri, 06 Jun 2014 11:50:00 -0700</pubDate><guid>https://chrisarges.net/posts/2014-06-06-using-kgraft-with-ubuntu/</guid><description>&lt;p&gt;New live kernel patching projects have hit LKML recently &lt;a href="https://lkml.org/lkml/2014/4/30/477"&gt;here&lt;/a&gt; and&#10;&lt;a href="https://lkml.org/lkml/2014/5/1/273"&gt;here&lt;/a&gt;, and I&amp;rsquo;ve taken the opportunity to test drive kGraft with the Ubuntu&#10;kernel. This post documents how to get a sample patch working.&lt;/p&gt;&#10;&lt;p&gt;First, I had to take the &lt;a href="https://git.kernel.org/cgit/linux/kernel/git/jirislaby/kgraft.git/"&gt;patches&lt;/a&gt; and apply them against the&#10;ubuntu-utopic kernel, which is based on 3.15-rc8 as of this post. They&#10;cherry-picked cleanly and the branch I&amp;rsquo;m using is stored &lt;a href="http://zinc.ubuntu.com/git?p=arges/ubuntu-utopic.git;a=shortlog;h=refs/heads/kgraft-utopic"&gt;here&lt;/a&gt;. In addition&#10;to applying the patches I had to also enable CONFIG_KGRAFT. A pre-built test&#10;kernel can be downloaded &lt;a href="http://people.canonical.com/~arges/kgraft-utopic/"&gt;here&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>netfilter hooks to snoop packets</title><link>https://chrisarges.net/posts/2014-03-24-netfilter-hooks-to-snoop-packets/</link><pubDate>Mon, 24 Mar 2014 07:47:00 -0700</pubDate><guid>https://chrisarges.net/posts/2014-03-24-netfilter-hooks-to-snoop-packets/</guid><description>&lt;p&gt;I&amp;rsquo;ve written a short netfilter hook to help snoop some outgoing packets. You can&#10;view the source code &lt;a href="https://github.com/arges/nf-snoop"&gt;here&lt;/a&gt;. I read &lt;a href="http://www.netfilter.org/documentation/HOWTO/netfilter-hacking-HOWTO-3.html"&gt;a&lt;/a&gt; &lt;a href="http://www.linuxjournal.com/article/7184"&gt;few&lt;/a&gt; &lt;a href="http://www.paulkiddie.com/2009/10/creating-a-simple-hello-world-netfilter-module/"&gt;articles&lt;/a&gt; to get an&#10;idea of how to put things together.&lt;/p&gt;</description></item><item><title>using git send-email for sending kernel patches</title><link>https://chrisarges.net/posts/2013-07-18-using-git-send-email-for-sending-kernel/</link><pubDate>Thu, 18 Jul 2013 15:27:00 -0700</pubDate><guid>https://chrisarges.net/posts/2013-07-18-using-git-send-email-for-sending-kernel/</guid><description>&lt;p&gt;Sending patches to a Linux kernel mailing list can be done easily using&#10;git-send-email. This post will help setup your environment and show you how to&#10;format the git send-email command. In addition there are some more advanced&#10;features that help when you need to send from multiple accounts.&lt;/p&gt;&#10;&lt;h3 id="git-setup"&gt;Git Setup&lt;/h3&gt;&#10;&lt;p&gt;First, install git and git-email. Then, setup &lt;code&gt;~/.gitconfig&lt;/code&gt; for your user&#10;and proper sendemail section. This shows a sendemail setup for a typical single&#10;gmail account.&lt;/p&gt;</description></item></channel></rss>