How to build a Linux loadable kernel module that Rickrolls people

Ғылым және технология

A totally legit use for Linux loadable kernel modules because....Linux.
Hope you enjoyed the video!
Check out this code here:
github.com/engineer-man/youtu...
Join my Discord server to chat with me:
/ discord
Check out some code on my GitHub:
github.com/ebrian/engineerman
Tweet me something funny on Twitter:
/ _engineerman
Say hi over at Facebook:
/ engineermanyt
Sincerely,
Engineer Man

Пікірлер: 184

  • @garryvee
    @garryvee2 жыл бұрын

    As a retired software engineer, starting with IBM 370 systems, I find your videos to be remarkably interesting and educational. Very much appreciated.

  • @speediestmoon1404
    @speediestmoon14045 жыл бұрын

    1:43 "Kernel Space Program" my favorite video game... Oh wait, it's Kerbal Space Program? Crap

  • @ChristopherGray00

    @ChristopherGray00

    4 жыл бұрын

    That would be interesting, the system crashing along with your ship.

  • @stephenjames5745
    @stephenjames57455 жыл бұрын

    Awesome introduction to kernel module development! Show me more! 😁

  • @pavel9652

    @pavel9652

    4 жыл бұрын

    You probably don't need it, but for future generations ;) There is a free book on Linux drivers development on LWN, which involves writing kernel modules. It is fairly old, as had been written for kernel 2.6, but these things didn't change much. Linux Device Drivers, Third Edition: lwn.net/Kernel/LDD3/

  • @Nunya58294

    @Nunya58294

    2 жыл бұрын

    Linux drivers are pretty easy to compile and write as long as you have a basic understanding of what your doing

  • @spicy_wizard
    @spicy_wizard5 жыл бұрын

    Hope you can do more on Operating System Programming as compared to web dev/machine learning, the resources on OS is scarce ! And you did great job on teaching it!!

  • @tissuepaper9962

    @tissuepaper9962

    3 жыл бұрын

    There's a book (somewhat outdated now) called just "Linux Kernel Development" by O'Reilly. Also "Linux Device Drivers" by someone else, can't remember. Really creative names, I know.

  • @Askaholic907
    @Askaholic9074 жыл бұрын

    Correctly me if I’m wrong, but I’m pretty sure you will have a buffer overflow if the user only supplies a small buffer. Always check the length of your destination buffers people!

  • @ancbi
    @ancbi4 жыл бұрын

    Me yesterday: researching kernel module & device file. Me today: Listening to rickroll in medieval style. KZread algorithm today:

  • @scootergirl3662
    @scootergirl366213 күн бұрын

    Despite being a great meme, also ironically one of the best Linux kernel development videos out there

  • @inqmusician2
    @inqmusician24 жыл бұрын

    You can make a virus, that opens Never Gonna Give You Up, as soon as browser is closed.

  • @milostean8615
    @milostean86155 жыл бұрын

    Just the right amount of detail in your videos brother : ]

  • @batlin
    @batlin2 жыл бұрын

    Recent versions of the kernel won't build the module if it's missing the MODULE_LICENSE tag. You can do that by adding it after calling the module_init/exit registration functions: MODULE_LICENSE("GPL");

  • @bilalkamran.1511

    @bilalkamran.1511

    2 жыл бұрын

    this comment should be pinned

  • @CyborgElf
    @CyborgElf5 жыл бұрын

    Nice video :) kernel is always difficult to explain, you did it perfectly

  • @kallikantzaros
    @kallikantzaros3 жыл бұрын

    Reading LPIC-1 book and got to the part with modules and this video taught me a lot of things on how this works. Thanks

  • @vtrandal
    @vtrandal Жыл бұрын

    I'm glad I found my way back here over a year later. Very cool stuff.

  • @williamdurocher207
    @williamdurocher2075 жыл бұрын

    Great video, I struggled with creating a kernel module before. Wish the video had been there then !

  • @katout75
    @katout755 жыл бұрын

    Thanks, what a great video to quickly explain how to start writing kernel modules.

  • @Skyler9604
    @Skyler96044 жыл бұрын

    Came for the meme, stayed for the knowledge

  • @yourneighbour5738
    @yourneighbour57385 жыл бұрын

    Big Chungus OS

  • @Mrdejjay
    @Mrdejjay2 жыл бұрын

    For anyone running into the module license error, insert this under the header for your .c file: MODULE_LICENSE("Dual BSD/GPL");

  • @Chris-no9tn

    @Chris-no9tn

    Жыл бұрын

    Thanks! Solved the problem for me.

  • @Karrq
    @Karrq5 жыл бұрын

    More Linux dev stuff pls! It was awesome

  • @theburntcrumpet8371
    @theburntcrumpet83715 жыл бұрын

    This was extremely informative. Thank you

  • @carlesg0n
    @carlesg0n5 жыл бұрын

    Nice video man, really interesting! Keep doing these

  • @magicrectangleEnt
    @magicrectangleEnt3 жыл бұрын

    Yo this video is amazing dude. Finally understand how these modules work! And with a choice example too 👍👍

  • @felipekenzoshiraishi3746
    @felipekenzoshiraishi37464 жыл бұрын

    Awsome introduction! Thanks a lot!

  • @marcbeatove7149
    @marcbeatove71495 жыл бұрын

    message_len should be size_t as it contains a length. Of course this shouldn't cause any problem as strlen() never returns a value lower than 0 and any further operation is done with the variable, but still, it's nice to get the beginners used to use the correct data types. Great video btw :D

  • @nischalbhandari9964
    @nischalbhandari99643 жыл бұрын

    I could not understand this thing by reading a book for four days but your video made it very clear. Thanks dude.

  • @crmafra
    @crmafra5 жыл бұрын

    Awesome! You made it look really simple, thank you!

  • @pcfreak1992
    @pcfreak19925 жыл бұрын

    I didn't know that making kernel modules was this simple. Nonetheless, I learned something new today and enjoyed it 👍

  • @N0AGI
    @N0AGI3 жыл бұрын

    Thank you for sharing this knowledge; Very helpful. I am hoping to learning kernel module programming - never had the prior opportunity to; Your video will motivate me in that direction. Thanks again. God Bless.

  • @umairgillani699
    @umairgillani6995 жыл бұрын

    just by seeing word "Linux" in title, liked the video and now watching.. more Linux videos please!

  • @treyquattro
    @treyquattro3 жыл бұрын

    good video. I anticipated you'd access the module via cat /dev/rickroll, but I expected that just registering the module would have automatically created the entry in /dev

  • @d1rtyharry378

    @d1rtyharry378

    3 жыл бұрын

    I thought the same thing. Registering shows the new device in /proc/devices. But when I do ls -l /dev it doesn't show up. My guess is the device is created but the directory entry that points to this device is not created. Mknod helps to create that directory/file which is managed by the device we created and registered

  • @adaminsanoff
    @adaminsanoff4 жыл бұрын

    Great introduction into kernel modules.

  • @pwlegolas3
    @pwlegolas34 жыл бұрын

    This is simply amazing.. Thanks Eng. Man !!!

  • @ZeeLegend
    @ZeeLegend5 жыл бұрын

    Awesome video!

  • @thomasburke7995
    @thomasburke79952 жыл бұрын

    I have been unable to comprehend what you did.. but I know what that rickroll can be used for.. brilliant..

  • @ivmaxxim100
    @ivmaxxim1002 жыл бұрын

    Really high quality video. Thanks!

  • @AmeenAltajer
    @AmeenAltajer2 жыл бұрын

    Love your work, keep these videos coming! Haha!

  • @richardbenes9
    @richardbenes93 жыл бұрын

    Great explanation, thanks! Btw. would it be a good idea to register the device at the time of loading of the module?

  • @coldhardwick
    @coldhardwick5 жыл бұрын

    Could you also use psuedo devices to create a com port to replace tty to ease serial communication from a device to program running on WINE? Very informative video, even though I'd never build that lol

  • @ericgorder1
    @ericgorder1Ай бұрын

    Thank you so much. I was able to get this working on Raspberry Pi 3 b VM under Qemu! This is so cool!

  • @ramesherrabolu1590
    @ramesherrabolu15904 жыл бұрын

    Thanks for a short and clear presentation. Do you have one on DKMS

  • @ianlang6058
    @ianlang60582 жыл бұрын

    Nicely presented video

  • @HasanAmmori
    @HasanAmmori3 жыл бұрын

    This video deserves way more views

  • @clementyves6154
    @clementyves61545 жыл бұрын

    Thanks dude ! this is again a very good lesson !

  • @r.savage1283
    @r.savage12835 жыл бұрын

    Love your content. Just subscribed. I just found atom . Any chance of an overview of it?

  • @unh0lys0da16
    @unh0lys0da163 жыл бұрын

    This is so valuable, there is way too little material on LKM's

  • @OscarCortesV
    @OscarCortesV3 жыл бұрын

    Thank you very much, this is exactly what I was looking for, clear information, I will subscribe and like... but I have a doubt, how can you know which kernel module goes to which device in /dev?

  • @inputignhere
    @inputignhere5 жыл бұрын

    very useful, ill be sure to use it in the future

  • @8v2000
    @8v20005 жыл бұрын

    Brb installing linux

  • @chHJChang
    @chHJChang10 ай бұрын

    This video helps me a lot, thx!

  • @0xssff
    @0xssff3 жыл бұрын

    Amazing content, thanks a lot!

  • @spyingpro4563
    @spyingpro45633 жыл бұрын

    I have no idea what I’m watching but I like it

  • @mattt2684
    @mattt26845 жыл бұрын

    That was epic!

  • @anupraj762
    @anupraj7625 жыл бұрын

    Thanks for sharing knowledge

  • @guyfromconcordia
    @guyfromconcordia3 жыл бұрын

    maybe you should compose a , say, main.c program, to show how to call the character-device through syscall, like read, write, and then to demonstrate the relationship between kernel module and user space process.

  • @Ncky
    @Ncky5 жыл бұрын

    How to make it to write only once and then close it self? Call dev_release inside dev_read?

  • @paulstelian97

    @paulstelian97

    4 жыл бұрын

    You can't normally close the file, but you can use the *offset field to ensure it looks like a normal file. Closing should be handled by the kernel based on the system call itself. Take a look into the source code of the close() system call to see what exactly it does if you do want to close the file yourself.

  • @zinsy23
    @zinsy235 жыл бұрын

    Did you paste multiple things sequentially one at a time? It didn't look like the video was cut at 3:08 and 3:14 when I noticed this. If so, how do you do this in Linux? I've done this before with Autohotkey in Windows by writing to a text file and pasting one line at a time. I'm curious to see how you did this in Linux if you did.

  • @RonnyMandal75
    @RonnyMandal753 жыл бұрын

    Great! Instead of "Sorry, rickroll is real only" it should say "You know the rules and so do I!"

  • @alecthenice8115
    @alecthenice81155 жыл бұрын

    Thx for helping me with custom boot.img creation

  • @JosephDAndrea0121
    @JosephDAndrea01214 жыл бұрын

    Studying for linux+ I keep a running notebook in evernote. I linked to this video as an example of creating and managing modules. I'm going to provide my notebook stack internally for the other guys who want to study for the linux+ exam. Though you might like to know that future generations of linux admins learned kernel modules by rickrolling their buddies

  • @BroscutaGaming
    @BroscutaGaming5 жыл бұрын

    Hey man! What font are you using on the terminal?

  • @paulwirkus4182
    @paulwirkus41824 жыл бұрын

    That video is kinda wholesome.

  • @perpirisgg
    @perpirisgg5 жыл бұрын

    We need engineer man cap merch

  • @EngineerMan

    @EngineerMan

    5 жыл бұрын

    Here you go :)www.amazon.com/Falari-Classic-Baseball-Cotton-Adjustable/dp/B010RDCIM2/ref=sr_1_2

  • @adameverett3414
    @adameverett34145 жыл бұрын

    Hey, great vid. Could you please make a tutorial of running an ssh server on Linux?

  • @MrArondc

    @MrArondc

    5 жыл бұрын

    what distro are you running?

  • @patrickmullen2914
    @patrickmullen2914 Жыл бұрын

    Great video

  • @MinhPhamGators
    @MinhPhamGators4 жыл бұрын

    "...🎶 never gonna let you down...🎶 ... never gonna panick ...🎶 unless you create a buffer overflow...🎶"

  • @kevinalexander4959
    @kevinalexander49594 жыл бұрын

    Would love to see you do the same project on an un-rooted Android device running newer OS. I was having error: "insmod: failed to load test.ko: Exec format error", loaded just fine on Ubuntu -- I'm guessing this example is not for Android.

  • @skunchtv
    @skunchtv5 жыл бұрын

    awesome stuff

  • @yoyonel1808
    @yoyonel18085 жыл бұрын

    Thx for the video. Your link to github repo not pointed to the correct subdirectory (subproject).

  • @EngineerMan

    @EngineerMan

    5 жыл бұрын

    Thanks for pointing that out. I just corrected it.

  • @yoyonel1808

    @yoyonel1808

    5 жыл бұрын

    @@EngineerMan You're welcome :)

  • @chrissmith6028
    @chrissmith60282 ай бұрын

    I had just learned that the '&&' only executes cmd2 IF cmd1 succeeds. So I have been doing "make clean && make". Is there a problem with that ? My thought would be that it is going to make sure dir is cleaned before running "make". p.s. Trying to follow the video leaves out the '"%d", major ' so I was having a lot of problems until I viewed the repo.

  • @pauloseifer7324
    @pauloseifer73245 жыл бұрын

    Nice video! Tks!

  • @GlennHamblin
    @GlennHamblin5 жыл бұрын

    Very cool. Thanks.

  • @CurrentlyObsessively
    @CurrentlyObsessively4 жыл бұрын

    Well. Linus always says don't break userspace. Your rickroll can be exited with Ctrl - C, so you're good.

  • @lyghters
    @lyghters4 жыл бұрын

    Dude, i can't get over of how you look exactly like one of Half-Life 2 civilian/resistance NPCs. And.. take that as a compliment, i guess

  • @joegatton4138

    @joegatton4138

    4 жыл бұрын

    Lol, now I'm going to be reminded of this for every video.

  • @FaizKhan-fm6kg
    @FaizKhan-fm6kg5 жыл бұрын

    whats your github handle? And do you have the source code of your videos on github?

  • @faozi1000
    @faozi10002 жыл бұрын

    Hi Engineers! I have a doubt if anyone could help me... I am trying to get to know how LKM's Work. I Successfully completed an installation with the insmod command, but when I reboot i do not find my module loaded. ( tried to add the name of the module installed into /etc/modules and got an error while loading the raspberry where it is installed . Any hint ? Best regards to everybody!

  • @ramsaiachanta5553
    @ramsaiachanta5553 Жыл бұрын

    bro how to rectify the error if the compiler differs from the one used in the kernal,since my program is not working as like you plz someone explain how to get out of this my compiler showing gcc 11.3 and kernal showing gcc 11.2

  • @Erandros
    @Erandros4 жыл бұрын

    very good intro haha

  • @cantanzim6215
    @cantanzim62153 жыл бұрын

    grate video really.... grate informations... amazing thanks

  • @AtomkeySinclair
    @AtomkeySinclair5 жыл бұрын

    Mad scientist laugh...

  • @rainfallen1064
    @rainfallen10642 жыл бұрын

    Strange, how come when I run "cat rickroll", it doesn't trigger the "dev_open" method UNTIL I hit control-c. Any idea?

  • @dxshindeo
    @dxshindeo4 жыл бұрын

    That was really cool :D

  • @rm-rf4612
    @rm-rf46125 жыл бұрын

    cool vid

  • @MebiusProject
    @MebiusProject4 жыл бұрын

    Hey Engineer Man, do you have any info on how to install the module from kernel 5.4 ? 'insmod' return 'Operation not permitted', apparently due to the new lockdown feature...

  • @SheIITear

    @SheIITear

    4 жыл бұрын

    Use sudo. Works fine on 5.6.

  • @echoptic775
    @echoptic7752 жыл бұрын

    Im having a problem im missing linux/init.h file but have all others

  • @engiecat705
    @engiecat7055 жыл бұрын

    couldn't you make that module handle the /dev link automatically?

  • @rohitnarwal8284
    @rohitnarwal82845 жыл бұрын

    you are awesome❤

  • @utsavtayde3378
    @utsavtayde33783 жыл бұрын

    Can this code be treated as a code for s device driver in linux? and is this code works in ubuntu? coz I am facing issues here in my ubuntu system

  • @jonathanengwall2777
    @jonathanengwall27774 жыл бұрын

    Good one

  • @rolandsz8831
    @rolandsz88314 жыл бұрын

    I suspect that this code can overflow the userspace buffer, in case len < message_len. Do I miss something here?

  • @tissuepaper9962

    @tissuepaper9962

    3 жыл бұрын

    I don't actually know, but I suspect that the function used to copy into the userspace buffer checks for this and would reflect such an error in its return value

  • @santoshjackman
    @santoshjackman5 жыл бұрын

    Do you age..?

  • @PauxloE
    @PauxloE4 жыл бұрын

    9:08 Shouldn't you only copy min(len, message_len) characters? Otherwise you might write over the bounds of the buffer. 10:35 I guess it's more effective if the device is not named "rickroll". And can you do the equivalent of this mknod call also from your init function, so it stays over restarts of the system?

  • @igorswies5913

    @igorswies5913

    3 жыл бұрын

    name it urandom

  • @danielderwertvolle6354
    @danielderwertvolle63545 жыл бұрын

    Great video! Maybe somebody can help me with this: For some reason I'm missing init.h... I did "apt-get install build-essential linux-source linux-headers-`uname -r`" but init.h is not where it's supposed to be. "locate" doesn't find it at all actually. maybe I'm missing something obvious but those are the packages everybody tells me i need...

  • @AryaFairywren

    @AryaFairywren

    5 жыл бұрын

    you can use apt-file to find a package containing a file you're after. Install apt-file, then try apt-file search init.h

  • @JeffSmith-vc9ii
    @JeffSmith-vc9ii5 жыл бұрын

    Does this work on Windows 10 Linux subsystem with Wine? I use Arch btw.

  • @vladimirtatarsky9928

    @vladimirtatarsky9928

    5 жыл бұрын

    What you are referring to as Linux, is in fact, GNU/‘Windows Subsystem for Linux’, or as I've recently taken to calling it, GNU plus Windows. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system.

  • @AshesOfEther

    @AshesOfEther

    5 жыл бұрын

    No. The Windows Subsystem for Linux doesn't use the Linux kernel, but rather it converts kernel calls to Win32 calls.

  • @AshesOfEther

    @AshesOfEther

    5 жыл бұрын

    Lorem Ipsum If you read my comment properly, I said “the Linux kernel”, indicating that I’m talking about Linux itself, not GNU/Linux.

  • @AshesOfEther

    @AshesOfEther

    5 жыл бұрын

    Lorem Ipsum Did you even read my reply?

  • @RandyFortier

    @RandyFortier

    5 жыл бұрын

    @@MantasXVIII I read your reply, and @Tobias SN is correct. He was talking about two things: Windows Subsystem for Linux - the official name Microsoft/Ubuntu use for this component of Windows, and Linux - the kernel, specifically (not the operating system frequently called "Linux" incorrectly, as you have pointed out) Neither correction you made was appropriate, in this case. People do make that mistake, but that isn't what happened here. Then, you just copied and pasted the same reply again, making it clear you didn't real his reply (or, at least not carefully enough). In fact, I'm not even certain you aren't a bot. I guess we'll find out if you reply.

  • @MrEklipze
    @MrEklipze2 жыл бұрын

    I think some code is missing, the code in the tutorial does not print the major number shown at min 9:59

  • @BrianClem
    @BrianClem5 жыл бұрын

    Awesome! because.... Linux

  • @ZacKoch
    @ZacKoch5 жыл бұрын

    Haha, I dig it!

  • @michaelt126
    @michaelt1262 жыл бұрын

    this is what computers were created to do

  • @user-he4dh1ig4i
    @user-he4dh1ig4i5 жыл бұрын

    Thanks for the quality content !!! Can you make a video on removing rootkits using rootkit hunter and how to remove the false positive warnings

  • @manishbhardwaj7162
    @manishbhardwaj71625 жыл бұрын

    which Desktop Environment do you use ?

  • @hyper4306

    @hyper4306

    5 жыл бұрын

    He uses CDE

  • @franchufranchu119
    @franchufranchu1193 жыл бұрын

    You could make it stream the video, so that you can play it with mplayer or other similar app

Келесі