Lập Trình Linux

How Do Linux Kernel Drivers Work? – Learning Resource

If you want to hack the Kernel, are interested in jailbreaks or just want to understand computers better, Linux Device Drivers is a great book to get you started. I used to learn the basics and in this video I want to share what *clicked* for me.

LDD Book:
LDD3 Example Code Updated:

-=[ 🔴 Stuff I use ]=-

→ Microphone:*
→ Graphics tablet:*
→ Camera#1 for streaming:*
→ Lens for streaming:*
→ Connect Camera#1 to PC:*
→ Camera#2 for electronics:*
→ Lens for macro shots:*
→ Keyboard:*
→ Headphones:*

-=[ ❤️ Support ]=-

→ per Video:
→ per Month:

-=[ 🐕 Social ]=-

→ Twitter:
→ Website:
→ Subreddit:
→ Facebook:

-=[ 📄 P.S. ]=-

All links with “*” are affiliate links.
LiveOverflow / Security Flag GmbH is part of the Amazon Affiliate Partner Programm.


Phần Mềm
Cách đưa iPhone 7 về chế độ DFU nhanh nhất How to reboot, reset, or enter DFU mode
Dự báo thời tiết 21/05/2020 | Bắc Bộ ngày nắng nóng, đêm mưa giông | VTC16
GIẢM CÂN sau Tết – Bài tập lấy lại vóc dáng cực nhanh!
  • Id like to listen to you just read it on YouTube but you almost certainly have better things to do.

  • Learn python well before you start messing around with the kernel.

  • Dude this is gold and I love you

  • Fantastic video, really enjoy your stuff.
    The joy in your eyes is great to see.

  • this will keep me busy for months XD

  • Great stuff. Very clear, thank you.


  • Thank you so much for the channel, I keep learning a lot!

  • I'm sorry, but it's perfect: "files"

  • Great video! I honestly share your joy! 🙂

    The buffering scenario that you demonstrated through Python is also an interesting one. It can probably be used as an entry point to the story of the kernel space protection mechanism. Kernel memory space and user memory space are separated. The buffer that a user creates within the boundaries of its Python interpreter has to be transferred to the kernel space to be forwarded to "file". That can be done through some kind of "*_copy_from_user", "*_copy_to_user". Jumping over the kernel fence involves certain (potentially time-consuming) machinery. What about buffering that?

  • You say reading the whole book right here would be a dumb idea but I disagree. I'm not saying that you should or that I would watch it just that audio books are thing why can't they have a accompanying video? Just say'n… maybe for a different channel it could be a great idea to read a whole book or a hole book, that's a book about holes I'd suppose lol.


    Author Reply

    There needs to be a part two that goes deeper into the more advanced topics.

  • cool video

  • If you like Python programming and file interfaces, you might love Python Fuse ( pip install fuse-python ) : write a virtual file interface in Python, straighter to the goal without compiling kernel modules. Thanks a lot for this tutorial. Love it!

  • Gentoo will kick your ass and teach you everything. Best 6 months I spent in a terminal as far as a learning experience. I'm hands on. I not going to recommend you do it but it will teach you all about kernel functionality module loading blacklisting initramfs the boot process I didn't have to pick up a book. I just wiped a laptop one day and said not stopping till it's done. Gentoo forces you to do everything manually. Including learning how to use the tools inside of the /usr/src/linux/bin folder (a symlink on that OS that points to your build tree) that allows you to automate config do test and more of the advanced tasks like finding memory leaks and learn how to config to mitigate them.

    I'm not saying go use it every day just try it. It'll kick your ass and teach ya a lot about the terminal the kernel the boot process among a boat load of other topics.

    I didn't know the different between a /dev/tty and a /dev/pty till I needed to learn to script a chroot with a virtual terminal. Something id not have known if the very design of the operating system hadn't forced it on me. I could not build my own initramfs that would bootstrap the kernel to load from an M.2 key without crashing and burning learning about Dracut and learning to build my own initramfs. I wouldn't have a running kernel that takes up less than 64 MB of ram when my system is running and boots up in five seconds without learning how to optimize it.

    When you learn to Linux you start see why it's superior. Eat my memory footprint nt users they can't touch the efficiency of the Linux kernel at all.

  • This was excellent !

  • print("hello hacker")
    >>> use sudo bro..!
    Inside me : 😱😱😱

  • What piano is that? Is it a p45?

  • Wonderful video, thank you. Editing was done superbly too.
    I hope you will have a proper office chair one day. That one looks painful to sit on.

  • How Do Linux Kernel Drivers Work?

    They dont.
    End of video.

  • I want to know what keyboard you are using :d it sounds amazing

  • Thanks for the video.
    I bumped into this 20 years ago when we did socks scanner shenanigans for IRC…

    It's nice to watch that kernel drivers made you act like if you're on cocaine.:)

  • Have you checked out the Plan 9 kernel?

  • Thanks for the very simple explanation of such a complex topic!

  • I'm really glad to have found this channel. Extremely interesting, very straight-foward and substantive 🙂

  • I now want a 2hr version of this 😂 this was amazing

  • Did anyone notice that this guy sound a bit like PewDiePie? No kidding. Just listen to his words without watching the video.

  • The first time I ever learned about everything in linux is a file is in the movie Jurrasic Park when the little girl and her brother tries to lock the room with a computer 🙂

  • wow a linux streamer who does not suck!

  • Hmm, I bought and still have the First Edition of this book when it was new.

  • Here is doc for Linux Kernel for 5.4 https://www.kernel.org/doc/html/v5.4/driver-api/index.html
    here is list for different versions : https://www.kernel.org/doc/html/

  • You can probably fix the python buffering problem by running it in unbuffered mode:
    python -u

    I use this for python to output directly to other processes and it works for me. However I am not sure of how it behaves in multi-processing cases

  • Realtek driver don’t work 🙁

  • I swear almost thought this guy was MIchael Cera ( from Scott Pilgrim vs the World movie)

  • That moment when things click in ur brain👌

  • Your enthusiasm is contagious

  • This book is so obsolete nowadays. In fact it had already been when I first read it about 10 years ago…

  • Hi LiveOverflow
    Liked the Video. Btw, you look like the male character 'Paulie Bleeker' or 'Michael Cera' from the movie 'Juno'.

  • 12:35 the really interesting part gets skipped over in 4 seconds

  • dipidipi

    Author Reply

    This is excellent, and it really makes me want to write a driver — like way back after I purchased the 2nd edition of that »Linux Kernel Drivers« tome (for €39.60, ouch).
    Grüße aus Nürnberg (where IBM also has a building, near the Saturnweg)!

  • One day I will understand this video.

  • Here are some resources that happen to be on sale today for $5:

  • i've gotten into these nooks countless times… Raspberry Pi , is a good exercise. For example, if you make a device, as opposed to buying one, you will have to write the driver. Linux is amazing in the regard that it is totally open for US to use and hence, we make it so we 'can' use it. SO others can 'make sense' of it… Its not like some crap that comes off a shelf and only does one thing. take the car off roading kinda thing. Every once in a while I will need to make a light blink on a server HDD chassis. The backplane is totally accessible through those "files" .. files .. lol . On a stripped down kernel there are no proprietary drivers. Its linux so we don't have to give up. Just read the docs and find where to push the buttons. Some file thats not a file, buried in a loop of a mess > sys class < I totally don't remember off the top of my head !! Ya, could just put the drivers in,, but why ? don't need it. A different note: I wish more people would get into RTOS . Advancing RTOS would change the world

  • f.write("Hello Worldn") would've probably flushed to the file automatically, considering it's in line buffering mode

  • They don't, in my experience.

  • Hey, Kernel dev here. Just wanted to mention that the reason they aren't publishing another book is because O'Reilly didn't want to. GKH was intending to publish another, and had quite a bit written for it. They're including all of his writings in /doc in the kernel itself. They definitely do need new devs working on drivers, in part because industry driver devs often times write bad/unmaintained code. Working on cleaning these up is a great way for someone to break into the kernel dev community.

  • I can see you enjoyed playing it 😆

  • CentOS 6 is ended with 2.6.32, maybe a good idea to use it for this.

  • 14:03 Or you could have done f.flush().

    Another option would be to use the lower-level os.open/read/write/close calls, which work on direct kernel FDs without imposing their own buffering, like regular Python file objects do.

  • 11:14 This is why people say there is no “stable” Linux kernel API as such. Calls to internal kernel routines are subject to change at any time. This is why the kernel developers don’t encourage you to carry your own drivers/modules outside the mainline kernel; it is easier long term to get it accepted into the official source tree, where it can be maintained along with the rest of the source.