Using static checkers on Linux Kernel

One of the hurdles in contributing to Linux kernel as a beginner is to find something to work on. If you are working as a kernel developer or are a part of a kernel mentorship program, this shouldn’t be a problem. But for others, the first step is to send a bunch of coding style fixes for warnings reported by checkpatch. In addition to checkpatch, there are many other static analysis tools like sparse, coccinelle and smatch, used to analyse source code and find possible bugs.

Hardware compression algorithms

Compression is a common technique that allows us to reduce the size of data. We use it when we store or send files as zip, 7z or rar archives. It helps reduce the space occupied by files in the filesystem and also to save bandwidth while transferring over a network. In general, compression algorithms try to encode redundancy or regularity in data with lesser bits. There are many different software compression algorithms available.

FOSSHack 2021

FOSSHack 2021 FOSSHack 2021 is a remote hackathon, organized by FOSSUnited, that happened on 13-14 November. FOSSUnited is a non-profit foundation that seeks to foster more FOSS projects and contributors from India and this hackathon is one such initiative. The rules were simple: Build a FOSS project or Work on existing FOSS project during the weekend. The projects would be judged based on factors like technical complexity, completeness and utility.

Publishing packages to PyPI

The usability of a programming language depends on many factors and one of them is the availability of good libraries to build on. When libraries are available, we also need a way to search and download libraries with ease. Most modern langauges maintain some form of index to make dependency management easier. Examples include Crates.io for Rust and PyPI for Python. Python Package Index (PyPI) is an index and repository of Python packages.

Creating sysfs files

The kernel provides a few ways in which userspace programs can get information from the kernel space. procfs: Used to get information about running processes debugfs: Used by kernel developers for debugging sysfs Sysfs is used for data that is not related to a particular process. It has information about hardware devices attached to the system and about drivers handling those devices. Any file added to the sysfs becomes a part of the Linux Application Binary Interface (ABI).

Looking inside /dev/null

Accessing hardware devices like files An important role of the operating system is to allow the user applications to access hardware resources. It has to allow the user programs to use hardware while also ensuring that the applications have permissions to access it and don’t misuse them. To simplify access to hardware, Unix, by design, exposes most of the hardware devices to userspace as device files, usually present under /dev directory.

Creating debugfs files

debugfs debugfs is a pseudo-filesystem used for kernel debugging. It is usually mounted at /sys/kernel/debug. debugfs contains files that allow us to read debugging information. By default, only the root user can cd into the /sys/kernel/debug directory. To change it to allow the current user to cd into debugfs, we can remount it with uid set to the current user’s uid. sudo umount /sys/kernel/debug sudo mount -t debugfs none /sys/kernel/debug -o uid=`echo $UID` cd /sys/kernel/debug Creating debugfs entries Creating debugfs files is similar to creating character device files.

Misc character devices

Character Devices, Major and Minor numbers Based on granularity of access, there are two classes of devices: Character devices are accessed as a stream of bytes. Eg: Keyboards Block devices are accessed in blocks. For instance, hard disks transfer data in blocks of multiple bytes at a time. The kernel uses major and minor numbers to identify the attached hardware devices. Major number usually tells us the type of device. Minor numbers are used to differentiate two or more devices with the same major number.

Updating vulnerable Python dependencies

Finding vulnerable dependencies Safety-db is a database that keeps track of vulnerable python packages and version information. It is updated once a month. They also provide a tool called safety, that checks if the installed packages or packages in requirements.txt are identified as vulnerable using the safety-db. Install safety pip install safety Use safety to check all packages in the current virtual enviroment safety check Use safety to only check the dependencies listed in requirements.

Eudyptula Challenge task 5

In this post, I want to share what I learnt by doing task 5 of the Eudyptula challenge. The Eudyptula Challenge is a set of 20 tasks designed to help people get started with Linux kernel development. Task 5 of the challenge is to make a hello world kernel module get loaded automatically when a USB keyboard is plugged in. Loadable kernel modules Linux kernel allows us to load modules to the kernel while the kernel is running.