How to build a Linux loadable kernel module that Rickrolls people
HTML-код
- Опубликовано: 19 янв 2019
- 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 - Наука
As a retired software engineer, starting with IBM 370 systems, I find your videos to be remarkably interesting and educational. Very much appreciated.
Awesome introduction to kernel module development! Show me more! 😁
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/
Linux drivers are pretty easy to compile and write as long as you have a basic understanding of what your doing
1:43 "Kernel Space Program" my favorite video game... Oh wait, it's Kerbal Space Program? Crap
That would be interesting, the system crashing along with your ship.
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!!
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.
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!
Me yesterday: researching kernel module & device file.
Me today: Listening to rickroll in medieval style.
RUclips algorithm today:
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");
this comment should be pinned
Just the right amount of detail in your videos brother : ]
Nice video :) kernel is always difficult to explain, you did it perfectly
You can make a virus, that opens Never Gonna Give You Up, as soon as browser is closed.
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
Great video, I struggled with creating a kernel module before. Wish the video had been there then !
Thanks, what a great video to quickly explain how to start writing kernel modules.
This was extremely informative. Thank you
I'm glad I found my way back here over a year later. Very cool stuff.
just by seeing word "Linux" in title, liked the video and now watching.. more Linux videos please!
Came for the meme, stayed for the knowledge
Big Chungus OS
Yo this video is amazing dude. Finally understand how these modules work! And with a choice example too 👍👍
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.
For anyone running into the module license error, insert this under the header for your .c file:
MODULE_LICENSE("Dual BSD/GPL");
Thanks! Solved the problem for me.
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
More Linux dev stuff pls! It was awesome
Awsome introduction! Thanks a lot!
Awesome! You made it look really simple, thank you!
I have been unable to comprehend what you did.. but I know what that rickroll can be used for.. brilliant..
I didn't know that making kernel modules was this simple. Nonetheless, I learned something new today and enjoyed it 👍
Nice video man, really interesting! Keep doing these
Great explanation, thanks! Btw. would it be a good idea to register the device at the time of loading of the module?
Great introduction into kernel modules.
I could not understand this thing by reading a book for four days but your video made it very clear. Thanks dude.
This is simply amazing.. Thanks Eng. Man !!!
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
Thanks for the quality content !!!
Can you make a video on removing rootkits using rootkit hunter and how to remove the false positive warnings
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
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
This video helps me a lot, thx!
Thanks for sharing knowledge
Brb installing linux
Love your content. Just subscribed. I just found atom . Any chance of an overview of it?
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?
Thanks for a short and clear presentation. Do you have one on DKMS
Awesome video!
Thx for helping me with custom boot.img creation
Love your work, keep these videos coming! Haha!
Really high quality video. Thanks!
Nicely presented video
very useful, ill be sure to use it in the future
Amazing content, thanks a lot!
This video deserves way more views
This is so valuable, there is way too little material on LKM's
Thanks dude ! this is again a very good lesson !
That was epic!
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.
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.
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
Hey man! What font are you using on the terminal?
"...🎶 never gonna let you down...🎶 ... never gonna panick ...🎶 unless you create a buffer overflow...🎶"
I have no idea what I’m watching but I like it
grate video really.... grate informations... amazing thanks
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.
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
Thx for the video.
Your link to github repo not pointed to the correct subdirectory (subproject).
Thanks for pointing that out. I just corrected it.
@@EngineerMan You're welcome :)
That video is kinda wholesome.
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!
Great! Instead of "Sorry, rickroll is real only" it should say "You know the rules and so do I!"
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
Very cool. Thanks.
Mad scientist laugh...
How to make it to write only once and then close it self? Call dev_release inside dev_read?
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.
Hey, great vid. Could you please make a tutorial of running an ssh server on Linux?
what distro are you running?
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.
awesome stuff
you are awesome❤
We need engineer man cap merch
Here you go :)www.amazon.com/Falari-Classic-Baseball-Cotton-Adjustable/dp/B010RDCIM2/ref=sr_1_2
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...
Use sudo. Works fine on 5.6.
Im having a problem im missing linux/init.h file but have all others
Awesome!
because.... Linux
Good one
Well. Linus always says don't break userspace. Your rickroll can be exited with Ctrl - C, so you're good.
7:44 Copy in it is shamocha
Great video
Nice video! Tks!
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
Lol, now I'm going to be reminded of this for every video.
I think some code is missing, the code in the tutorial does not print the major number shown at min 9:59
Anyone got this error when compiling the makefile:
ERROR: modpost: missing MODULE_LICENSE()
Does this work on Windows 10 Linux subsystem with Wine?
I use Arch btw.
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.
No. The Windows Subsystem for Linux doesn't use the Linux kernel, but rather it converts kernel calls to Win32 calls.
Lorem Ipsum If you read my comment properly, I said “the Linux kernel”, indicating that I’m talking about Linux itself, not GNU/Linux.
Lorem Ipsum Did you even read my reply?
@@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.
Everyone commenting this video is a boss...almost Everything he says are going over my head..cant understand anything as a noob
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...
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
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?
name it urandom
Fun!
KERN_LOG undeclared
Do you age..?
You could make it stream the video, so that you can play it with mplayer or other similar app
awesome
I suspect that this code can overflow the userspace buffer, in case len < message_len. Do I miss something here?
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
Haha, I dig it!
Awesome
register_chrdev is an outdated function in Linux kernel module programming.
very good intro haha
discord squad!
Yeet