 Ya, link seluruh ini di sini jika anda mahu menggunakan Mungkin saya akan tulis ke bawah Okey, jadi ini berhasil? Ya, ini berhasil Okey, jadi hari ini kita akan bercakap tentang Sebenarnya, dan perjumpaan dengan Linux Dan kemudian, bagaimana Tengoknya tidak sangat teknikal Kita tidak akan bercakap tentang bagaimana Linux berhasil Oleh itu, bagaimana perjumpaan Linux berhasil Dan bagaimana anda Dan juga beberapa idea tentang jika anda bekerja di Linux Bagaimana anda mengembangkan perjumpaan dan sebagainya Jadi, beberapa perkara yang saya menemukan Untuk bekerja dengannya, hanya sedikit Saya tidak sangat bekerja dengannya Tetapi, hanya sedikit Jadi, dan kemudian saya akan mempunyai sebuah demo pada akhir Bagaimana dengan idea perubahan Dan kemudian, kita akan menghubungi sebuah patch yang anda dapat menghubungi Jadi, mari kita pergi Jadi, pertama, Linux mempunyai sebuah cerita Jadi, Linux mempunyai Saya rasa, Linux tersebut Linux tersebut bermula bekerja di Seperti April 1991 Dan dia tersebut bermula bekerja di Uni Helsinki Seperti kita, saya rasa Ya, jadi, saya rasa ada beberapa perkara yang dia bekerja Tetapi, sebenarnya, Saya rasa salah satu perkara yang penting adalah Dia tidak suka sesuatu tentang Linux Linux adalah sebuah keranel yang ditulis Untuk sebuah tanda-tanda Andrew Saya percaya Linux tidak suka Jadi, saya rasa dia inginkan projek hobi dan sebagainya Jadi, dia bekerja di keranel Linux Dan kemudian, di August 1991 Dia menghubungi e-mails Yang masih berada di Google Group Archive Jika anda mempunyai sisi, anda boleh mencari foto Biar saya mencari Saya rasa anda perlu menghubungi ke Google Jangan lupa Jadi, ya Dia berkata, oh, dia menghubungi ini kepada group Minix Dia berkata, oh, saya melakukan sistem operasi Bukannya tidak akan menjadi besar dan profesional Ya Lihat cara dia sekarang Ya, dan kemudian Jadi, itu adalah mulai Linux Dan Jadi, di August 1991, dia pertama menghubungi e-mails Pada december 1991, keranel itu menjadi menghubungi Jadi, apa ini bermakna? Keranel itu boleh menghubungi dan menghubungi Kemudian, pada december 1992 Tanenbaum berkata, oh, Linux adalah obsolete Jadi, Tanenbaum berkata Keranel monolithik yang akan saya bercakap dengan dengan cepat Keranel monolithik dan kita semua harus menggunakan keranel micro Keranel Minix adalah micro Dan saya bermaksud Saya tidak rasa keranel monolithik adalah obsolete Meskipun kita mempunyai Google dengan fuzer dan zekon Jadi, kita akan lihat apa yang berlaku Pada december 1992, Linux menghubungi keranel dari perang Keranel sendiri yang menghubungi beberapa perkara komersial Untuk GPU2 Saya rasa dia berkata, ini adalah keputusan yang terbaik untuk keranel Ya, saya rasa saya tidak percaya Tapi itu adalah satu-satunya bercakap dengan keranel Pada december 1994, mereka mencapai 1.0 Meskipun keranel berkata, keranel berkata, ini seperti biasa Jadi, pada awal, ia seperti 1.0, 1.1, 1.2 Dan kemudian, anda mempunyai berkata-kata Jadi, jika ada kata-kata yang berkata-kata, ia akan menjadi 1.0.1 1.1, 1.2, dan sebagainya Dan ini berlaku sehingga Kemudian, dua tahun lepas itu, mereka menghubungi 2.0 Jadi, ia menjadi semi-arbiturasi juga Sebenarnya, keranel berkata-kata keranel berkata-kata Pada december 2003, mereka menghubungi... Jadi, ada banyak menghubungi di antara Tetapi, 2.6 itu merupakan keranel Keranel berkata-kata keranel berkata-kata keranel berkata-kata Keranel berkata-kata keranel berkata-kata Oh, keranel berkata-kata sangat stabil sekarang Kita hanya berhenti pada 2.6, dan kemudian kita menghubungi 2.6.1 1.0 Selepas itu, mereka menghubungi 2.6.30.0 Kemudian, dan Linus berkata, Kita akan berubah lagi Jadi, pada Juli 2011, mereka mengubungi kemari yang baru, yang adalah... Apa ini sekarang? Sebenarnya, ia hanya... 3.0, dia hanya kata, Yang lain akan menjadi 3.0 Dan setiap sebulan, mereka mengubungi Yang lain akan menjadi 3.1, 3.2 Sehingga 3.20 Yang adalah apabila Linus berkata-kata, Saya tidak dapat menghubungi Dan kemudian, kita mengubungi 4.0 Dan kemudian, kemudian Saya rasa, pada bulan Desember, bulan Desember 18, kita mengubungi 4.20 Dan Linus berkata-kata, Okey, kemudian, mereka mengubungi lagi Jadi, kita akan mengubungi 5.0 Dan pada bulan 19 bulan terakhir Kita mengubungi 5.0 Jadi, itu yang keranel berkata-kata sekarang Yang keranel berkata-kata, ia cukup berkata-kata Saya rasa, ia harus menjadi sesuatu yang sama Seperti bagaimanapun, bagaimana Krom dan Firefox berkata-kata mereka berkata-kata Sebab setiap perjalanan, ia hanya plus 1 Sebab itu, ia hanya Linus berkata-kata berkata-kata pada awal, sebabnya Saya tidak tahu Okey, dan... Jadi, semasa saya mencari Untuk pembentangan ini, saya sebenarnya mencari Saya sebenarnya mencari Okey, saya tidak mencari saya pada IPA Sebab saya tidak memahami Tapi, saya rasa ini adalah IPA yang berkata-kata Tapi ini adalah pembentangan Linus sendiri berkata-kata Helo, ini Linus Dua pembentangan dan saya nama Linus Jadi, ini Linus Saya tidak tahu Tapi, bagaimanapun, semua orang hanya melihat Linus, bukan? Jadi... Saya tidak... Saya tidak... Saya tidak tahu Okey Ya Tapi ini... Ia seperti di linux Saya buat lagi Ia di linux CDN Jadi, ia benar-benar Jadi, apa itu linux? Linux adalah kernel monolithic Jadi, apa kernel? Jadi, okey Jika anda tidak tahu Kernel adalah apa yang berlainan antara program anda Bukankah anda menulis program yang berkata Print Hello World Jadi, apa yang berlainan daripada print tersebut sehingga print tersebut berlainan Ada banyak perkara yang berlainan Tetapi, salah satu perkara itu adalah kernel Okey, mari kita lihat yang berlainan dalam C Jadi, anda akan berkata sesuatu seperti Print F Hello World Print F adalah fungsi dalam library C standard Dan jika anda mempunyai linux Linux Jika anda mempunyai linux Anda mungkin akan menggunakan library GNU C yang adalah G-Lip C Jadi, G-Lip C akan mempunyai Akhirnya ia akan berakhir dalam panggilan yang baik Jadi, panggilan yang baik adalah panggilan yang baik adalah program yang berlainan dalam panggilan yang berlainan yang berlainan dengan kernel Jadi, apa panggilan yang berlainan? Panggilan panggilan itu adalah jika anda bercakap tentang x86 kemudian anda mempunyai koncept ring Jadi, apabila anda mempunyai panggilan panggilan anda akan mempunyai kernel kontrol yang anda lakukan dan kemudian anda mempunyai panggilan yang berlainan saya menghubungi detail tetapi anda mempunyai panggilan yang berlainan dalam panggilan kernel pada masa latihan, ia berlainan dengan panggilan datang hari ini anda tidak mempunyai panggilan yang berlainan karena anda tidak mempunyai panggilan untuk pengaruh ia disebabkan jika program anda berlainan dan sepanjang warna, jika anda mempunyai panggilan kernel anda dapat mempunyai panggilan yang berlainan juga mempunyai panggilan yang berlainan antara panggilan awak dan hardware dan kebanyakan-kebanyakan tersebut adalah perangkat perangkat perangkat jadi mereka membantu mempunyai semua perangkat yang berlainan ke perangkat perangkat yang berlainan yang anda boleh menggunakan seperti pangkat CISKAL dan sebagainya dan kemudian kebanyakan yang lain juga seperti perangkat perangkat jadi anda mempunyai perangkat yang berlainan dengan sistemnya dan perangkat akan mengandalkan CPU dan mengandalkan setiap program untuk mengandalkan dan juga mengandalkan mempunyai jadi mengandalkan unit mempunyai mempunyai mempunyai untuk mengandalkan program anda hanya boleh mempunyai untuk di sini dan di sini anda tidak boleh mempunyai dari situ. Jika anda mempunyai dari situ, saya akan membunuh anda itu adalah yang saya buat. Itu adalah yang saya cakap apabila program anda cuba mencari atau mempunyai dari mana yang diperlukan jadi apa yang penting antara monolithik dan microkernel apabila anda mempunyai kernel monolithik sebuah kernel proses anda dan kernel mempunyai perkaraan asli akan selalu di kernel tetapi dalam kernel monolithik yang berlainan dengan kerajaan anda itu juga di kernel apabila anda mempunyai kernel microkernel sebagainya, terutama perkaraan ini kernelan anda di kernel penggunaan dan mereka mempercaya kernel penggunaan jadi ada bahan-bahan terhadap kernel microkernel dan kernel monolithik tapi sayaEMUM mungkin tidak akan mendapat diri E C ikan ber Penal Penal jealous pemalaman MacOS dan MacOS sangat bergantung. Sebenarnya... Bukan MacOS dan MacOS? MacOS dan MacOS. Okey, jadi... Sebab itulah saya meletakkan banyak detil di sini. Tetapi untuk Windows, saya masih berkata bahawa ia lebih bergantung dengan MacroKernel. Ia berada di antara. Tetapi saya rasa ia lebih bergantung dengan MacroKernel. Ia lebih bergantung. Ia bergantung. Okey. Okey. Kita akan mengambil kemudian. Sebab itu bukan hal ini. Sehingga kita akan bercakap tentang bagaimana perangkat Linux terdapat. Okey, bagaimana perangkat Linux terdapat? Okey. Jadi hanya sebuah perjumpaan. Jadi hari ini... Hari ini... banyak orang berkongsi per tahun. Baiklah. Kita mempunyai sekitar 1,000 perjumpaan semasa perjumpaan Windows. Ia berkongsi perangkat Linux terdapat. Jadi... 1.7,000 orang berkongsi ke versi 5. Dan kita mempunyai lebih daripada 12,500 komit yang tidak berkongsi di 5.0. Komit yang berkongsi adalah komit yang berkongsi apabila anda mempunyai komit yang berkongsi. Kita bercakap tentang komit yang tidak berkongsi bermaksud komit yang sebenarnya berubah. Jadi 12.5,000. Jadi bagaimana dalam dunia anda mempunyai banyak komit yang berkongsi? Baiklah. Dan... anda akan mempunyai github? Atau github? Sebenarnya, kebanyakan perangkat saya berkongsi pada perangkat yang berkongsi atau berkongsi yang berkongsi. Jadi... orang yang berkongsi yang berkongsi pada perangkat layak dia... dia berkongsi mengapa github tidak boleh berkongsi perangkat. Tapi... untuk saya, masalah yang penting adalah github tidak boleh berkongsi. Kerana... cara perangkat berkongsi perangkat berkongsi dalam sebuah cara. Semuanya dibina bersama. Lenox. Jadi... anda tidak boleh berkongsi perangkat menjadi perangkat berkongsi. Baiklah. Anda berkongsi. Tapi ia tidak akan berkongsi dengan baik. Baiklah. Ia tidak akan sangat berkongsi. Kerana ia perlu dibina bersama. Jadi bagaimana anda berkongsi menjadi perangkat berkongsi? Anda berkongsi dengan perangkat perangkat perangkat perangkat perangkat. Tapi perkara itu, perangkat berkongsi di antara perangkat. Apakah anda... Bersama anda memandu perangkat perangkat perangkat? Bagaimana anda... segalanya yang mempunyai perangkat perangkat telah memandu? Dan di Lenox, itu sangat mudah kerana orang yang memandu perangkat untuk perangkat perangkat akan memandu setiap perangkat. Kerana anda dapat memandu. Kerana semua adalah satu-tiga. Jadi anda dapat memandu. Tapi jika anda tidak memandu, bagaimana anda memandu? Jika anda memandu perangkat perangkat dan anda akan berkumpul menjadi beberapa repos. Dan perkara yang lain adalah, jika anda mempunyai GitHub atau GitLab, atau apa-apa saja servis yang digunakan, jika GitHub sudah ke bawah, dan jika semua komentar yang anda mempunyai, semua metadata, bukan hanya kode, kerana GitHub sudah kecil, jadi anda mempunyai semua. Tapi jika GitHub sudah ke bawah, bagaimana anda mempunyai komentar yang anda mempunyai? Semuanya akan beam lepatient. Sebab itulah pergadiran kernel adalah email halu. Kita akan berbual nanti. Berapa ker SGER melakukannya? Dulu ibu patut sainkan emb creep harakin kamu yang kad� weakness. hal apa yang ibu minta inspire komentare adalah pembadan yang akan menyembahaja zuman nama-tama yang anda meng lasting api. Jadi ada listan maintainers yang di dalam Linux 3 Dan kemudian listan maintainer untuk setiap individual directory atau file dan sebagainya Jadi apabila anda membuat pakaian, anda akan email ke sesiapa-siapa yang ditanggung di sini dan sebuah sub-system maintainer dan sebagainya dan e-mail listan untuk sub-system dan sebagainya Dan sebagainya, e-mail yang paling penting adalah orang yang menjaga file Jadi anda email seorang yang akan membuat pakaian dan berikan komen dan sebagainya Dan sebagainya, sebagainya, sebagainya dan sebagainya, sebagainya Dan kemudian, apabila pakaian akan diperbaiki, kemudian, sekarang pakaian yang dianggung akan menggunakan pakaian yang anda berikan dari e-mail Dan dia akan menggantikan perubahan ke file dan dia akan menghubungkan pakaian ke sebagainya, ke pakaian yang telah diambil atau sebagainya, ia adalah pakaian yang mencari dan pakaian itu akan membuat pakaian dan sebagainya dan kemudian, kemudian, anda akan menggunakan pakaian yang telah dianggung ke pakaian dan sebagainya dan kemudian, perubahan akan membuat pakaian untuk Linux Starboard So basically the stable or what we call the mainline kernel is basically Linus' tree. So if you're using a distro kernel, it won't be exactly the mainline kernel. It'll be probably some patches applied on top and so on. But what we call the mainline Linux is Linus' tree. So let's follow a patch. So this is just a random patch that I picked. It's nothing. I didn't pick it for any reason. No, I didn't want to pick the one that I worked on. Although you can find it. Because the Linux kernel requires you to contribute under your real name. Although you could come up with a fake real name but I didn't. So this is just a random patch. You can see it was written February and then it got committed in April. So let's look at the initial email. So this guy emails with the patch. We're subjecting patch and this is the commit title. This is the commit message and so on. We won't go into the patch details but basically this guy is the maintainer for that file and he gives the guy some comments. So he gives the guy some comments and then the guy responds with version 3. The guy responds with a new version of the patch and he has fixed the problems. So now the maintainer says thank you. So that means he has pulled it into his tree and so we can actually go and look at it. So he accepted it. So we can actually go and look at this guy's name is Jaco's tree. So his tree will be here and you can actually go and look at it and if you look at the short log there's a lot of changes but actually no, it will be in February. No, that's him but it's not that change. Okay, there's actually a lot of changes. I should have found this earlier. So basically Jaco will pull it into his tree which is located in this location and then... I'm sure. Thanks. Okay, so let's look at the... Okay, so I'm not going to copy the commit hash because you can't actually use that. Because when you pull it in then Jaco will have at his cometer information and so the commit hash changes. Okay, let me get the... Let me get the commit title which is this. Ya, the... It will take a while. I'm not even doing... I didn't even enable RE. We'll just continue and then when it's done we'll take a look at it. Okay, so... after Jaco accepted it then about one month later one month later Jaco sends a pull request to the maintainer of that the TPM subsystem. So hi James, these are fixes for 5.1 Okay, so this line onwards is basically what Git generates when you send an email pull request. The following changes since this commit are available in... Git with timeout, nice. Let's not look at it then. But ya, so... Jaco now sends a pull request to his next maintainer. And so you can see that that includes this change Right. And now the maintainer few weeks later, maintainer sends a pull request to TorVolts. So... 2 TorVolts. Please pull this TPM fixes. And... TorVolts doesn't reply because he has a bot to reply for him. Ya. And ya, if you go and look at it then you can see that the commit actually went into TorVolts 3 lah. Ya, so that's basically the lifecycle of a patch in Linux. Right. So, how would this compare to GitHub? I actually cannot imagine how Linux will work on GitHub because there are projects that are pretty large on GitHub. But personally I've dealt with Rust community. Rust, I would say, is large-ish and they are on GitHub. But I think the difference is that Rust is like... what they have is compiler. Tenner library. So, that sort of can go into one repository. And they have a lot of other smaller libraries that are separate. And those can work separately. They don't have to be part of the single monorepo that is Rust. So, it works fine. But the problem with Linux is that everything is sort of depends on each other. And it's very hard to actually separate things out. So, there's sort of... like if you look at Windows, drivers, there's a sort of driver API. And so, in Windows you have... the people who write the drivers are actually the device manufacturers generally. And then they just write the drivers themselves and they ship it to you directly. Or, okay, they can use Microsoft. But Microsoft doesn't maintain a source repository with all the drivers. In contrast, Linux does let you compile out of three drivers. That's what we call it. But we generally prefer that drivers are main-lined, what we call it. So, they're included into the main tree. Why is because that... So, if you have driver main-line, then well, one thing is everyone can work on it together. And if there are any changes to kernel APIs, you are not responsible for fixing it. The person who changes the API will fix it for you. Right? That's great. So, someone said once... I can't remember where. I think it was Greg K.H. So, Greg is the person who maintains stable kernels. He said that in an email that is again that explains why Linux doesn't have a stable driver API. He said that Linux kernels... Linux drivers are generally about up to one-third the size of the drivers of Windows because they don't have to maintain code and they work with different versions of the kernel and so on. The driver that ships with this kernel works with this kernel and any obsolete code you can just throw it out because the driver is in the tree so it's part of the whole kernel. And I think that's pretty nice. There are people who prefer having a stable driver API but Linux explicitly says that the internal APIs are not stable but it works. And there are benefits to it. So, personally I'm in favour of this but there are always arguments and people who come in and say why don't we have a stable API and so on. Okay, so we talked about the Linux release cycle. So basically what happens this is what happens now so in the past it probably was different but what happens now is basically so this is just let's say we have 5.0 release, right? Okay, let's say we have 5.0 release so the moment 5.0 is released the merge window for the next release starts so it usually lasts about 1-2 weeks so in this merge window the subsystem maintainers will send their pull request to Linux and they will accept all the pull request Linux will accept whatever changes new features major changes that could break things and so on all go into the kernel during this merge window so it lasts about 1-2 weeks and as when Linux thinks it's appropriate it release RC1 and when the more RC1 is released the merge window is closed, right? and from RC1 until usually depending on the you know the changes that go in there's about 6-9 RCs, release candidates and so basically people test the kernel test the new changes and fix things so anything that goes in at this point which just fixes or potentially things that cannot break the rest of the kernel and when Linux thinks it's about the right time but basically when the patches that are going in start to dwindle down then he will release the next version so usually cycle lasts about 3 months but it's really up to Linux and once the version is released so we have let's say the next version will be 5.1 so I think now we have 5.1 RC3 so when the next version is released then Greg Cage will take over that version and he will start producing the stable patch level so 5.1.1 and so on so that's how the release cycle works basically and that's how basically so the moment from when you submit a patch to your the maintainer to the moment where it appears and is released in a stable kernel could probably will probably be at least 3 months because depending on your patch it could be if your patch is a fix for a serious bug it will definitely go in immediately but if your patch is like a new feature something not that urgent it will probably take 3 months because it will have to wait for the next merge window and then all the way until that release is released so yeah so what does Linux use to handle all this email mailing list so can go and see so Linux has many many many mailing lists it's basically one mailing list per subsystem or architecture and so when you submit a patch you will submit to that mailing list and there's also one mailing list called Linux Kernel which is basically the mega mega mailing list and everything goes there but yeah and they use Git which was written for Linux so there's a lot of Linux specific things in Git like for example who actually uses Git send email right Linux developers do I'm not sure I don't think so it's in kernel docs it's been there for quite a while like Git send-email you can like so basically what Git send email does is you will just you give it your SMTP credentials and you will just do the sending for you yeah and there are people who don't like Git because it has a terrible UI so they use Mercurial and apparently it works I personally haven't tried it because I think Mercurial is very slow and there are also a few tools like Patchwork and Bugzilla so Patchwork is this website where that tracks the patches that are emailed into the Linux world but it's basically a nicer UI to look at patches instead of looking at the mailing list archives there's also Bugzilla and so the funny thing is that Bugzilla exists and so people like users of the kernel will actually report bugs into Bugzilla but developers don't look at Bugzilla they look at the mailing list so Bugzilla has been described so of as Blackhole or Deaf Null of bugs because a lot of things are there but developers generally don't look at it only a few people do the people commenting there are generally all users it's quite unfortunate so if you ever encounter a bug in a Linux kernel actually the best place you can report it to Bugzilla but also email the mailing list because the mailing list is just for patches it's also for discussion and things about that subsystem okay so submitting kernel patches so this links to basically the kernel's own documentation so which I definitely I'm not going to replicate that here I'm just going to go through the overall process and a very simple process which works but there are a lot of details that may be worth knowing so you should read the documentation if you do want to contribute to Linux kernel okay so the first thing you need to do is of course have a commit so basically before this you will have clone the Linux tree do your changes fixers whatever and you commit your changes and so one thing to take note is when you commit so Linux uses this thing called the developer certificate of origin yeah so they want you to have this line at the end so if you look at the Linux tree every commit has this line saying signed off by your name your email and basically by adding that line you certify that all this stuff it's just the next things right and the other thing about Linux is that the commit message you you you you you you is that the commit messages are very very very detailed which personally I am a fan of so when for my own projects I also enforce some sort of commit message discipline but a lot of people don't and I get very get very irritated when I see commit messages they are just totally trash because okay let's look at the commit message okay this is the commit title the commit title is the first line and you can already see there is some sort of discipline that goes on here basically they talk about the they describe the subsystem they say like which subsystem it is or whatever and then like the change the change will always it will always be an imperative statement so open this in a method mode or extend the test or fix something or change this or change that and this is just the first line so every commit will have a very long explanation behind it like this one okay it's not very long but I have seen if you look if you look through the history you can see commit messages that are like paragraphs long and they include like description of the bug minimal repro of the bug basically code in your commit message to repro the bug and more things at the end yeah so yeah when you are committing to a link skill you should definitely have commit message because actually when you are sending your patch you have to justify your patch and so your justification is your commit message so yeah if you are in doubt about what you should be saying then just look at the past commit messages for the file and that's one of the great things about committing to one of the things that can help you when you are working with Linux because there is so much work done already so when you are in doubt you just look at what has been done and try and figure it away from there okay then from there it's just you generate the patch then there are scripts to help you check your coding style the patch style any issues it's not perfect but it catches a lot of issues and it's written in Perl which is okay then you use another script to figure out who to email right and then you send off the email and that's the other caveat when you're contributing to Linux which is that client that doesn't mangle patches because okay Linux uses tabs I don't know okay some people hate tabs but Linux generally the quotes the indentation style uses tabs and if you try and paste your patch into let's say the Gmail web interface all your tabs are converted to spaces and now your patch doesn't work at all because when you you apply a patch it doesn't fix the white space for you right so you have to use an appropriate client so this link basically links to again the kernel docs which tells you certain things or certain ways to configure certain clients to make them work with contributing to Linux so you can't use Gmail web interface forget about that you can't use Outlook web interface forget about that basically you have to use your offline client so for me I use Thunderbird I think Linux developers like to use smart anything that's not a web interface has a good chance of working but for Thunderbird you need to tweak some settings so that it doesn't auto flow your patches and things like that and it doesn't mangle your white space but yeah then after that you just wait for feedback and then you send additional versions of your patch and so on that's it right so the last thing of course is so now if you're working in a kernel do you actually navigate through the kernel because the kernel has 15 million lines of code and yeah you have to find your way through it okay well one of the first things you need to be able to do is to actually test your changes so I think if you haven't done this before then you can go and play with it if you use Linux to compile the kernel compile your own kernel and run it on your system or in a VM if you're paranoid but so how do you compile a kernel okay you can clone a tree or you can download a release table and you just configure the kernel so what configuring a kernel does is basically select the drivers and options so that the kernel can run on your system there are a lot of scripts to help you do this configuration but I put local yes config here because what this does is basically takes the current config you have as well as the modules or drivers that are loaded for your system and then it will make a config that will work for your system but there are also other you know there's a way like graphical configurator and so on that lets you just choose what you need and so on or the other way the other option is to just look for what your distro the config that your distribution uses and just use that because that should work you make the kernel so this can take between 5 minutes and half an hour or 1 hour depending on what you have selected and your computer then you install it and then you configure your bootloader to boot the kernel it's very hard to go into the details because everyone has a different setup or alternatively and if you are going to use your own kernel for a long period or you're going to just use your kernel your own kernel instead of the distro's kernel then I would just use your own distro's build system and distribution have some way of letting you use your own kernel Ubuntu Ubuntu has a guide ARK has a guide and so on and if you scan too I think you should know how to compile a kernel but if you're just doing tests you can just overwrite you can just replace the kernel you're using for a while it's fine so what kind of changes can you make or can you make to the kernel so you can and if you are not that familiar with the code yet actually that's one way to get familiar with the code help them document it because the kernel documentation is quite I would say it's not very good and they know that kernel developers know that the documentation is not very good and they will definitely appreciate it if you help them write documentation definitely so what this patch is is basically someone's for your own and this guy is a kernel developer taro and his FOIL was looking at the looking at the screen while he was working on it and like basically like this you see the dashes don't cover this s so his FOIL his kid made a comment about it and you know we have a patch to fix that ya it's a real patch you can click on it so things like that ya or more serious things like you can document a subsystem as you are working through it and so on or you can like if you encounter bugs in drivers which I guess this is the most common kind of like if you are not actively working on a Linux kernel then this is probably the most common thing that you will do like you encounter a kernel bug or crash while you are using your system and you debug it and you figure out a fix then you can commit that as well if you figure out a fix then you contribute that so what when you encounter a bug of course you search the mailing list see if anyone has encountered a bug because most of the time someone has right but most of the time there is no fix ya and check your log so usually if there's a bug then if there's a like okay if there's an issue then usually or most of the time there will be some log output and you can there will give you a hint like maybe where you should be looking at so this kernel bug is not like a bug but a bug a bug is a hazard failure so a bug is just one kind of hazard it's actually the if I remember probably it's the most serious like a hazard ya so this is a hazard failure and so it points you to this line in the kernel source so you just go look at it and how do you debug the kernel it's a bit complicated because like you if you're running the kernel on your own system then you can't possibly attach a debugger to your own system unless you have another computer and like you can if you're for example if you're debugging a Raspberry Pi you could like JTAG and debug that but if you're like debugging the X86 driver it's a bit hard to attach the debugger unless you have special hardware to do that so in general when you're debugging a kernel either you run in a VM like Qemu KVM and then you can attach GDB to that or you just use printf debugging or printk debugging and ya really that's all you can do because you can't attach a debugger and printk is basically the kernel version of printf because there's no standard library and there are so switches to enable diagnostics and so on so that one you have to check the documentation depending on your sub-system so when you encounter a bug actually one of the first things you should do maybe just email the mailing list because there are people who are you know the people who work on the sub-system everyday will be looking at it and you just send a bug say oh I have this bug I'm trying to debug it and they will give you pointers because they are more than willing to help you if you're trying to fix something so it will give you ideas like oh maybe you can enable this for diagnostics and look at this look at this and so on and yeah so that's one of the things also like if you are contributing actually this applies to any open source project don't be afraid to just email and ask for ideas or go on like IRC or something and ask for ideas it really helps right okay and last thing is that Linus Taubholtz has actually said something about he said that he is against kernel debugger so you can go and read his email but anyway this is 19 years ago but I don't think he has changed his opinion Linus is quite stubborn okay and other resources so if you ever need to search through the kernel well it's 15 million line so there are people who have created these source cross reference tools and basically you can go there it's like list all the list all the versions and the source and you can just search fire say panic and then it will tell you always define here and so on then you can just look at it it helps you and the other option the good thing about this is like like types and so on is you can click on it and it will help you search for it the other thing is of course you just git grab or rg rg is drip grab right so I just want to say that if you are searching through a git repo you should use git grab instead of grab because git grab will look at the index or pack files so it's slightly more efficient in terms of IO or if not you can just use rg so rg is this grab replacement written in Rust and it's apparently very fast and other tools like the standard stuff like git blame if you ever need to figure out who broke something so I officially done this so someone actually broke I'm not broke so what happened was that my old laptop every time the battery drop the percentage I would get a random keystroke on my screen right so what happens what happened was actually that there is input device well it's not input it's not input device small if I remember currently it was an ACPI event ACPI event but so this person so some of the ACPI events are like that come through are like you know like some laptops have like tablet mode so when you convert to tablet mode it's actually reflected as an ACPI call and then it's bubble up to so the driver that handling that ACPI device was represented as an input device which makes sense because that's how input devices are but the thing is when he encountered an unhandled call he just sent it as he just sent it as input a keyboard stroke for some strange reason and so for my laptop the battery whenever the battery level change it will be an ACPI event and it was not handled in that driver so it got reflected as a keyboard key press and every time my battery drop I would get a key press which was very annoying so of course I went to debug it so there are tools you can use for this for in my case it was lip input so I figure out which input device it was coming from then the input device would have been coming from a kernel driver so I go and look at that kernel driver then I figure out where that input key stroke was coming from then I go and get blame and go and see that this person made this change and actually I emailed him and asked him why he did this so that's also actually open source in general where people can email you years later about something some change you made and ask you why do you do this you know yeah and actually and then after that I removed that that fall back key press because it doesn't make sense why were you but yeah so that was one of my that was a patch that I submitted to the kernel yeah so other resources you can look at the mailing list archives the documentation which is which as I said it wasn't it's not very good but there's a lot of things there also a lot of opinions and philosophies that are there also and also kernel newbies it's a community for people who are new to contributing to a kernel they also like IRC channels like kernel on freenote I think OFTC as well and so on so I think most people here okay so then now we'll look at a demo okay so my demo is I am going to show like so my idea is to add a backdoor to it's just a random idea okay don't actually try and commit this to the kernel so my idea is to add a backdoor to def now so when I write a certain string to it my process UID is changed to root right okay so okay so so let's okay we need some background information here so I want to modify the right handler for this def now so def now in kernel in Linux is character device right because Linux follows this philosophy of basically everything as a file so def now is a character device and what it does is basically it's a virtual device and well if you use Linux you'll know that if you whatever you write to def now is discarded and whenever you read from def now well it just gives you an awful immediately la so and okay and in Linux we have this thing I'm not sure about other languages but in Linux we have devices are represented by like major and minor numbers and yeah so let's just so now we need to figure out where are we going to make this change so I'm just going to use the cross-referencing tool and well so we I'll take this chance also to go through like the kernel source layout so we have number of folders documentation is documentation licenses so the rest of these are basically source code except like scripts and tools those are just built tools right so this one is architecture specific code these are block devices crypto code this is probably the biggest part of the Linux code which are all the device you know these are file system drivers and memory management the network networking code security sound etc so we remember what we had here was a character device right so I'm just going to go on a hunch and we look at FS I mean actually I look through this so I know and then we see oh okay character device so we just go through and see okay so we have this major minor number where is our device created because when we find where the device is created then we also most likely the code for handling the writes is also nearby so oh okay we have this thing called register character device so I'm just going to okay I'm just going to click on this and you can see where it's used okay so it's referenced in a number of places but I think the one we are looking for is in the header right because they have this so you see this underscore underscore so it means it's some sort of internal function the one that people call is probably not that one so we have to look for the one that is the people actually call which is this register character device so let's look for what uses that and it's referenced in a lot of files and okay so there's a number of files here but you know I might want to take a look at this because DevNull is like works in memory okay I mean I'm sort of cheating because I already know where it is but yeah then you look okay let's see there's null here so we have found where this DevNull is created and so you look at the struct here so there's a name of device also although this isn't actually used like it's just internal like your DevNull you could create a DevNull anywhere else and call anything because all that matters is the device major and minor number so what we're looking at is the file operations so what happens when you write or read from the device so DevNull is defined by this null and it's defined here line it to 3 and then we finally when you read from it read null when you write to it write null so let's just search for right now and so it's here so basically all this does is it says that it just returns the count of bytes because it just discuss your data okay so now we know that we need to make our changes here and so let's go and actually make our changes okay so I actually don't have the Linux kernel on my my laptop because I don't want to trash my SSD I'm a bit paranoid about it it's like 1.7GB and if you actually just take the whole folder oh okay 3GB but it's a lot of file so I don't want and I don't want to be compiling the kernel on my laptop so I just have it on the computer cluster okay actually so okay so okay what was I okay I wanted to add a backdoor to that DevNull so let's actually look at oops ya so actually I the gate on the computer cluster is like 1.7GB so I have my own gate and I always forget to source my path because I don't want to automatically overwrite my path with my own local path so I but I always forget to do it so I just replace gate with script that tells me to source my profile okay so let's just cut it short so we modify our function right so what we want to do is is it visible is it readable from behind is it better okay so what we're doing is basically we check okay so the idea is if I write this to DevNull then I'm going to become root so basically we just check if count is 23 basically this is the number of bytes you're writing then ya so we copy from user space we cannot access so this buff is what the user is writing we cannot access it directly because it's a pointer to user memory and it could be invalid and so on so we don't want to access it directly so we have helper functions that help us access user memory and they won't like these helper functions will check if the memory is accessible and so on and return the appropriate errors when it's not so we copy the memory to our internal buffer and then we check compare and check it's our magic string and then ya so we prepare our set of credentials so this part comes from the Linux security sub-system which is well which is documented here so I'm just going through my top process as I wrote this maybe it will help so it's written here and then it says here oh how do we alter credentials so it tells us that we should prepare a new set a cred struct we should prepare a new cred struct by calling prepare creds and modify it and once we're done we commit it so it's quite clean because it has been wrapped into a nice API for us right so we just prepare set our set our user id and group id to zero okay okay ya the return value is that what you're asking ya so copy from user returns the number of bytes that were not copied so we want zero because we want them if it has some bytes not copied it means something is wrong already so ya zero is success and memcmp ya la we want it to be equal so zero ya and I don't know if you all know like you know people always say label go to is bad but I think in C code generally you just like it's quite standard for error handling ya so ya we set the UID and group id to zero so all this other maybe I just mention this is the save UID effective UID and this is the UID used for NFS access just some kernel or line-up stinks so we just set it to zero and we commit it and let's say la we everything else just works as if the same so now we have return our code right so we compile a kernel which I won't show and then we have to test whether it works so so I actually use Alpine Linux VM so let's just run so actually ya let's wait for the VM to boot up so I have now I'm using the unmodified 5.0.7 kernel right okay so this is just I'm using QEMU in case anyone uses QEMU here I'm using QEMU with the graphical UI disabled so I'm just this is the output to the zero console which is why you hear TTYS0 so I'm just going to log in as nobody ya normally nobody is disabled but I enable it just for sake of demonstration so now let me just check I'm using the oh okay I have the back.kernel so okay normally when you write something to Dev now nothing happens right but now let me just show you that I am nobody right and now I'm going to so the dash n just says don't append a new line because we need to emit the exact bytes once and for all right oh so it works okay so ya so our patch works so now we can commit it lah so I'm just going to power off so I'm rude now right so I can power off the system so you'll power off just give me a moment ya so we're done okay so now I'm going to commit and I have to write a good commit message so actually I already made a commit but ya so you will have your real name and then you have your title and say that oh okay so why do you make this commit and so on and then at the end signed off by my real name okay so you have your commits so normally you okay if you're writing a big change then you will divide it logically into commits as far as possible you should divide your commits into sorry you should divide your change into independent commits that sort of can as far as possible you should divide them into commits that are sort of independent and can be applied independently although they might not do anything on their own but the kernel should still work when you apply them independently as far as possible it may not be possible then in that case you can have some dependencies but as far as possible you should remove them and I think this should be applied to any any kind of PR you do la as far as possible you should divide your changes into commits that can be applied independently and when you apply each commit they don't break like at each stage your code base is still comparable and it passes all the tests as far as possible but most people don't bother okay so we have a patch so I'm just going to get format patch actually I already I already did that so format patch format we'll just generate patch files for all the commits from the commit you specify here so we only have one commit so I'm just going to reference the commit just before this commit right so we have a patch file and yeah so now we're going to run the script switch let's check the style sorry check patch right so I have some style issues which I'm actually going to commit this then if you're going to actually send this then you will of course fix all these issues so basically this is just code style issue switch okay and then the script is written in Perl but it can actually fix your C style so I don't even want to look at the the script source code but yeah okay then let's figure out who we're going to send this patch to okay so it says that we should send it to these people is it too small sorry yeah okay then finally now we know we have a patch and we know who to send it to so let's actually send it okay no I'm not going to send it okay so I personally use Thunderbolt so I'll just show you how so in Thunderbolt Thunderbolt Thunderbird Thunderbird of course okay let's just actually look at the patch file right so the patch file is actually generated as a valid email file so if you're using a same client like for example Mart, Thunderbird, anything you can just import the email file straight in and yeah so I'm just going to I'm just going to import the email in right yeah so now my patch is done right so it's a draft message and my patch is all here and if I can show you yeah so the tabs are preserved right so let's edit the thing and then of course if we're going to send it then I will just add in the people I'm going to send it to and send it lah so that's it and then you wait for your feedback and so on yeah okay so let's basically that's it for my talk the last part is so why do you use line-ups because you can do this right or actually okay you can use BSDs too you can actually you can contribute and look at the source for BSDs but you know Linux is the one with like the most development work done on it and so on so you know why line-ups because of this you can if something breaks you can go in and see what's wrong and even fix it yourself you can't do that for Windows or Mac yeah so that's all I have