<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Bodha</title><link>https://bodha.siddh.me/</link><description>Recent content on Bodha</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Wed, 18 Oct 2023 18:33:32 +0530</lastBuildDate><atom:link href="https://bodha.siddh.me/index.xml" rel="self" type="application/rss+xml"/><item><title>Study resources for electronics and other subjects</title><link>https://bodha.siddh.me/posts/2023/10/18/ece_study_resources/</link><pubDate>Wed, 18 Oct 2023 18:33:32 +0530</pubDate><guid>https://bodha.siddh.me/posts/2023/10/18/ece_study_resources/</guid><description>Navigation If you are here for a specific subject, click on its name in the ToC to jump directly to it.
Introduction There is a lack of any list of quality resources to study from for (mainly UG) electronics (ECE et al) students. The subjects are much harder than those of CSE counterparts. This means there are a lot of bad resources masquerading as quality ones and get high views, especially on YT, as they essentially serve as last minute prep for students at 3 AM.</description><content>&lt;h2 id="navigation">Navigation&lt;/h2>
&lt;p>If you are here for a specific subject, click on its name in the ToC to jump directly to it.&lt;/p>
&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>There is a lack of any list of &lt;strong>quality&lt;/strong> resources to study from for (mainly UG) electronics (ECE et al) students. The subjects are much harder than those of CSE counterparts. This means there are a lot of bad resources masquerading as quality ones and get high views, especially on YT, as they essentially serve as last minute prep for students at 3 AM.&lt;/p>
&lt;p>In this post, I&amp;rsquo;ll try to list quality resources I&amp;rsquo;ve used or come across during my UG. &lt;strong>This is NOT an exhaustive list and only contains a &lt;u>few&lt;/u> resources.&lt;/strong> Diligently studying (which I didn&amp;rsquo;t do) from the resources will hopefully give you a deeper understanding and put you ahead of average engineering plebs like me.&lt;/p>
&lt;p>I will keep updating this to include content I forgot, or found to be helpful.&lt;/p>
&lt;hr>
&lt;h2 id="sources-to-avoid">Sources to avoid&lt;/h2>
&lt;p>Except standard books, avoid everything like a plague. No, that textbook bearing your university&amp;rsquo;s name and tailored to syllabus is a scam with sloppy multi-level plagiarism, and is the worst literature to exist on the face of Earth.&lt;/p>
&lt;p>Any source which has &amp;ldquo;GATE&amp;rdquo; written anywhere, in thumbnail, or in source (like channel) name. They are mostly programming you for an exam instead of teaching you the subject in depth and providing intuition.&lt;/p>
&lt;p>YT channels whose content don&amp;rsquo;t have any depth and go on with a mugging up workflow. Popular examples are Gajendra Purohit, Engineering Funda, etc. Avoid them like plague.&lt;/p>
&lt;hr>
&lt;h2 id="sources-to-consult">Sources to consult&lt;/h2>
&lt;p>As a thumb rule, prefer to go for a domain specialist than a single guy who seems to make videos for every subject under the sun. When starting search, try to go for long form content by sources like NPTEL, MIT OCW, college professors, etc. Not all series are good even in them, so you should put effort into finding the good ones according to your taste.&lt;/p>
&lt;p>It does not always have to be college lecture series. Popular != bad. There are &lt;em>many&lt;/em> good popular channels out there whose contents are remarkable. Example:
&lt;a
href="https://www.youtube.com/@BenEater"
target="_blank"
>Ben Eater&lt;/a>.&lt;/p>
&lt;p>Attend lectures in college if you have good professors. There are always some out there. They are irreplaceable, many times you can just learn the entire thing during lectures itself.&lt;/p>
&lt;p>&lt;strong>There is no substitute for practicals.&lt;/strong> Please get involved in as much projects and practical activity as you can, that gives you a working knowledge and insight into things.&lt;/p>
&lt;hr>
&lt;br>
&lt;h2 id="general">General&lt;/h2>
&lt;br>
&lt;h3 id="mathematics">Mathematics&lt;/h3>
&lt;p>Khan Academy is a good resource to a major extent. Sometimes content may not be ordered in playlist properly, so try putting some effort to find them. Also, Grant Sanderson worked with KA to make videos on advanced topics like multivariable calculus, before he opened his famous 3B1B channel on YouTube.&lt;/p>
&lt;p>Khan Academy is good for the following subjects:&lt;/p>
&lt;ul>
&lt;li>Calculus and differential equations&lt;/li>
&lt;li>Linear Algebra&lt;/li>
&lt;li>Multivariable Calculus (Vector Calculus)&lt;/li>
&lt;li>Probability and Statistics (upto a point)&lt;/li>
&lt;li>Sequences and Series (Start with the AP College Calculus BC playlist) (upto a point)&lt;/li>
&lt;/ul>
&lt;p>While it may not cover everything (though a major part is covered), what it covers is done in a very good way. Outside of it, you may search on Brilliant (yes), OCW, NPTEL, etc. I&amp;rsquo;ll add them towards the end of this section. Or you can just read the books, whichever you have.&lt;/p>
&lt;p>Fourier is missing, and Laplace is not really explained well (because Fourier isn&amp;rsquo;t there). But these things you learn during Signals course again (signals playlist has an excellent explanation), with the reason why they were made in the first place, so maybe it&amp;rsquo;s okay. Laplace and differential equations are encountered even earlier, during the Control Systems course.&lt;/p>
&lt;p>Wikipedia is unironically a good resource, especially for stuff like sequences and series.&lt;/p>
&lt;p>&lt;em>(I need to find what I used, I&amp;rsquo;ll update here as and when I remember or get hold of them.)&lt;/em>&lt;/p>
&lt;p>Probability and Statistics:&lt;/p>
&lt;ul>
&lt;li>
&lt;a
href="https://www.youtube.com/@zedstatistics/playlists"
target="_blank"
>zedstatistics&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://automata88.medium.com/list/ap-statistics-intuition-cacc224d5e7d"
target="_blank"
>Ms Aerin articles on Medium&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/playlist?list=PL2SOU6wwxB0uwwH80KTQ6ht66KWxbzTIo"
target="_blank"
>Statistics 110: Probability - Prof. Joe Blitzstein, Harvard University&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://nptel.ac.in/courses/115106089"
target="_blank"
>Physical Applications of Stochastic Processes - Prof. V. Balakrishnan, IIT Madras&lt;/a>. This is an advanced course if you like the subject.&lt;/li>
&lt;/ul>
&lt;p>Edit: A friend suggested
&lt;a
href="https://www.youtube.com/@Eigensteve"
target="_blank"
>Steve Brunton&lt;/a> for Fourier series and transform, and
&lt;a
href="https://www.youtube.com/c/drtreforbazett"
target="_blank"
>Dr. Trefor Bazett&lt;/a> for differential equations. Do check them out!&lt;/p>
&lt;br>
&lt;h3 id="c-programming">C Programming&lt;/h3>
&lt;p>If you know programming already, get K&amp;amp;R and enjoy the absolute best content out there.&lt;/p>
&lt;p>&amp;ldquo;K&amp;amp;R&amp;rdquo; refers to the book &amp;ldquo;The C Programming Language&amp;rdquo; by Brian Kernighan and Dennis Ritchie.&lt;/p>
&lt;p>If you are new to programming, start by using online platforms which give you tasks to complete, or learn while doing things. After you are able to write a full program with &amp;ldquo;hello world&amp;rdquo; or conditionals yourself, install &lt;code>gcc&lt;/code> on your computer and make and break things yourself. It&amp;rsquo;s a good idea to install a Linux distro (I use Debian Testing, just fire and forget). After you are comfortable, go get K&amp;amp;R.&lt;/p>
&lt;p>&lt;em>&lt;strong>Do NOT use compilers like Turbo C++.&lt;/strong>&lt;/em> If you do, please close this webpage, you cannot be helped.&lt;/p>
&lt;br>
&lt;h3 id="control-systems">Control Systems&lt;/h3>
&lt;p>
&lt;a
href="https://nptel.ac.in/courses/107106081"
target="_blank"
>Control systems - Prof. C.S.Shankar Ram, IIT Madras&lt;/a>&lt;/p>
&lt;p>This NPTEL playlist is &lt;em>&lt;strong>GOLD&lt;/strong>&lt;/em>. Very calm and lucid explanations. You can get the notes
&lt;a
href="https://drive.google.com/drive/folders/1NLFfZqYBQJyi6xu-r-t0DnaMISN_-U4f"
target="_blank"
>from here&lt;/a>.&lt;/p>
&lt;p>The professor is the book.&lt;/p>
&lt;p>Also, learn MATLAB. At this point you may have some programming and scripting knowledge, time for you to employ it in a new domain. Make heavy use of the references/documentation at the MATLAB website. You can also join the
&lt;a
href="https://discord.com/invite/matlab"
target="_blank"
>Discord server&lt;/a> to ask doubts and questions when you are stuck.&lt;/p>
&lt;p>Make sure to install the control and symbolic math toolbox! You might get a license from your college for MATLAB.&lt;/p>
&lt;br>
&lt;hr>
&lt;br>
&lt;h2 id="digital-logic-and-vlsi">Digital logic and VLSI&lt;/h2>
&lt;br>
&lt;h3 id="digital-system-design">Digital System Design&lt;/h3>
&lt;p>
&lt;a
href="https://nptel.ac.in/courses/117/106/117106086/"
target="_blank"
>Digital Circuits and Systems - Prof. S Srinivasan, IIT Madras&lt;/a>&lt;/p>
&lt;p>This NPTEL playlist is &lt;em>&lt;strong>GOLD&lt;/strong>&lt;/em>. Just see the first video if you doubt me. If you study from this, you are going to impose dominance over others who are just coasting, and your path to studying advanced concepts, microprocessors, and VLSI will be a lot easier. Literally a zero to hero path. Diligently study and make notes!&lt;/p>
&lt;p>If you want a book, go with Morris Mano, but the video lecture series will be better for the topics it contains.&lt;/p>
&lt;p>Also, an extremely good YouTube channel in the practical domain is
&lt;a
href="https://www.youtube.com/@BenEater"
target="_blank"
>Ben Eater&lt;/a>. Just check it out!&lt;/p>
&lt;br>
&lt;h3 id="microprocessors-and-microcontrollers">Microprocessors and Microcontrollers&lt;/h3>
&lt;p>
&lt;a
href="https://www.youtube.com/@BharatAcharyaEducation"
target="_blank"
>Bharat Acharya&lt;/a> has a good introductory videos. Unfortunately, his full courses are paid (though not too costly if you have money to spare). Sometimes you may find the full playlist online, or Bharat Acharya himself may release some of them.&lt;/p>
&lt;p>Anyways, here are some extremely good videos to get you up to speed in the subject (choose the relevant ones, or find on his channel for other architectures). These videos are &lt;em>&lt;strong>GOLD&lt;/strong>&lt;/em>, don&amp;rsquo;t miss them!&lt;/p>
&lt;ul>
&lt;li>(Common) Introduction to Microprocessors:
&lt;a
href="https://www.youtube.com/watch?v=Xl2nWDcy0To"
target="_blank"
>English&lt;/a>, or
&lt;a
href="https://www.youtube.com/watch?v=0M74z5jEAyA"
target="_blank"
>Hindi&lt;/a>.&lt;/li>
&lt;li>8085 architecture:
&lt;a
href="https://www.youtube.com/watch?v=fS7FFOaC_iQ"
target="_blank"
>English&lt;/a>, or
&lt;a
href="https://www.youtube.com/watch?v=UWekjor55pc"
target="_blank"
>Hindi&lt;/a>.&lt;/li>
&lt;li>8086 (English):
&lt;a
href="https://www.youtube.com/watch?v=DmwOSdwzZ3E"
target="_blank"
>Architecture&lt;/a>,
&lt;a
href="https://www.youtube.com/watch?v=RFDZbZWPMvg"
target="_blank"
>Buses and Memory&lt;/a>.&lt;/li>
&lt;/ul>
&lt;p>After you know the basics of how a microprocessor is described and ISA is read, you&amp;rsquo;ll be able to broadly understand any processor under the sun!&lt;/p>
&lt;p>Practice reading and writing assembly programming. Use simulators like &lt;code>GNUSim8085&lt;/code> or &lt;code>avr_sim&lt;/code> instead of bloated IDEs.&lt;/p>
&lt;p>Understand how your C programs are translated to assembly. NPTEL has a &lt;em>&lt;strong>very good&lt;/strong>&lt;/em> playlist:&lt;/p>
&lt;p>
&lt;a
href="https://nptel.ac.in/courses/106106210"
target="_blank"
>C Programming and Assembly Language - Prof. Janakiraman Viraraghavan, IIT Madras&lt;/a>&lt;/p>
&lt;p>Also,
&lt;a
href="https://www.youtube.com/@BenEater"
target="_blank"
>Ben Eater&lt;/a> as always is an extremely good practical resource.&lt;/p>
&lt;br>
&lt;h3 id="advanced-µc--µp-arm7">Advanced µc / µp, ARM7&lt;/h3>
&lt;p>Start with
&lt;a
href="https://www.youtube.com/watch?v=fI20Bsx3EPM"
target="_blank"
>introduction by Bharat Acharya&lt;/a>. It is an &lt;strong>extremely&lt;/strong> good video and will get you up to speed very quickly.&lt;/p>
&lt;p>For full video series, a very good one is
&lt;a
href="https://nptel.ac.in/courses/106105193"
target="_blank"
>Embedded System Design with ARM - Prof. Indranil Sengupta and Prof. Kamalika Datta, IIT Kanpur&lt;/a>, covering in sufficient breadth and depth.&lt;/p>
&lt;p>Then consult the official documentation by Arm for learning about architecture, programmer&amp;rsquo;s model, and ISA in general. You should also consult lecture PPTs and articles posted online. I don&amp;rsquo;t have specific links to the ones I used back in the days, but you can easily find a lot of them with the help of Google.&lt;/p>
&lt;p>Here are a few links to helpful manuals and other resources:&lt;/p>
&lt;ul>
&lt;li>
&lt;a
href="https://iitd-plos.github.io/col718/ref/arm-instructionset.pdf"
target="_blank"
>Chapter 4 - ARM Instruction Set - ARM7TDMI-S Data Sheet&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://developer.arm.com/documentation/ddi0234/latest/"
target="_blank"
>ARM7TDMI-S Technical Reference Manual&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://www.slideserve.com/haley/general-purpose-processor"
target="_blank"
>General Purpose Processor and ARM Introduction - Slideserve&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>Honestly, I didn&amp;rsquo;t consult any specific book or video lecture series. If you want, there are some books, as well as series on NPTEL which I linked above. Though, you don&amp;rsquo;t need to see videos or read books to do any kind programming, let alone assembly. ISA can also be understood directly from references (you will be able to do it, I know), but it is understandable to get a curated text. So you can consult any book you like, even the books I told to avoid at the start. It&amp;rsquo;s just a matter of understanding the reference.&lt;/p>
&lt;p>Make sure to learn ISA and assembly instructions and their addressing modes.&lt;/p>
&lt;p>Attempt problems on assembly programming, and build up logic on how to use ARM instructions and flags to your advantage and reduce branching. For example, there is an &lt;code>LDRSBGT&lt;/code> possible.&lt;/p>
&lt;p>Use
&lt;a
href="https://cpulator.01xz.net/?sys=arm"
target="_blank"
>CPUlator ARMv7 System Simulator&lt;/a> which runs completely on browser, instead of bothering around with Keil.&lt;/p>
&lt;p>For LPC2148 microcontroller, the following playlist is good to ramp up:&lt;/p>
&lt;p>
&lt;a
href="https://www.youtube.com/playlist?list=PLgIjRMdFBe6uhhko53nOU30T0u-wvoDG9"
target="_blank"
>ARM Programming With Embedded C - Vishal Gaikwad&lt;/a>&lt;/p>
&lt;p>For memory, hazards, cache, virtual memory, etc., the following are some good resources (in no particular order), choose according to your tastes:&lt;/p>
&lt;ul>
&lt;li>
&lt;a
href="https://www.youtube.com/playlist?list=PLiwt1iVUib9s2Uo5BeYmwkDFUh70fJPxX"
target="_blank"
>Virtual Memory - David Black-Schaffer, Uppsala University&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/playlist?list=PLWCT05ePsnGww5psXWHRLG7p30eKKt1Pd"
target="_blank"
>Operating Systems - Casey Cole, USC&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/watch?v=cjNORC_00_A&amp;amp;list=PL08BD8EC321445637&amp;amp;index=11"
target="_blank"
>From Lecture 11 - Embedded Systems - Dr.Santanu Chaudhury, IIT Delhi&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/playlist?list=PLeWkeA7esB-MuCn8XQWAarM7zvimE0yme"
target="_blank"
>Fundamentals of Computer Architecture - Prof. Dr. Ben H. Juurlink, TUB&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/playlist?list=PLBlnK6fEyqRgLLlzdgiTUKULKJPYc0A4q"
target="_blank"
>Computer Organization &amp;amp; Architecture (COA) - Neso Academy&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/playlist?list=PLAwxTw4SYaPmqpjgrmf4-DGlaeV0om4iP"
target="_blank"
>High Performance Computer Architecture - Georgia Tech, Udemy&lt;/a>&lt;/li>
&lt;/ul>
&lt;br>
&lt;h3 id="vlsi-design">VLSI Design&lt;/h3>
&lt;p>I cannot stress this enough. These resources are &lt;em>&lt;strong>GOLD&lt;/strong>&lt;/em>.&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;em>&lt;strong>Watch the first 14 videos of
&lt;a
href="https://www.youtube.com/playlist?list=PLc7Gz02Znph-c2-ssFpRrzYwbzplXfXUT"
target="_blank"
>New Analog Circuit Design (By Prof. Ali Hajimiri, Caltech)&lt;/a>.&lt;/strong>&lt;/em>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;em>&lt;strong>Get &lt;code>Introduction to VLSI Circuits and Systems - John P. Uyemura&lt;/code>.&lt;/strong>&lt;/em>&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>The playlist is just too good, and you will gain a great insight on the semiconductor physics - how transistors and MOSFETs concepts were conceived, and how they work in great detail at a microscopic level. I would say this is mandatory to watch!&lt;/p>
&lt;p>The book has extremely good and lucid explanations, while packing a significant amount of content. It teaches you CMOS logic, stick diagrams, manufacturing process, electrical analysis of MOSFETs (though for that you see the playlist) and CMOS logic, RTL, physical design, system design, clocking, and what not. Literally a zero to hero path. If you don&amp;rsquo;t trust me, see the reviews on Amazon!&lt;/p>
&lt;p>And the book is enjoyable, unlike the boring one by Sung-Mo Kang.&lt;/p>
&lt;p>If you have time, you can see
&lt;a
href="https://nptel.ac.in/courses/117/106/117106092/"
target="_blank"
>Digital VLSI System Design - Prof. S. Srinivasan and Dr. S. Ramachandran, IIT Madras&lt;/a>.&lt;/p>
&lt;p>This is the sequel to the awesome digital circuits course by the same professor (initially), so you know it &lt;em>&lt;strong>will&lt;/strong>&lt;/em> be good!&lt;/p>
&lt;p>Another good resource on YT is
&lt;a
href="https://www.youtube.com/@AdiTeman/playlists"
target="_blank"
>playlists by Prof. Adi Teman, BIU&lt;/a>.&lt;/p>
&lt;br>
&lt;h3 id="embedded-systems-and-rtos">Embedded Systems and (RT)OS&lt;/h3>
&lt;p>A good resource to look at is the Linux kernel :D&lt;/p>
&lt;p>The following resources (in nor particular order) are good for ramping up, choose whichever suits you the best:&lt;/p>
&lt;ul>
&lt;li>
&lt;a
href="https://www.youtube.com/playlist?list=PLYwpaL_SFmcBpuYagx0JiSaM-Bi4dm0hG"
target="_blank"
>Hindi: Embedded and Real Time Operating Systems (ERTOS) - 5 Minutes Engineering&lt;/a> (fast concept building)&lt;/li>
&lt;li>
&lt;a
href="https://en.wikipedia.org/wiki/Real-time_operating_system"
target="_blank"
>Real-time operating system - Wikipedia&lt;/a>, and follow the rabbit hole :P Yes, Wikipedia is good!&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/playlist?list=PLacuG5pysFbDQU8kKxbUh4K5c1iL5_k7k"
target="_blank"
>CS 377 Spring &amp;lsquo;14: Operating Systems - Sean Barker, UMass&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://nptel.ac.in/courses/106105172"
target="_blank"
>Real Time Operating System - Prof. Rajib Mall, IIT Kharagpur&lt;/a> (Speed up the videos to 1.5x or 2x)&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/playlist?list=PLBlnK6fEyqRiVhbXDGLXDk_OQAeuVcp2O"
target="_blank"
>Operating Systems - Neso Academy&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/watch?v=fQ8x3hQR-zM&amp;amp;list=PL1XjRDnU2tOipNUtu22aHUGC4SADqHrYF&amp;amp;index=10"
target="_blank"
>OS8 - OS- EZCSE&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>An &lt;em>&lt;strong>extremely&lt;/strong>&lt;/em> good book is &lt;code>An Embedded Software Primer - David E. Simon&lt;/code>. I stumbled upon its explanation of shared data problem, and scheduling, and I immediately just &lt;em>got it&lt;/em>. The book introduces you to embedded systems and RTOS concepts.&lt;/p>
&lt;p>For microcontroller like MSP430, I don&amp;rsquo;t think I should be adding videos at this point :P, you are capable enough, but anyways the following is a good one:&lt;/p>
&lt;p>
&lt;a
href="https://nptel.ac.in/courses/108102169"
target="_blank"
>Introduction to Embedded System Design - Prof. Dhananjay V. Gadre (NSUT) and Prof. Badri N Subudhi (IIT Jammu)&lt;/a>&lt;/p>
&lt;p>Another good book is &lt;code>Embedded Systems Design: A Unified Hardware/Software Introduction - Vahid, Givargis&lt;/code>. Though, I have only skimmed through some of it&amp;rsquo;s introductory chapters. YMMV.&lt;/p>
&lt;br>
&lt;h3 id="vlsi-testing-and-verification">VLSI Testing and Verification&lt;/h3>
&lt;p>The following books are very good to learn from:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;code>VLSI Test Principles and Architectures - L.T. Wang, C.W. Wu, X. Wen&lt;/code> (colloquially known as WWW).&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>Writing Testbenches: Functional Verification of HDL Models - Janick Bergeron&lt;/code>.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>An excellent video series on testing is
&lt;a
href="https://www.youtube.com/playlist?list=PLvd8d-SyI7hjk_Ci0zpTqImAtpEjdK5JF"
target="_blank"
>VLSI Testing - Prof. James Chien-Mo Li, NTU&lt;/a>. The prof. has also authored a chapter in WWW!&lt;/p>
&lt;br>
&lt;hr>
&lt;br>
&lt;h2 id="circuits">Circuits&lt;/h2>
&lt;br>
&lt;h3 id="network-theory">Network Theory&lt;/h3>
&lt;p>
&lt;a
href="https://www.youtube.com/playlist?list=PLc7Gz02Znph_HU1I9STgC4Nv0aG_jdb8Z"
target="_blank"
>Circuits and Systems (By Prof. Ali Hajimiri, Caltech)&lt;/a>&lt;/p>
&lt;p>While I haven&amp;rsquo;t seen this one as I stumbled upon it later, I&amp;rsquo;ve seen Prof. Hajimiri&amp;rsquo;s other playlist (New Analog Circuit Design), and I can safely say &lt;strong>if you want to have a good insight, this is the playlist you need to see&lt;/strong>.&lt;/p>
&lt;p>
&lt;a
href="https://www.youtube.com/playlist?list=PLBlnK6fEyqRgLR-hMp7wem-bdVN1iEhsh"
target="_blank"
>Neso Acadaemy&amp;rsquo;s playlist&lt;/a> is also good, particularly for quick learning and ramping up, but it can never rival the depth and insight in Prof. Hajimiri&amp;rsquo;s lectures.&lt;/p>
&lt;p>&lt;code>Engineering Circuit Analysis - Hayt, Kemmerly, Durbin&lt;/code> is a good textbook with very good explanation. It is thanks to this book that I could learn this subject and survive the exam!&lt;/p>
&lt;br>
&lt;h3 id="analog-circuit-design">Analog Circuit Design&lt;/h3>
&lt;p>
&lt;a
href="https://www.youtube.com/playlist?list=PLc7Gz02Znph-c2-ssFpRrzYwbzplXfXUT"
target="_blank"
>New Analog Circuit Design (By Prof. Ali Hajimiri, Caltech)&lt;/a>&lt;/p>
&lt;p>&lt;em>&lt;strong>Extremely&lt;/strong>&lt;/em> good playlist! I came across this later during my VLSI studies, but you don&amp;rsquo;t have to!&lt;/p>
&lt;p>This is my weakest subject :P (no surprises, the course is too big, and the content is very high IQ, and COVID pandemic didn&amp;rsquo;t help).&lt;/p>
&lt;br>
&lt;hr>
&lt;br>
&lt;h2 id="signals-and-systems">Signals and Systems&lt;/h2>
&lt;br>
&lt;h3 id="continuous-time">Continuous time&lt;/h3>
&lt;p>
&lt;a
href="https://www.youtube.com/playlist?list=PL557uxcMh3xz82fmtp-2HhZVCWxSPshmr"
target="_blank"
>Signals and Systems 2021 - Prof. Andrew Reader&lt;/a>&lt;/p>
&lt;p>Can&amp;rsquo;t recommend the above playlist enough. This is &lt;em>&lt;strong>GOLD&lt;/strong>&lt;/em>. If you are new or want to solidify your understanding quickly, just stop everything right now and watch it! It&amp;rsquo;s only 8 videos long. Make notes!&lt;/p>
&lt;p>
&lt;a
href="https://ocw.mit.edu/courses/res-6-007-signals-and-systems-spring-2011/"
target="_blank"
>Signals and Systems - Prof. Alan V. Oppenheim - MIT OCW&lt;/a>&lt;/p>
&lt;p>Yes, this series is by Alan Oppenheim (the author of the de-facto standard book) himself! The lectures are still relevant despite being recorded more than 35 years ago. You gotta increase the speed. Also, the intro music is addictive, and is still stuck in my mind…&lt;/p>
&lt;p>If you want to learn in Hindi, NPTEL has a playlist:
&lt;a
href="https://nptel.ac.in/courses/108106163"
target="_blank"
>Signals and Systems - Prof. Kushal K. Shah, IISER Bhopal&lt;/a>.&lt;/p>
&lt;p>For book, no surprises here, go with &lt;code>Signals and Systems - Oppenheim, Willsky, Young&lt;/code>.&lt;/p>
&lt;br>
&lt;h3 id="discrete-time---dsp">Discrete time / DSP&lt;/h3>
&lt;p>
&lt;a
href="https://nptel.ac.in/courses/117102060"
target="_blank"
>Digital Signal Processing - Prof. S.C. Dutta Roy, IIT Delhi&lt;/a>&lt;/p>
&lt;p>This NPTEL video series is &lt;em>&lt;strong>GOLD&lt;/strong>&lt;/em>, even though it is old resulting in low video resolution. The prof. knows his stuff and his style of teaching is very lucid. Though you will need to increase the speed to something like 1.5x. Hope you enjoy the &lt;em>difference&lt;/em> to discrete-time domain!&lt;/p>
&lt;p>
&lt;a
href="https://ocw.mit.edu/courses/res-6-008-digital-signal-processing-spring-2011/"
target="_blank"
>Digital Signal Processing - Prof. Alan V. Oppenheim - MIT OCW&lt;/a>&lt;/p>
&lt;p>This is another old series instructed by Oppenheim himself! You gotta increase the speed here too. For some reason, old Signals professors have the tendency to be slow…&lt;/p>
&lt;p>
&lt;a
href="https://www.youtube.com/playlist?list=PLXbLuD5WNA3LFU86pSAB-b8bx_zYCkoew"
target="_blank"
>Digital Signal Processing - KK Awasthi&lt;/a> (Hindi)&lt;/p>
&lt;p>This playlist is in Hindi, and is primarily geared towards filter design and DFT. If you want to quickly learn filter structure and realisation, especially if an exam is coming, I would recommend watching it.&lt;/p>
&lt;p>For book, go with &lt;code>Discrete-Time Signal Processing - Oppenheim, Schafer, Buck&lt;/code>. Please avoid a different book named &amp;ldquo;Digital Signal Processing&amp;rdquo; by Oppenhiem.&lt;/p>
&lt;br>
&lt;hr>
&lt;br>
&lt;h2 id="em-and-communication">EM and Communication&lt;/h2>
&lt;br>
&lt;h3 id="electromagnetic-theory">Electromagnetic Theory&lt;/h3>
&lt;p>Prerequisites: Vector calculus. Very important! Didn&amp;rsquo;t study this subject properly / much :P, but here are some good resources:&lt;/p>
&lt;p>
&lt;a
href="https://nptel.ac.in/courses/108106073"
target="_blank"
>Electromagnetic Fields - Prof. Harishankar Ramachandran, IIT Madras&lt;/a>&lt;/p>
&lt;p>
&lt;a
href="https://nptel.ac.in/courses/117101056"
target="_blank"
>Transmission Lines and EM Waves - Prof. R.K. Shevgaonkar, IIT Bombay&lt;/a>&lt;/p>
&lt;p>Both the NPTEL playlists are good! It&amp;rsquo;s up to your tastes to choose any one. The first one is using a blackboard, while the second one uses digital slides and paper + marker.&lt;/p>
&lt;p>Prof. Shevgaonkar has also written a book, &lt;code>Electromagnetic Waves - R. K. Shevgaonkar&lt;/code>, which you can get.&lt;/p>
&lt;p>A good well-known book is &lt;code>Elements of Electromagnetics - Matthew N.O. Sadiku&lt;/code>, which is what I was suggested too.&lt;/p>
&lt;br>
&lt;h3 id="analog-and-digital-communication">Analog and Digital Communication&lt;/h3>
&lt;p>
&lt;a
href="https://www.youtube.com/playlist?list=PLlQim6boihdhI0Jw95zxBYcw-NzPpLQFC"
target="_blank"
>Communications Engineering I - Prof. Ali Muqaibel, KFUPM&lt;/a>&lt;/p>
&lt;p>If you want to quickly learn the subject, this is the playlist you &lt;em>&lt;strong>need&lt;/strong>&lt;/em> to see. The prof. explains everything satisfactorily without excessive content. That means the content is good! Though, it does &lt;em>not&lt;/em> cover everything you&amp;rsquo;ll have in your course.&lt;/p>
&lt;br>
&lt;h3 id="antenna-and-propagation">Antenna and Propagation&lt;/h3>
&lt;p>This is a hard and high IQ subject, but also very interesting. It relates to a major part of our everyday macro world - you&amp;rsquo;ll start seeing antennas everywhere for the rest of your life once you start learning this subject!&lt;/p>
&lt;p>&lt;em>Warning:&lt;/em> You must know electromagnetism (like Maxwell&amp;rsquo;s equations etc), and have a good grasp of vector calculus! Otherwise in your quest to avoid it via integral relations, you&amp;rsquo;re gonna mess everything up and fail! Yes, that&amp;rsquo;s very specific :P&lt;/p>
&lt;p>Here are some videos I&amp;rsquo;d suggest watching:&lt;/p>
&lt;ul>
&lt;li>RCAF videos (1960):
&lt;a
href="https://www.nfb.ca/film/propagation/"
target="_blank"
>Propagation&lt;/a>,
&lt;a
href="https://www.nfb.ca/film/directivity/"
target="_blank"
>Directivity&lt;/a>, and
&lt;a
href="https://www.nfb.ca/film/bandwidth/"
target="_blank"
>Bandwidth&lt;/a>.&lt;/li>
&lt;li>USAF videos (1947): Radio Fundamentals -
&lt;a
href="https://www.youtube.com/watch?v=JHSPRcRgmOw"
target="_blank"
>Part 1&lt;/a>,
&lt;a
href="https://www.youtube.com/watch?v=EtEBxY8TvuE"
target="_blank"
>Part 2&lt;/a>.&lt;/li>
&lt;li>Video playlists on the
&lt;a
href="https://www.youtube.com/channel/UCGMEJcR7pOMd4hihuGZl2wQ/playlists"
target="_blank"
>EMViso YouTube channel&lt;/a> (by Kathryn Leigh Smith, UNCC + Ansys).&lt;/li>
&lt;li>Antenna section of
&lt;a
href="https://nptel.ac.in/courses/117101056"
target="_blank"
>Transmission Lines and EM Waves - Prof. R.K. Shevgaonkar, IIT Bombay&lt;/a>. You probably would want to see this as it contains some mathematical derivations.&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>But mainly, you&amp;rsquo;re going to learn using book.&lt;/strong> The subject is just like that, not much video resources outside basics, just literature. The basics of antenna hasn&amp;rsquo;t (or rather, will not) changed, the subject is mathematics-heavy so you &lt;em>&lt;strong>need&lt;/strong>&lt;/em> to read books, there are ton of derivations. Note that you are not going to study the whole book, but a part of it, so size doesn&amp;rsquo;t matter.&lt;/p>
&lt;p>I would suggest &lt;code>Antennas for All Applications - John D. Kraus, Ronald J. Marhefka&lt;/code>. There is another book by Constantine A. Balanis considered the de-facto standard text on antenna, but my first impression of it when comparing with Krauss&amp;rsquo; text was that it seemed more boring and thicker. YMMV.&lt;/p>
&lt;p>There is a &amp;ldquo;Special Indian Edition&amp;rdquo; (SIE) of Krauss&amp;rsquo; text by McGrawHill (which I read), please try to avoid it. But if book with the above mentioned title is not available, go with the SIE. It&amp;rsquo;s a sloppy attempt by a random Indian professor (Ahmad S Khan) who wanted to dish out a book with his name, and as a result distorts the text. He added a chapter in between to address a part of university syllabus in India (the change of tone is very apparent), and as a result messes up the latter chapter numbers, and thus he then concatenated chapters.&lt;/p>
&lt;br>
&lt;h3 id="fibre-optic-communication">Fibre Optic Communication&lt;/h3>
&lt;p>
&lt;a
href="https://nptel.ac.in/courses/108106167"
target="_blank"
>Fiber Optic Communication Technology - Prof. Deepa Venkitesh, IIT Madras&lt;/a>&lt;/p>
&lt;p>This is a very good series covering the subject in sufficient depth, and gives reasoning behind some things which you normally may ignore. I had binge watched it for multiple days before exams! :P&lt;/p>
&lt;p>For book, you may go for &lt;code>Optical Fiber Communications - Gerd Keiser&lt;/code>. While I haven&amp;rsquo;t read it, my friends were positive about it.&lt;/p>
&lt;br>
&lt;h3 id="wireless-communication">Wireless Communication&lt;/h3>
&lt;p>For book I&amp;rsquo;ll recommend &lt;code>Wireless Communications: Principles and Practice - Theodore Rappaport&lt;/code>. This textbook has very good explanations, and is considered the standard. I&amp;rsquo;d suggesting reading the book, especially the cellular concept chapter. Many times people just recycle/copy the content from this book. Someone on Wikipedia just straight-up copied 3-4 pages from this book directly!&lt;/p>
&lt;p>For videos, I&amp;rsquo;ll post links to a couple of sources, choose whatever suits you the best.&lt;/p>
&lt;ul>
&lt;li>
&lt;a
href="https://www.youtube.com/@LTE4G/playlists"
target="_blank"
>@LTE4G on YouTube&lt;/a>. Good for concept building.&lt;/li>
&lt;li>Some LiveOverflow&amp;rsquo;s videos:
&lt;ul>
&lt;li>
&lt;a
href="https://www.youtube.com/watch?v=iJFnYBJJiuQ"
target="_blank"
>How do SIM Cards work? - SIMtrace&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/watch?v=IuxBfHnP5S0"
target="_blank"
>GSM Mobile Network Intro - Nokia Network Monitor&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/watch?v=gKHaKoPJN08"
target="_blank"
>Troopers 17 Badge ft. BadgeWizard&lt;/a>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;a
href="https://nptel.ac.in/courses/106106167"
target="_blank"
>Introduction to Wireless and Cellular Communications - Prof. David KoilPillai, IIT Madras&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://nptel.ac.in/courses/108106192"
target="_blank"
>Fundamentals Of Wireless Communication (Hindi) - Dr.Vivek Bohara, IIIT Delhi&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/playlist?list=PLbbCsk7MUIGfynU-ONMbe-yZXWTgTX1YP"
target="_blank"
>Short Course on Fundamentals of Wireless Communications - David Tse, UC Berkeley - The Qualcomm Institute&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/playlist?list=PLlQim6boihdgIdnLeVe34070cu899Le0c"
target="_blank"
>Wireless Communication - Prof. Ali Muqaibel, KFUPM&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/playlist?list=PLwbDCByFFyXX43OWLPbtqLTW6zQNiVn-Q"
target="_blank"
>Wireless Communication - Quantum Study Circle&lt;/a>. This YT playlist is in Hindi, YMMV w.r.t. content, good for last days preparation.&lt;/li>
&lt;/ul>
&lt;br>
&lt;hr>
&lt;br>
&lt;h2 id="networking-and-protocols">Networking and Protocols&lt;/h2>
&lt;br>
&lt;h3 id="computer-networks">Computer Networks&lt;/h3>
&lt;p>Following are some excellent resources:&lt;/p>
&lt;ul>
&lt;li>
&lt;a
href="https://www.youtube.com/playlist?list=PLIvL2PgyB2oxDePrTzFF6YdQ9lQh9CC8G"
target="_blank"
>Networking related videos by Computerphile&lt;/a> (&lt;em>&lt;strong>GOLD&lt;/strong>&lt;/em>, please watch them!)&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/watch?v=X8jsijhllIA"
target="_blank"
>But what are Hamming codes? The origin of error correction - 3Blue1Brown&lt;/a>. Watch part 2, and Ben Eater&amp;rsquo;s video, both linked in the description.&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/playlist?list=PLBlnK6fEyqRgMCUAG0XRw78UA8qnv6jEx"
target="_blank"
>Computer Networks - Neso Academy&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/@systemengineer7131/playlists"
target="_blank"
>Playlists by System Engineer YT channel&lt;/a>&lt;/li>
&lt;li>
&lt;a
href="https://www.youtube.com/playlist?list=PLYwpaL_SFmcAXkWn2IR-l_WXOrr0n851a"
target="_blank"
>Hindi: Computer Network (CN) - 5 Minutes Engineering&lt;/a>&lt;/li>
&lt;li>Relevant Wikipedia articles&lt;/li>
&lt;/ul>
&lt;p>You really don&amp;rsquo;t want to read too much books for this subject. Getting Tanenbaum would be an academic suicide.&lt;/p>
&lt;p>A good book which is not thick is &lt;code>Computer Networks - Mayank Dave&lt;/code>. It contains lucid and to-the-point explanations and illustrations.&lt;/p>
&lt;br>
&lt;h3 id="internet-of-things">Internet of Things&lt;/h3>
&lt;p>Ngl, this will seem to be the most useless subject when studying (it isn&amp;rsquo;t). This subject is essentially 50% bullshitting, 30% learning protocols and models, and 20% thinking about some &amp;ldquo;smart&amp;rdquo; thing using Arduino et al (which is 50% bullshit).&lt;/p>
&lt;p>This is an easy subject, especially those who are adept with tech and programming like you, so there are no specific resources for this. You should just Google the topic you are studying (say, publish-subscribe model, MQTT, etc.) and see the relevant articles, lecture slides (use stuff like &lt;code>filetype:pdf&lt;/code>), or YouTube videos. Searching generically for &amp;ldquo;IoT&amp;rdquo; will get you 100% bullshit.&lt;/p>
&lt;p>Some YT playlists in Hindi are by
&lt;a
href="https://www.youtube.com/playlist?list=PLz8TdOA7NTzR1NxoC8yRIWfaO0Yrj9gVB"
target="_blank"
>Asha Khilrani&lt;/a>, which goes into details enough for your exams. Another one is by
&lt;a
href="https://www.youtube.com/playlist?list=PLYwpaL_SFmcB8fDd64B8SkJiPpEIzpCzC"
target="_blank"
>5 minutes engineering&lt;/a>.&lt;/p>
&lt;p>If you are thinking to get a book for this, you can do better. Don&amp;rsquo;t make the mistake! :P&lt;/p>
&lt;br>
&lt;hr>
&lt;br>
&lt;h2 id="ai">AI&lt;/h2>
&lt;br>
&lt;h3 id="artificial-intelligence">Artificial Intelligence&lt;/h3>
&lt;p>
&lt;a
href="https://ocw.mit.edu/courses/6-034-artificial-intelligence-fall-2010/"
target="_blank"
>Artificial Intelligence - Prof. Patrick H. Winston - MIT OCW&lt;/a>&lt;/p>
&lt;p>The content in this course is &lt;em>&lt;strong>GOLD&lt;/strong>&lt;/em>! The prof. builds the intuition for how things work in an excellent way from the first principles. I would say just watch it!&lt;/p>
&lt;p>
&lt;a
href="https://nptel.ac.in/courses/106102220"
target="_blank"
>An Introduction to Artificial Intelligence - Prof. Mausam, IIT Delhi&lt;/a>&lt;/p>
&lt;p>This is another good course. It also starts with history for those who like dedicated videos on it.&lt;/p>
&lt;br>
&lt;h3 id="machine-learning">Machine Learning&lt;/h3>
&lt;p>
&lt;a
href="https://nptel.ac.in/courses/106105152"
target="_blank"
>Introduction to Machine Learning - Prof. Sudeshna Sarkar, IIT Kharagpur&lt;/a>&lt;/p>
&lt;p>This is a good theoretical course on ML, which (according to one of the comments) follows content from the Machine Learning book by Tom Mitchell. Though due to its heavy theoretical nature and the difficulty, sometimes you might get bored. :P&lt;/p>
&lt;p>You can download the presentations used in the course
&lt;a
href="https://github.com/raviudal/NPTEL-Intro-to-ML/pull/3"
target="_blank"
>from here&lt;/a>.&lt;/p>
&lt;p>A fun and &lt;em>&lt;strong>GOLD&lt;/strong>&lt;/em> tier resource is the
&lt;a
href="https://www.youtube.com/playlist?list=PLblh5JKOoLUICTaGLRoHQDuF_7q2GfuJF"
target="_blank"
>Machine Learning playlist by StatQuest&lt;/a>. Josh Starmer explains in a very cool, fun and easy way! Of course, it does not contain the theoretical rigour of the NPTEL playlist, but as an engineering student, you must be familiar about tradeoffs by now. :P&lt;/p>
&lt;p>
&lt;a
href="https://www.youtube.com/@VisuallyExplained/videos"
target="_blank"
>Visually Explained&lt;/a> is another good channel, and contains short and intuitive videos for concept building.&lt;/p>
&lt;br>
&lt;hr>
&lt;br>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>That&amp;rsquo;s it for now! Hope you find these useful! :)&lt;/p>
&lt;p>I&amp;rsquo;ll update this post when I find some other good resources I had come across (i.e. to add missing stuff), to update links, or to clarify something if it isn&amp;rsquo;t clear.&lt;/p>
&lt;p>If you encounter any problems or know of link rot or content being moved or redirected, please comment and let me and everyone else know!&lt;/p></content></item><item><title>Running keyutils tests</title><link>https://bodha.siddh.me/posts/2023/10/14/running_keyutils_tests/</link><pubDate>Sat, 14 Oct 2023 02:29:49 +0530</pubDate><guid>https://bodha.siddh.me/posts/2023/10/14/running_keyutils_tests/</guid><description>It&amp;rsquo;s not very apparent how to run the tests in the keyutils repo ( kernel/git/dhowells/keyutils.git - Key management utilities), especially if you don&amp;rsquo;t work on kernel areas like keyrings and watch queue.
Running tests does require some kernel preparation. Searching on internet fetches you limited information. So I looked further what would cause some failures by looking at the test code.
I was able to run all the test using the following config options enabled (you can paste in a file and then use the merge_config script, see my previous post):</description><content>&lt;p>It&amp;rsquo;s not very apparent how to run the tests in the keyutils repo (
&lt;a
href="https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git"
target="_blank"
>kernel/git/dhowells/keyutils.git - Key management utilities&lt;/a>), especially if you don&amp;rsquo;t work on kernel areas like keyrings and watch queue.&lt;/p>
&lt;p>Running tests does require some kernel preparation. Searching on internet fetches you limited information. So I looked further what would cause some failures by looking at the test code.&lt;/p>
&lt;p>I was able to run all the test using the following config options enabled (you can paste in a file and then use the &lt;code>merge_config&lt;/code> script, see my previous post):&lt;/p>
&lt;pre tabindex="0">&lt;code class="language-config" data-lang="config">CONFIG_KEYS=y
CONFIG_TMPFS=y
CONFIG_CRYPTO_LIB_CHACHA20POLY1305=y
CONFIG_BIG_KEYS=y
CONFIG_TRUSTED_KEYS=y
CONFIG_SYSTEM_TRUSTED_KEYRING=y
CONFIG_SECONDARY_TRUSTED_KEYRING=y
CONFIG_SYSTEM_BLACKLIST_KEYRING=y
CONFIG_SYSTEM_TRUSTED_KEYS=&amp;#34;key.pem&amp;#34;
CONFIG_CRYPTO_DH=y
CONFIG_KEY_DH_OPERATIONS=y
CONFIG_INTEGRITY=y
CONFIG_INTEGRITY_SIGNATURE=y
CONFIG_INTEGRITY_ASYMMETRIC_KEYS=y
CONFIG_INTEGRITY_TRUSTED_KEYRING=y
&lt;/code>&lt;/pre>&lt;p>Note that we specify a key named &lt;code>key.pem&lt;/code> to &lt;code>CONFIG_SYSTEM_TRUSTED_KEYS&lt;/code>, which causes the key to be added in the trusted keyring during compile time.&lt;/p>
&lt;p>We can generate a dummy key for tests using the following command:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ openssl req -x509 -newkey rsa:4096 -out key.pem -sha256 -nodes -subj &lt;span style="color:#e6db74">&amp;#34;/CN=.&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Now build the kernel and boot into it using QEMU.&lt;/p>
&lt;p>Install the keyutils packages (on Debian) as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ sudo apt install keyutils libkeyutils*
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Clone the keyutils repo:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/dhowells/keyutils.git
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ cd keyutils
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Now run tests using &lt;code>make&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ make test
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Now all tests in the &lt;code>tests/&lt;/code> directory will run.&lt;/p></content></item><item><title>Kernel QEMU setup for development and debugging</title><link>https://bodha.siddh.me/posts/2023/10/14/kernel_qemu_setup/</link><pubDate>Sat, 14 Oct 2023 01:16:38 +0530</pubDate><guid>https://bodha.siddh.me/posts/2023/10/14/kernel_qemu_setup/</guid><description>Introduction Setting up kernel for debugging can be a confusing task for a beginner. It certainly was for me when I was starting out.
In this post, I&amp;rsquo;ll outline a way to quickly set up your computer to compile and run kernels on the fly. You need to never hassle about it again, we will make aliases along the way so that you just have to use simple commands to do things.</description><content>&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>Setting up kernel for debugging can be a confusing task for a beginner.
&lt;a
href="https://bodha.siddh.me/posts/2022/08/26/the_curious_mouse_click"
>It certainly was for me when I was starting out&lt;/a>.&lt;/p>
&lt;p>In this post, I&amp;rsquo;ll outline a way to quickly set up your computer to compile and run kernels on the fly. You need to never hassle about it again, we will make aliases along the way so that you just have to use simple commands to do things. Tab completion auto-filling the command name makes things very convenient.&lt;/p>
&lt;p>Of course, one should know what an alias is doing before adding them for general use in &lt;code>.bash_aliases&lt;/code>, so please make sure you understand everything and only then add it. Hopefully, I&amp;rsquo;ll be clear, and the context will be obvious if I do not mention some things. I assume basic familiarity with the kernel.&lt;/p>
&lt;p>For those who have already read the article and just wants to see the bash aliases together, I have them (and a couple more) in the following gist:
&lt;a
href="https://gist.github.com/siddhpant/0af22835e6825b90869f583749af2070"
target="_blank"
>https://gist.github.com/siddhpant/0af22835e6825b90869f583749af2070&lt;/a>&lt;/p>
&lt;p>I may update the gist, but not this post necessarily.&lt;/p>
&lt;hr>
&lt;h2 id="cloning-and-saving-the-kernel">Cloning and saving the kernel&lt;/h2>
&lt;p>If you ever tried to clone the kernel, you&amp;rsquo;d know the download is huge! The history is long, so it makes sense. But it does not make sense to keep cloning it again and again.&lt;/p>
&lt;p>Clone entire history once, then keep updating it (using &lt;code>git pull&lt;/code>). Whenever you want to work on the kernel, either&lt;/p>
&lt;ul>
&lt;li>Use &lt;code>git worktree&lt;/code>, which copies the tree but shares the &lt;code>.git&lt;/code> across all of them. Note that it is the &lt;code>.git&lt;/code> folder which is the biggest (currently it is of 2.9 GB).&lt;/li>
&lt;li>Copy the entire repo using &lt;code>cp&lt;/code>.&lt;/li>
&lt;/ul>
&lt;p>Do this for &lt;strong>each&lt;/strong> bug fix or patch set, i.e., for related work. This will help in multitasking and saving work. If you use copy-on-write filesystems like BTRFS, the copy won&amp;rsquo;t even actually take extra space. Only upon modifications will the affected files be created anew.&lt;/p>
&lt;p>While the git.kernel.org (g.k.o) is the canonical home for the kernel, that server is slow for our download. We anyways won&amp;rsquo;t be pushing upstream directly. So, it&amp;rsquo;s best to use the googlesource mirror.&lt;/p>
&lt;p>Clone the mainline once in a folder named &lt;code>updated_mainline&lt;/code> as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux updated_mainline
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Now whenever you need to do some work, let&amp;rsquo;s say work on a UAF in net, you can simply do either of the following:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Worktree method (inside updated_mainline).&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ git worktree add ../net_uaf
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ cd ../net_uaf
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Copy method.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ cp -r updated_mainline/ net_uaf
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ git switch -c uaf_fix &lt;span style="color:#75715e"># Do not work on master branch.&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>While &lt;code>git worktree&lt;/code> should be preferred, I use the copy method, because that&amp;rsquo;s what I started with :-P.&lt;/p>
&lt;hr>
&lt;h2 id="setting-up-git">Setting up git&lt;/h2>
&lt;p>One must ensure that the git configuration is correctly set for kernel repos, as identity is very crucial for signing your commits and sending them via email.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Set identity.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ git config user.name &lt;span style="color:#e6db74">&amp;#34;Your name&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ git config user.email &lt;span style="color:#e6db74">&amp;#34;your@email.com&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>I have GPG signing enabled globally in git, but kernel commits for plebs like us must not be GPG signed, it is used only by maintainers.&lt;/p>
&lt;p>GPG signing is done, on say GitHub, to ensure that the git identity is not fake. By adding a public key to GitHub and checking the signatures in commits, GitHub can verify committer identity. But in kernel development, we use mailing list, so we actually do not need GPG signing. The &lt;code>Signed-off-by&lt;/code> email and the &lt;code>From:&lt;/code> address of the patch email must match.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Disable GPG signing.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ git config commit.gpgsign false
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Upon pulling, rebase should be done. The upstream is supreme. Also, whenever someone says on mailing list to rebase, you just need to pull.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Rebase on pull.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ git config pull.rebase true
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Email SMTP details should be set properly, as the patches to the mailing lists are typically sent using &lt;code>git send-email&lt;/code>. But please&lt;/p>
&lt;ul>
&lt;li>&lt;strong>DO NOT store the password in config&lt;/strong>. One can utilise keyrings to store the password. Here is an excellent blog post detailing the process:
&lt;a
href="https://gchamp20.github.io/git-send-email-gnome-keyring/"
target="_blank"
>Using git send-email with gnome-keyring – Guillaume Champagne&lt;/a> (web archive
&lt;a
href="https://web.archive.org/web/20231012164752/https://gchamp20.github.io/git-send-email-gnome-keyring/"
target="_blank"
>here&lt;/a>).&lt;/li>
&lt;li>&lt;strong>If possible, make sure to create an application specific password to use for git.&lt;/strong>&lt;/li>
&lt;/ul>
&lt;p>This all then simply results in the following git commands:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Set up email settings for send-email.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ git config sendemail.smtpServer &lt;span style="color:#e6db74">&amp;#34;smtp.email.com&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ git config sendemail.smtpEncryption tls
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ git config sendemail.smtpServerPort &lt;span style="color:#ae81ff">587&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ git config sendemail.smtpUser &lt;span style="color:#e6db74">&amp;#34;your@email.com&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ git config sendemail.confirm &lt;span style="color:#e6db74">&amp;#34;always&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>It&amp;rsquo;s effectively mandatory to use &lt;code>checkpatch.pl&lt;/code> script to check your patches, otherwise you&amp;rsquo;ll have complaints over the mailing list (outside of genuine cases). Manually doing it is tiring, and one may forget to do it or get tired of it.&lt;/p>
&lt;p>Fortunately, git allows for hooks to be executed before and after actions like commit. Whenever someone is annoying you with web3 BS like blockchain with smart contracts, just show them git.&lt;/p>
&lt;p>Shuah in the LFD103 course&lt;sup id="fnref:1">&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref">1&lt;/a>&lt;/sup> suggests a neat trick to add checkpatch to the post-commit hook. Basically, after committing changes you extract the commit in patch format (using &lt;code>git show&lt;/code>) and pass it to checkpatch, which will show whether there are any problems or everything is okay.&lt;/p>
&lt;p>To do that, add the following in &lt;code>updated_mainline/.git/hooks/post-commit&lt;/code> and make it executable:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#!/bin/bash
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>patch&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#66d9ef">$(&lt;/span>git show --format&lt;span style="color:#f92672">=&lt;/span>email HEAD&lt;span style="color:#66d9ef">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>./scripts/checkpatch.pl --show-types --strict --codespell - &lt;span style="color:#f92672">&amp;lt;&amp;lt;&amp;lt;&lt;/span> &lt;span style="color:#e6db74">&amp;#34;&lt;/span>$patch&lt;span style="color:#e6db74">&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="kgit_config">kgit_config&lt;/h3>
&lt;p>We can put everything together in a bash function as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>kgit-config&lt;span style="color:#f92672">()&lt;/span> &lt;span style="color:#f92672">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> git config user.name &lt;span style="color:#e6db74">&amp;#34;Your name&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> git config user.email &lt;span style="color:#e6db74">&amp;#34;your@email.com&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> git config commit.gpgsign false
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> git config pull.rebase true
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> git config sendemail.smtpServer &lt;span style="color:#e6db74">&amp;#34;smtp.email.com&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> git config sendemail.smtpEncryption tls
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> git config sendemail.smtpServerPort &lt;span style="color:#ae81ff">587&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> git config sendemail.smtpUser &lt;span style="color:#e6db74">&amp;#34;your@email.com&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> git config sendemail.confirm &lt;span style="color:#e6db74">&amp;#34;always&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> echo -e &lt;span style="color:#e6db74">&amp;#39;#!/bin/bash
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74"> patch=$(git show --format=email HEAD)
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74"> ./scripts/checkpatch.pl --show-types --strict --codespell - &amp;lt;&amp;lt;&amp;lt; &amp;#34;$patch&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74"> &amp;#39;&lt;/span> | awk &lt;span style="color:#e6db74">&amp;#39;{$1=$1};1&amp;#39;&lt;/span> &amp;gt; .git/hooks/post-commit
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> chmod u+x .git/hooks/post-commit
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Now, you can just use &lt;code>kgit-config&lt;/code> on terminal and have everything done for you.&lt;/p>
&lt;p>Even though this is a one-time setup (because you use/copy this repo in the end), it&amp;rsquo;s good to have this alias. You may also work on subsystem-specific trees, linux-next, etc., mainline isn&amp;rsquo;t the only repo.&lt;/p>
&lt;hr>
&lt;h2 id="setting-up-qemu-image">Setting up QEMU image&lt;/h2>
&lt;p>This section is essentially from the syzkaller docs on setting up QEMU&lt;sup id="fnref:2">&lt;a href="#fn:2" class="footnote-ref" role="doc-noteref">2&lt;/a>&lt;/sup>. I will be talking about x86-64.&lt;/p>
&lt;p>Make a specific folder for storing QEMU related things, like the system image. It&amp;rsquo;s good to organise things.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ mkdir -p qemu/image
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ cd qemu/image
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>We will use the &lt;code>create-image.sh&lt;/code> script provided by Google for syzkaller. It will create a Debian image with a passwordless root user, and also generate SSH keys so that we can use SSH to login into the system once run by QEMU.&lt;/p>
&lt;p>Download the script as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ wget https://raw.githubusercontent.com/google/syzkaller/master/tools/create-image.sh
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ chmod +x create-image.sh
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>You may want to remove the &lt;code>-x&lt;/code> flag from line 7 in the script to avoid spam during runtime.&lt;/p>
&lt;p>Create a 10 GB image (suffiicient size to install some things later and not worry about space) containing Debian 12 (bookworm) as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ ./create-image.sh -s &lt;span style="color:#ae81ff">10240&lt;/span> -d bookworm -f full
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Delete leftover chroot folder from building&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>$ sudo rm -rf chroot
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Name the image &lt;code>bookworm.img&lt;/code> so you know what it is, and the associated SSH keys similarly. They all reside in the same folder as the script, here that is &lt;code>qemu/image&lt;/code>.&lt;/p>
&lt;hr>
&lt;h2 id="configuring-the-kernel">Configuring the kernel&lt;/h2>
&lt;p>One can generate a default config with &lt;code>make defconfig&lt;/code>.&lt;/p>
&lt;p>Though, generally when debugging bugs, like those listed on syzkaller, you&amp;rsquo;ll get a config file (which is to be stored as &lt;code>.config&lt;/code> in the kernel root). These may not have all the new config options, and during build time it may ask you for the values those options should have. You could just spam (press and hold) the enter key to set the defaults, or use the handy &lt;code>merge_config.sh&lt;/code> script as:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ ./scripts/kconfig/merge_config.sh .config
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>But this script is for a more powerful purpose. As the name suggests, it merges the config files automatically. It accounts for all dependencies for you, so you do not have to bother with setting values yourself normally.&lt;/p>
&lt;p>This allows for a neat way to configure kernel for our QEMU machines because we need to set some more options. It would be tiring to do them by hand, so we can just have the relevant options in a config file somewhere, let&amp;rsquo;s say in &lt;code>$HOME/linux/config&lt;/code>, and then pass it to this script.&lt;/p>
&lt;p>For our QEMU machine, need to include the &lt;code>kvm_guest.config&lt;/code> from &lt;code>kernel/configs&lt;/code> in the repo, as that includes some necessary config options, like enabling virtIO, 9P filesystem, networking, etc.&lt;/p>
&lt;p>We need some options like &lt;code>CONFIGFS_FS&lt;/code>, &lt;code>SECURITYFS&lt;/code> enabled for correctly booting our image. Also, debugging benefits from a couple of other things, like KASAN, UBSAN, preemption, lockup detector, etc. So, we can have a common config as follows, which we will always include.&lt;/p>
&lt;div class="collapsable-code">
&lt;input id="368145297" type="checkbox" checked />
&lt;label for="368145297">
&lt;span class="collapsable-code__language">config&lt;/span>
&lt;span class="collapsable-code__title">common.config&lt;/span>
&lt;span class="collapsable-code__toggle" data-label-expand="Show" data-label-collapse="Hide">&lt;/span>
&lt;/label>
&lt;pre class="language-config" >&lt;code>
CONFIG_DYNAMIC_DEBUG=y
CONFIG_DEBUG_FS=y
CONFIG_CONFIGFS_FS=y
CONFIG_SECURITYFS=y
CONFIG_DEBUG_INFO=y
CONFIG_KASAN=y
CONFIG_UBSAN=y
CONFIG_PANIC_ON_OOPS=y
CONFIG_PANIC_ON_OOPS_VALUE=1
CONFIG_PANIC_TIMEOUT=0
CONFIG_PREEMPT_BUILD=y
CONFIG_PREEMPT=y
CONFIG_PREEMPT_COUNT=y
CONFIG_PREEMPTION=y
CONFIG_PREEMPT_DYNAMIC=y
CONFIG_SCHED_CORE=y
CONFIG_PREEMPT_RCU=y
CONFIG_PREEMPT_NOTIFIERS=y
CONFIG_LOCKUP_DETECTOR=y
CONFIG_SOFTLOCKUP_DETECTOR=y
CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC=y
CONFIG_HAVE_HARDLOCKUP_DETECTOR_BUDDY=y
CONFIG_HARDLOCKUP_DETECTOR=y
CONFIG_HARDLOCKUP_DETECTOR_PERF=y
CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER=y
CONFIG_HARDLOCKUP_CHECK_TIMESTAMP=y
CONFIG_BOOTPARAM_HARDLOCKUP_PANIC=y
CONFIG_DETECT_HUNG_TASK=y
CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=140
CONFIG_BOOTPARAM_HUNG_TASK_PANIC=y
CONFIG_WQ_WATCHDOG=y
CONFIG_TUN=y
CONFIG_FAULT_INJECTION=y
CONFIG_FAILSLAB=y
CONFIG_FAIL_PAGE_ALLOC=y
CONFIG_FAULT_INJECTION_USERCOPY=y
CONFIG_FAIL_MAKE_REQUEST=y
CONFIG_FAIL_IO_TIMEOUT=y
CONFIG_FAIL_FUTEX=y
CONFIG_FAULT_INJECTION_DEBUG_FS=y
&lt;/code>&lt;/pre>
&lt;/div>
&lt;p>Sometimes we may need more options which are there in &lt;code>kernel/configs/debug.config&lt;/code> in the kernel root. Also, we may sometimes want to enable tracing or options like 9P debugging, which can be done by adding the options in another config file as follows:&lt;/p>
&lt;div class="collapsable-code">
&lt;input id="362879154" type="checkbox" checked />
&lt;label for="362879154">
&lt;span class="collapsable-code__language">config&lt;/span>
&lt;span class="collapsable-code__title">tracing.config&lt;/span>
&lt;span class="collapsable-code__toggle" data-label-expand="Show" data-label-collapse="Hide">&lt;/span>
&lt;/label>
&lt;pre class="language-config" >&lt;code>
CONFIG_KCOV=y
CONFIG_KASAN=y
CONFIG_KASAN_INLINE=y
CONFIG_FTRACE=y
CONFIG_DYNAMIC_FTRACE=y
CONFIG_FUNCTION_TRACER=y
CONFIG_FUNCTION_GRAPH_TRACER=y
CONFIG_IRQSOFF_TRACER=y
CONFIG_PREEMPT_TRACER=y
CONFIG_SCHED_TRACER=y
CONFIG_STACK_TRACER=y
CONFIG_BLK_DEV_IO_TRACE=y
CONFIG_FUNCTION_PROFILER=y
CONFIG_FTRACE_MCOUNT_RECORD=y
CONFIG_NET_9P_DEBUG=y
&lt;/code>&lt;/pre>
&lt;/div>
&lt;p>Now, we can simply create our config as:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ ./scripts/kconfig/merge_config.sh .config &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> ./kernel/configs/kvm_guest.config &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> $HOME/linux/config/common.config
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>For the extra debug options, simply add the config files:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ ./scripts/kconfig/merge_config.sh .config &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> ./kernel/configs/kvm_guest.config &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> ./kernel/configs/debug.config &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> $HOME/linux/config/common.config &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> $HOME/linux/config/tracing.config
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="kconfig">kconfig&lt;/h3>
&lt;p>We can set up a bash function for this as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>kconfig&lt;span style="color:#f92672">()&lt;/span> &lt;span style="color:#f92672">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">case&lt;/span> &lt;span style="color:#e6db74">&amp;#34;&lt;/span>$1&lt;span style="color:#e6db74">&amp;#34;&lt;/span> in
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">&amp;#34;--def&amp;#34;&lt;/span>&lt;span style="color:#f92672">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> make defconfig &lt;span style="color:#e6db74">&amp;#34;&lt;/span>&lt;span style="color:#e6db74">${&lt;/span>@:5&lt;span style="color:#e6db74">}&lt;/span>&lt;span style="color:#e6db74">&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ./scripts/kconfig/merge_config.sh .config &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> ./kernel/configs/kvm_guest.config &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> $HOME/linux/config/common.config
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ;;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">&amp;#34;--fix&amp;#34;&lt;/span>&lt;span style="color:#f92672">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ./scripts/kconfig/merge_config.sh .config &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> ./kernel/configs/kvm_guest.config &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> $HOME/linux/config/common.config
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ;;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#e6db74">&amp;#34;--debug&amp;#34;&lt;/span>&lt;span style="color:#f92672">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ./scripts/kconfig/merge_config.sh .config &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> ./kernel/configs/kvm_guest.config &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> ./kernel/configs/debug.config &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> $HOME/linux/config/common.config &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> $HOME/linux/config/tracing.config
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ;;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> *&lt;span style="color:#f92672">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> echo &lt;span style="color:#e6db74">&amp;#34;Pass --def, --fix, or --debug.&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ;;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">esac&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Now we can just quickly configure using &lt;code>kconfig&lt;/code> command.&lt;/p>
&lt;p>My gist has more options, if interested one can check it out.&lt;/p>
&lt;hr>
&lt;h2 id="building-the-kernel">Building the kernel&lt;/h2>
&lt;p>The kernel can be built with:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ make -j&lt;span style="color:#e6db74">`&lt;/span>nproc&lt;span style="color:#e6db74">`&lt;/span> all
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The &lt;code>nproc&lt;/code> allows for parallelised building, so that the compile time is significantly improved. Some people suggest to use a number = 1.5*nproc in the argument (like if nproc is 12, use -j18).&lt;/p>
&lt;p>Sometimes we may want to build with LLVM. For that we can pass &lt;code>LLVM=1&lt;/code> in the make argument, as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ make -j&lt;span style="color:#e6db74">`&lt;/span>nproc&lt;span style="color:#e6db74">`&lt;/span> all LLVM&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#ae81ff">1&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Now, if we use QEMU to run the kernel, it will be successful, but you&amp;rsquo;ll notice that any loadable modules you may have enabled or made won&amp;rsquo;t be there, because the loadable &lt;code>.ko&lt;/code> files, or even the &lt;code>/lib/modules&lt;/code> folder, simply does not exist.&lt;/p>
&lt;p>We need to use the &lt;code>modules_install&lt;/code> make recipe to copy them to a location, and somehow access it inside the VM. We can achieve that using virtio 9P filesystem. That&amp;rsquo;s why I had mentioned we need to enable it during the configuration.&lt;/p>
&lt;p>Let&amp;rsquo;s copy the modules to a new folder named &lt;code>.compiled_modules&lt;/code> in the tree root. Note that the name starts with a dot, because the &lt;code>.gitignore&lt;/code> is configured to ignore most hidden files and folders.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ make INSTALL_MOD_PATH&lt;span style="color:#f92672">=&lt;/span>./.compiled_modules modules_install
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>modules_install&lt;/code> creates a symlink to the kernel source tree in &lt;code>/lib/modules/&amp;lt;version&amp;gt;/build&lt;/code>, but we cannot really access the symlink from inside the VM (as the mount point will be the &lt;code>.compiled_modules&lt;/code> folder, and not its parent).&lt;/p>
&lt;p>So please delete that symlink. One can copy the entire tree to the &lt;code>build&lt;/code> directory, but there is no need to. But it is a good idea to copy the config file, so the config of the currently running kernel is accessible inside the VM.&lt;/p>
&lt;h3 id="kmake-all">kmake-all&lt;/h3>
&lt;p>We can now put everything in a bash function as follows.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>kmake-all&lt;span style="color:#f92672">()&lt;/span> &lt;span style="color:#f92672">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">(&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> set -e
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">if&lt;/span> &lt;span style="color:#f92672">[[&lt;/span> -f &lt;span style="color:#e6db74">&amp;#34;.llvm&amp;#34;&lt;/span> &lt;span style="color:#f92672">]]&lt;/span>; &lt;span style="color:#66d9ef">then&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> echo -e &lt;span style="color:#e6db74">&amp;#34;.llvm found - Using LLVM.\n&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> make -j18 all LLVM&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#ae81ff">1&lt;/span> &lt;span style="color:#e6db74">&amp;#34;&lt;/span>$@&lt;span style="color:#e6db74">&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">else&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> echo -e &lt;span style="color:#e6db74">&amp;#34;.llvm not found - Using GCC\n&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> make -j18 all &lt;span style="color:#e6db74">&amp;#34;&lt;/span>$@&lt;span style="color:#e6db74">&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">fi&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e"># Store loadable modules so we can use in QEMU via virtfs.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e"># Note: We delete the old folder to avoid failing mkdir et al.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> rm -rf .compiled_modules
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> make INSTALL_MOD_PATH&lt;span style="color:#f92672">=&lt;/span>./.compiled_modules modules_install
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e"># Symlink to local dir in /lib/modules/*/build won&amp;#39;t work in&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e"># the VM, so remove it and just add the config file there.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> rm ./.compiled_modules/lib/modules/*/build
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> mkdir &lt;span style="color:#66d9ef">$(&lt;/span>ls -d ./.compiled_modules/lib/modules/*&lt;span style="color:#66d9ef">)&lt;/span>/build
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> cp .config ./.compiled_modules/lib/modules/*/build
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Note that we automated the LLVM argument by checking if a file named &lt;code>.llvm&lt;/code> exists in the repo root. You can make using &lt;code>touch .llvm&lt;/code>. This is done because it is annoying to write &lt;code>LLVM=1&lt;/code> everytime, it&amp;rsquo;s very convenient to just type &lt;code>km&lt;/code> and use tab completion.&lt;/p>
&lt;hr>
&lt;h2 id="running-the-kernel-in-qemu-you-are-probably-here-for-this">Running the kernel in QEMU (you are probably here for this)&lt;/h2>
&lt;p>The most confusing part most people beginning with kernel development have is running QEMU properly.&lt;/p>
&lt;p>QEMU has a &lt;em>&lt;strong>lot&lt;/strong>&lt;/em> of arguments listed in its manpage. Naturally, it might look like a daunting task at first to figure it out, but after done once it actually starts making perfect sense.&lt;/p>
&lt;h3 id="explanation-of-the-options-we-use">Explanation of the options we use&lt;/h3>
&lt;p>Since we are going to emulate an x86-64 system, the program name would be &lt;code>qemu-system-x86_64&lt;/code>.&lt;/p>
&lt;p>As we are on an x86-64 CPU already, we emulate the same CPU using the &lt;code>-cpu host&lt;/code> option.&lt;/p>
&lt;p>We enable KVM virtualisation acceleration using &lt;code>-accel kvm&lt;/code>, which allows for the near native performance.&lt;/p>
&lt;p>We are going to work using the command line, so we disable the graphics with &lt;code>-nographics&lt;/code> option.&lt;/p>
&lt;p>We can allocate memory to the VM using &lt;code>-m&lt;/code> option. For instance, if we want to allocate 4 GB of RAM, we will use &lt;code>-m 4G&lt;/code>.&lt;/p>
&lt;p>We can allocate the number of cores using the &lt;code>-smp&lt;/code> option. This is important, as race conditions will not happen without multicore setup, as you&amp;rsquo;ll only have one thread running by default (&lt;code>-smp 1&lt;/code>). I allocate half the number listed by &lt;code>nproc&lt;/code>. For example, &lt;code>-smp 6&lt;/code>.&lt;/p>
&lt;p>We need to specify the kernel image location using &lt;code>-kernel&lt;/code> flag. If in the kernel repo root after building, use &lt;code>-kernel ./arch/x86_64/boot/bzImage&lt;/code>.&lt;/p>
&lt;p>We can pass command-line parameters for the kernel using the &lt;code>-append&lt;/code> option.&lt;/p>
&lt;ul>
&lt;li>&lt;code>console=ttyS0&lt;/code> tells the kernel to dump the logs (same as &lt;code>dmesg&lt;/code>) on ttyS0, which is the tty emulated by the QEMU window.&lt;/li>
&lt;li>&lt;code>root=/dev/sda&lt;/code> tells the root partition of the image is &lt;code>/dev/sda&lt;/code>.&lt;/li>
&lt;li>&lt;code>earlyprintk=serial&lt;/code> tells the kernel to print the early boot messages over the serial port.&lt;/li>
&lt;li>&lt;code>nokaslr&lt;/code> disables Kernel Address Space Layout Randomization (KASLR) and causes kernel to be loaded in its standard memory location.&lt;/li>
&lt;li>&lt;code>net.ifnames=0&lt;/code> tells the kernel to disable the Predictable Network Interface Names mechanism, which is needed if the &amp;ldquo;Failed to start Raise network interfaces&amp;rdquo; error is encountered&lt;sup id="fnref:3">&lt;a href="#fn:3" class="footnote-ref" role="doc-noteref">3&lt;/a>&lt;/sup>.&lt;/li>
&lt;li>&lt;code>panic_on_oops=1&lt;/code> tells the kernel to panic when there is an oops, but we set this in the kernel config for compilation, so we need not add this.&lt;/li>
&lt;li>&lt;code>panic_on_warn=1&lt;/code> tells the kernel to panic when a WARN (or a BUG) is encountered.&lt;/li>
&lt;li>&lt;code>panic_on_io_nmi=1&lt;/code> tells the kernel to panic when an IO error causes an NMI.&lt;/li>
&lt;li>&lt;code>panic_on_rcu_stall=1&lt;/code> tells the kernel to panic when an RCU stall is encountered.&lt;/li>
&lt;li>&lt;code>max_rcu_stall_to_panic=1&lt;/code> tells the kernel to panic even for a single RCU stall.&lt;/li>
&lt;li>&lt;code>panic_on_unrecovered_nmi=1&lt;/code> tells the kernel to panic when an unknown/memory NMI is encountered. This is by default off due to hardware vendor reasons, but for QEMU we don&amp;rsquo;t have that limitation. See kernel docs.&lt;sup id="fnref:4">&lt;a href="#fn:4" class="footnote-ref" role="doc-noteref">4&lt;/a>&lt;/sup>&lt;/li>
&lt;li>&lt;code>selinux=1&lt;/code> enables the SELinux module. Setting to &lt;code>0&lt;/code> disables it.&lt;/li>
&lt;/ul>
&lt;p>The arguments discussed above can be passed using &lt;code>-append &amp;quot;console=ttyS0 root=/dev/sda earlyprintk=serial nokaslr net.ifnames=0 panic_on_warn=1 panic_on_io_nmi=1 panic_on_rcu_stall=1 max_rcu_stall_to_panic=1 panic_on_unrecovered_nmi=1 selinux=0&amp;quot;&lt;/code>.&lt;/p>
&lt;p>We need to specify the location of our raw format Debian image we created using the &lt;code>-drive&lt;/code> option. For example, &lt;code>-drive file=$HOME/linux/qemu/image/bookworm.img,format=raw&lt;/code>. Note the lack of space between the two kwargs, it is important so that QEMU parses it correctly as arguments to &lt;code>-drive&lt;/code>.&lt;/p>
&lt;p>We can set the networking options using &lt;code>-net&lt;/code> option.&lt;/p>
&lt;p>We need to set SSH settings, as we discussed we allow for SSH login. For our case, we will set them using &lt;code>-net user,host=10.0.2.10,hostfwd=tcp:127.0.0.1:10021-:22&lt;/code> (config values straight from syzkaller docs&lt;sup id="fnref1:2">&lt;a href="#fn:2" class="footnote-ref" role="doc-noteref">2&lt;/a>&lt;/sup>, you are free to change them).&lt;/p>
&lt;p>We also set the emulated NIC settings using &lt;code>-net nic,model=e1000&lt;/code>.&lt;/p>
&lt;p>We can store the PID of the QEMU VM using &lt;code>-pidfile&lt;/code> option. For example, &lt;code>-pidfile vm.pid&lt;/code>.&lt;/p>
&lt;p>We also mentioned we access the &lt;code>.compiled_modules&lt;/code> inside the VM. We do that by setting a mount point for the 9p virtfs using the &lt;code>-virtfs&lt;/code> option.&lt;sup id="fnref:5">&lt;a href="#fn:5" class="footnote-ref" role="doc-noteref">5&lt;/a>&lt;/sup> Specifically, we use the following (remember the lack of space after commas):&lt;/p>
&lt;pre tabindex="0">&lt;code>-virtfs local,path=./.compiled_modules/lib/modules,mount_tag=compiled_modules,security_model=none
&lt;/code>&lt;/pre>&lt;p>The first argument specifies the filesystem driver. We simply use &lt;code>local&lt;/code> so the individual virtual FS functions are translated directly to act on the host filesystem. The &lt;code>path&lt;/code> specifies the path of the directory to mount (which in our case is the directory we want to be mounted to &lt;code>/lib/modules&lt;/code> in the VM). &lt;code>mount_tag&lt;/code> specifies the tag of the mount point inside the VM. The &lt;code>security-model&lt;/code> specifies the security model for the files in path (credentials, attributes, etc.). We use &lt;code>none&lt;/code> so files created in VM are stored as it is. You can read more on the QEMU docs.&lt;sup id="fnref1:5">&lt;a href="#fn:5" class="footnote-ref" role="doc-noteref">5&lt;/a>&lt;/sup>&lt;/p>
&lt;p>Lastly, we can store all the output by piping the QEMU output to &lt;code>tee&lt;/code> command.&lt;/p>
&lt;h3 id="the-command">The command&lt;/h3>
&lt;p>Therefore, to run our compiled kernel on QEMU, we use the following command by putting together everything:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ qemu-system-x86_64 &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> -cpu host &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> -accel kvm &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> -nographic &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> -m 4G &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> -smp &lt;span style="color:#ae81ff">6&lt;/span> &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> -kernel ./arch/x86_64/boot/bzImage &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> -append &lt;span style="color:#e6db74">&amp;#34;console=ttyS0 root=/dev/sda earlyprintk=serial nokaslr net.ifnames=0 panic_on_warn=1 panic_on_io_nmi=1 panic_on_rcu_stall=1 max_rcu_stall_to_panic=1 panic_on_unrecovered_nmi=1 selinux=0&amp;#34;&lt;/span> &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> -drive file&lt;span style="color:#f92672">=&lt;/span>$HOME/linux/qemu/image/bookworm.img,format&lt;span style="color:#f92672">=&lt;/span>raw &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> -net user,host&lt;span style="color:#f92672">=&lt;/span>10.0.2.10,hostfwd&lt;span style="color:#f92672">=&lt;/span>tcp:127.0.0.1:10021-:22 &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> -net nic,model&lt;span style="color:#f92672">=&lt;/span>e1000 &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> -pidfile vm.pid &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> -virtfs local,path&lt;span style="color:#f92672">=&lt;/span>./.compiled_modules/lib/modules,mount_tag&lt;span style="color:#f92672">=&lt;/span>compiled_modules,security_model&lt;span style="color:#f92672">=&lt;/span>none &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span>2&amp;gt;&amp;amp;&lt;span style="color:#ae81ff">1&lt;/span> | tee vm.log
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="logging-in">Logging in&lt;/h3>
&lt;p>&lt;em>&lt;strong>The username to login is &lt;code>root&lt;/code>&lt;/strong>&lt;/em> if you followed the mentioned procedure to make the image.&lt;/p>
&lt;p>To login using SSH, in a new window use the following SSH command (which uses the key we generated):&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>$ ssh -i $HOME/linux/qemu/image/bookworm.id_rsa -p &lt;span style="color:#ae81ff">10021&lt;/span> -o &lt;span style="color:#e6db74">&amp;#34;StrictHostKeyChecking no&amp;#34;&lt;/span> root@localhost
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>We use port 10021 because that&amp;rsquo;s what we configured in QEMU.&lt;/p>
&lt;h3 id="terminating">Terminating&lt;/h3>
&lt;p>Use Ctrl+A and then X to terminate the VM.&lt;/p>
&lt;h3 id="kemulate">kemulate&lt;/h3>
&lt;p>We can put everything together, and allow for more user arguments which can override the defaults, in a bash function / aliases as follows:&lt;/p>
&lt;div class="collapsable-code">
&lt;input id="892567314" type="checkbox" checked />
&lt;label for="892567314">
&lt;span class="collapsable-code__language">bash&lt;/span>
&lt;span class="collapsable-code__title">kemulate&lt;/span>
&lt;span class="collapsable-code__toggle" data-label-expand="Show" data-label-collapse="Hide">&lt;/span>
&lt;/label>
&lt;pre class="language-bash" >&lt;code>
kemulate() {
qemu_args=&amp;#34;&amp;#34;
# We will pass user args to QEMU, except the flags.
# Since flag processing is needed, we will append them in the end.
# Also, by appending the user args at the end, the default arguments
# can be overriden by user.
user_args=&amp;#34;$@&amp;#34;
# Use host for the KVM on terminal.
qemu_args&amp;#43;=&amp;#34;-cpu host -accel kvm -nographic&amp;#34;
qemu_args&amp;#43;=&amp;#34; &amp;#34;
# Memory size.
qemu_args&amp;#43;=&amp;#34;-m 4G&amp;#34;
qemu_args&amp;#43;=&amp;#34; &amp;#34;
# Number of cores.
qemu_args&amp;#43;=&amp;#34;-smp 6&amp;#34;
qemu_args&amp;#43;=&amp;#34; &amp;#34;
# Kernel image location.
qemu_args&amp;#43;=&amp;#34;-kernel ./arch/x86_64/boot/bzImage&amp;#34;
qemu_args&amp;#43;=&amp;#34; &amp;#34;
# Kernel command line parameters.
qemu_args&amp;#43;=&amp;#34;-append \&amp;#34;&amp;#34;
qemu_args&amp;#43;=&amp;#34;console=ttyS0 root=/dev/sda earlyprintk=serial nokaslr &amp;#34;
qemu_args&amp;#43;=&amp;#34;net.ifnames=0 panic_on_warn=1 panic_on_io_nmi=1 &amp;#34;
qemu_args&amp;#43;=&amp;#34;panic_on_rcu_stall=1 max_rcu_stall_to_panic=1 &amp;#34;
qemu_args&amp;#43;=&amp;#34;panic_on_unrecovered_nmi=1&amp;#34;
if [[ &amp;#34;$1&amp;#34; == &amp;#34;--selinux&amp;#34; ]]; then
qemu_args&amp;#43;=&amp;#34; selinux=1&amp;#34;
user_args=&amp;#34;${user_args:9}&amp;#34;
else
qemu_args&amp;#43;=&amp;#34; selinux=0&amp;#34;
fi
qemu_args&amp;#43;=&amp;#34;\&amp;#34; &amp;#34;
# Debian image to boot.
qemu_args&amp;#43;=&amp;#34;-drive file=$HOME/linux/qemu/image/bookworm.img,&amp;#34;
qemu_args&amp;#43;=&amp;#34;format=raw&amp;#34;
qemu_args&amp;#43;=&amp;#34; &amp;#34;
# User settings for SSH.
qemu_args&amp;#43;=&amp;#34;-net user,host=10.0.2.10,hostfwd=tcp:127.0.0.1:10021-:22&amp;#34;
qemu_args&amp;#43;=&amp;#34; &amp;#34;
# NIC settings.
qemu_args&amp;#43;=&amp;#34;-net nic,model=e1000&amp;#34;
qemu_args&amp;#43;=&amp;#34; &amp;#34;
# PID file.
qemu_args&amp;#43;=&amp;#34;-pidfile vm.pid&amp;#34;
qemu_args&amp;#43;=&amp;#34; &amp;#34;
# Use virtfs to get access to loadable modules inside QEMU.
qemu_args&amp;#43;=&amp;#34;-virtfs local,path=./.compiled_modules/lib/modules,&amp;#34;
qemu_args&amp;#43;=&amp;#34;mount_tag=compiled_modules,security_model=none&amp;#34;
qemu_args&amp;#43;=&amp;#34; &amp;#34;
# Append the user args.
qemu_args&amp;#43;=&amp;#34;$user_args&amp;#34;
# Run QEMU (eval used to avoid bash splitting arguments on spaces)
eval &amp;#34;qemu-system-x86_64 $qemu_args 2&amp;gt;&amp;amp;1 | tee vm.log&amp;#34;
}
alias kemulate-one=&amp;#34;kemulate -smp 1&amp;#34;
&lt;/code>&lt;/pre>
&lt;/div>
&lt;p>Now, just use &lt;code>kemulate&lt;/code> to run the kernel. You can use &lt;code>kemulate-one&lt;/code> if you don&amp;rsquo;t want multi-core setup. You can use &lt;code>--selinux&lt;/code> if you want to enable selinux. You can, as mentioned earlier, add and override the QEMU arguments by passing them to the function.&lt;/p>
&lt;h3 id="klogin">klogin&lt;/h3>
&lt;p>Similarly, we can make a bash function for logging in via SSH (and store the output to a file) as follows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>klogin&lt;span style="color:#f92672">()&lt;/span> &lt;span style="color:#f92672">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ssh -i $HOME/linux/qemu/image/bookworm.id_rsa &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> -p &lt;span style="color:#ae81ff">10021&lt;/span> -o &lt;span style="color:#e6db74">&amp;#34;StrictHostKeyChecking no&amp;#34;&lt;/span> root@localhost &lt;span style="color:#ae81ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#ae81ff">&lt;/span> 2&amp;gt;&amp;amp;&lt;span style="color:#ae81ff">1&lt;/span> | tee ssh_op.log
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h2 id="editing-fstab-to-mount-libmodules-inside-the-vm-image">Editing fstab to mount /lib/modules inside the VM image&lt;/h2>
&lt;p>We booted into the VM, but we still have not mounted the 9P mount point we have created for &lt;code>/lib/modules&lt;/code>.&lt;/p>
&lt;p>We can use the command line to do it, but doing it everytime is a hassle. So, we just add an entry in &lt;code>/etc/fstab&lt;/code> so that it is automatically mounted at boot.&lt;/p>
&lt;p>Append the following in &lt;code>/etc/fstab&lt;/code> and save:&lt;/p>
&lt;pre tabindex="0">&lt;code># &amp;lt;file system&amp;gt; &amp;lt;mount pt&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;
compiled_modules /lib/modules 9p trans=virtio,version=9p2000.L 0 0
&lt;/code>&lt;/pre>&lt;p>Now restart the VM (quit and &lt;code>kemulate&lt;/code> again), and see if the folder in &lt;code>/lib/modules&lt;/code> exist. If you followed everything correctly till now, it will be there.&lt;/p>
&lt;hr>
&lt;h2 id="decoding-stacktrace">Decoding stacktrace&lt;/h2>
&lt;p>Sometimes you&amp;rsquo;ll want to decode a stacktrace dumped by the kernel. We can use the &lt;code>decode_stacktrace.sh&lt;/code> script in the kernel &lt;code>scripts&lt;/code> folder for it.&lt;/p>
&lt;p>The following bash function does it for you:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>ktrace-decode&lt;span style="color:#f92672">()&lt;/span> &lt;span style="color:#f92672">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">if&lt;/span> &lt;span style="color:#f92672">[[&lt;/span> &lt;span style="color:#e6db74">&amp;#34;&lt;/span>$1&lt;span style="color:#e6db74">&amp;#34;&lt;/span> &lt;span style="color:#f92672">==&lt;/span> &lt;span style="color:#e6db74">&amp;#34;&amp;#34;&lt;/span> &lt;span style="color:#f92672">||&lt;/span> &lt;span style="color:#e6db74">&amp;#34;&lt;/span>$2&lt;span style="color:#e6db74">&amp;#34;&lt;/span> &lt;span style="color:#f92672">==&lt;/span> &lt;span style="color:#e6db74">&amp;#34;&amp;#34;&lt;/span> &lt;span style="color:#f92672">]]&lt;/span>; &lt;span style="color:#66d9ef">then&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> echo &lt;span style="color:#e6db74">&amp;#34;Provide input and output filenames.&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> exit &lt;span style="color:#ae81ff">1&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">fi&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#f92672">(&lt;/span>./scripts/decode_stacktrace.sh vmlinux &amp;lt; &lt;span style="color:#e6db74">&amp;#34;&lt;/span>$1&lt;span style="color:#e6db74">&amp;#34;&lt;/span>&lt;span style="color:#f92672">)&lt;/span> &amp;gt; &lt;span style="color:#e6db74">&amp;#34;&lt;/span>$2&lt;span style="color:#e6db74">&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Use as &lt;code>ktrace-decode in.log out.log&lt;/code>.&lt;/p>
&lt;p>Many times you can make &lt;code>in.log&lt;/code> by appropriately trimming the &lt;code>vm.log&lt;/code> file we tee&amp;rsquo;d QEMU&amp;rsquo;s output to in our command.&lt;/p>
&lt;hr>
&lt;h2 id="getting-maintainers">Getting maintainers&lt;/h2>
&lt;p>You debugged everything and created patches. Now who to send these patches to?&lt;/p>
&lt;p>One can use &lt;code>./scripts/get_maintainer.pl&lt;/code> to get the appropriate people and mailing lists to send the patch to.&lt;/p>
&lt;p>You can use the script name directly. It is big enough for me to create a simple bash alias, so here it is:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>kget-maintainers&lt;span style="color:#f92672">()&lt;/span> &lt;span style="color:#f92672">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ./scripts/get_maintainer.pl &lt;span style="color:#e6db74">&amp;#34;&lt;/span>$@&lt;span style="color:#e6db74">&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>One can extend this into &lt;code>ksend-patch&lt;/code> which can parse the &lt;code>get_maintainer.pl&lt;/code> output and appropriately sets the &lt;code>to&lt;/code> and &lt;code>cc&lt;/code> arguments for &lt;code>git send-email&lt;/code>.&lt;/p>
&lt;hr>
&lt;p>That&amp;rsquo;s it for now. Hope you found this useful!&lt;/p>
&lt;div class="footnotes" role="doc-endnotes">
&lt;hr>
&lt;ol>
&lt;li id="fn:1">
&lt;p>
&lt;a
href="https://trainingportal.linuxfoundation.org/courses/a-beginners-guide-to-linux-kernel-development-lfd103"
target="_blank"
>A Beginner&amp;rsquo;s Guide to Linux Kernel Development (LFD103) - The Linux Foundation&lt;/a>&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:2">
&lt;p>
&lt;a
href="https://github.com/google/syzkaller/blob/master/docs/linux/setup_ubuntu-host_qemu-vm_x86-64-kernel.md"
target="_blank"
>https://github.com/google/syzkaller/blob/master/docs/linux/setup_ubuntu-host_qemu-vm_x86-64-kernel.md&lt;/a>&amp;#160;&lt;a href="#fnref:2" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&amp;#160;&lt;a href="#fnref1:2" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:3">
&lt;p>
&lt;a
href="https://github.com/google/syzkaller/blob/master/docs/linux/troubleshooting.md"
target="_blank"
>https://github.com/google/syzkaller/blob/master/docs/linux/troubleshooting.md&lt;/a>&amp;#160;&lt;a href="#fnref:3" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:4">
&lt;p>
&lt;a
href="https://www.kernel.org/doc/html/latest/admin-guide/sysctl/kernel.html#panic-on-unrecovered-nmi"
target="_blank"
>Documentation for /proc/sys/kernel/ — The Linux Kernel documentation&lt;/a>&amp;#160;&lt;a href="#fnref:4" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:5">
&lt;p>
&lt;a
href="https://wiki.qemu.org/Documentation/9psetup"
target="_blank"
>Documentation/9psetup - QEMU&lt;/a>&amp;#160;&lt;a href="#fnref:5" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&amp;#160;&lt;a href="#fnref1:5" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;/ol>
&lt;/div></content></item><item><title>Migrated some content</title><link>https://bodha.siddh.me/posts/2023/10/12/initial_quora_migration/</link><pubDate>Thu, 12 Oct 2023 21:16:27 +0530</pubDate><guid>https://bodha.siddh.me/posts/2023/10/12/initial_quora_migration/</guid><description>Initial migration of select content from other sources is complete.
Any posts before (below) this one are answers or posts I wrote on Quora. The DRM and KUnit intro is from my vain GSoC proposal (should have put more effort).
I&amp;rsquo;ve tried to correct any typos, fix up broken sentences and missing references, etc. without changing the content much. Still, I&amp;rsquo;m sorry if there are any citation etc. issues in the content, good referencing wasn&amp;rsquo;t something on the top of the mind for the teenage Quora user.</description><content>&lt;p>Initial migration of select content from other sources is complete.&lt;/p>
&lt;p>Any posts before (below) this one are answers or posts I wrote on Quora. The DRM and KUnit intro is from my vain GSoC proposal (should have put more effort).&lt;/p>
&lt;p>I&amp;rsquo;ve tried to correct any typos, fix up broken sentences and missing references, etc. without changing the content much. Still, I&amp;rsquo;m sorry if there are any citation etc. issues in the content, good referencing wasn&amp;rsquo;t something on the top of the mind for the teenage Quora user.&lt;/p>
&lt;p>Note: I&amp;rsquo;m no longer on Quora, the platform has gone down the drain. Before deleting my account, I requested all my data.&lt;/p></content></item><item><title>About</title><link>https://bodha.siddh.me/about/</link><pubDate>Sat, 27 May 2023 20:07:10 +0530</pubDate><guid>https://bodha.siddh.me/about/</guid><description>Hi there! I&amp;rsquo;m Siddh, and this is my personal blog where I will write randomly about random stuff. Views are my own, and does not necessarily reflect that of anyone else.
Find or contact me at: GitHub • GitLab • Email • Matrix • OFTC (siddh)
What does &amp;ldquo;bodha&amp;rdquo; mean? Bodha (बोध) is a Sanskrit word which can mean idea, thought, understanding, knowing, perception, conciousness, intelligence, reflection, etc. (you get the point).</description><content>&lt;h1 id="hi-there">Hi there!&lt;/h1>
&lt;p>I&amp;rsquo;m Siddh, and this is my personal blog where I will write randomly about random stuff. Views are my own, and does not necessarily reflect that of anyone else.&lt;/p>
&lt;p>Find or contact me at:
&lt;a
href="https://github.com/siddhpant"
target="_blank"
>GitHub&lt;/a> •
&lt;a
href="https://gitlab.com/siddhpant"
target="_blank"
>GitLab&lt;/a> •
&lt;a
href="https://siddh.me/email_me"
target="_blank"
>Email&lt;/a> •
&lt;a
href="https://matrix.to/#/@siddhpant:matrix.org"
target="_blank"
>Matrix&lt;/a> • OFTC (siddh)&lt;/p>
&lt;hr>
&lt;h1 id="what-does-bodha-mean">What does &amp;ldquo;bodha&amp;rdquo; mean?&lt;/h1>
&lt;p>Bodha (बोध) is a Sanskrit word which can mean idea, thought, understanding, knowing, perception, conciousness, intelligence, reflection, etc. (you get the point). Check out the dictionaries here:
&lt;a
href="https://www.learnsanskrit.cc/translate?search=bodha&amp;amp;dir=se"
target="_blank"
>learnsanskrit.cc&lt;/a>,
&lt;a
href="https://ambuda.org/tools/dictionaries/mw,shabdasagara,apte,vacaspatyam,shabdakalpadruma,amara,apte-sh,shabdartha-kaustubha/bodha"
target="_blank"
>Ambuda&lt;/a>.&lt;/p>
&lt;p>Hence, this is a cool name for this blog. I will post here whenever I learn something new or share my thoughts.&lt;/p>
&lt;hr>
&lt;h1 id="license">License&lt;/h1>
&lt;p>&lt;img src="https://bodha.siddh.me/about/index.assets/cc-by-sa.svg">&lt;/p>
&lt;p>The contents and posts in this blog are licensed under a
&lt;a
href="http://creativecommons.org/licenses/by-sa/4.0/"
target="_blank"
>Creative Commons Attribution-ShareAlike 4.0 International License&lt;/a>, unless otherwise stated.&lt;/p>
&lt;p>The full text of the license can also be accessed in the content repo.&lt;/p>
&lt;h1 id="sources">Sources&lt;/h1>
&lt;ul>
&lt;li>Content repo:
&lt;a
href="https://github.com/siddhpant/bodha/"
target="_blank"
>https://github.com/siddhpant/bodha/&lt;/a> (CC-BY-SA 4.0)&lt;/li>
&lt;li>Theme (fork):
&lt;a
href="https://github.com/siddhpant/hugo-theme-terminal/"
target="_blank"
>https://github.com/siddhpant/hugo-theme-terminal/&lt;/a> (MIT)&lt;/li>
&lt;li>Website root:
&lt;a
href="https://github.com/siddhpant/siddhpant.github.io/"
target="_blank"
>https://github.com/siddhpant/siddhpant.github.io/&lt;/a> (AGPLv3)&lt;/li>
&lt;/ul>
&lt;h1 id="credits">Credits&lt;/h1>
&lt;p>Powered by
&lt;a
href="https://gohugo.io/"
target="_blank"
>Hugo&lt;/a>.
&lt;a
href="https://github.com/panr/hugo-theme-terminal"
target="_blank"
>Theme&lt;/a> made by
&lt;a
href="https://github.com/panr"
target="_blank"
>panr&lt;/a>.&lt;/p>
&lt;hr></content></item><item><title>Search</title><link>https://bodha.siddh.me/search/</link><pubDate>Sat, 27 May 2023 20:07:10 +0530</pubDate><guid>https://bodha.siddh.me/search/</guid><description>Under Construction I&amp;rsquo;m not a web dev, and so I need to take out time and find a good solution for search which does not force me to do too many changes.
And I want to avoid installing the following npm hell:</description><content>&lt;h1 id="under-construction">Under Construction&lt;/h1>
&lt;p>I&amp;rsquo;m not a web dev, and so I need to take out time and find a good solution for search which does not force me to do too many changes.&lt;/p>
&lt;p>And I want to avoid installing the following npm hell:&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/search/index.assets/npm_hell.png">&lt;/p>
&lt;hr></content></item><item><title>High level introduction to KUnit</title><link>https://bodha.siddh.me/posts/2023/04/04/intro_to_kunit/</link><pubDate>Tue, 04 Apr 2023 00:00:00 +0000</pubDate><guid>https://bodha.siddh.me/posts/2023/04/04/intro_to_kunit/</guid><description>KUnit is a unit testing framework for the Linux kernel. It is inspired by other x-unit testing frameworks (JUnit, Python unittest). According to Brendan Higgins (the author of KUnit) at LPC2019, the need for yet another framework is because other frameworks have their own style and conventions, which does not match kernel conventions. Since the kernel community is huge and telling everyone to change their conventions is a laborious idea, KUnit was made specifically to cater to kernel standards and usage.</description><content>&lt;p>KUnit is a unit testing framework for the Linux kernel. It is inspired by other x-unit testing frameworks (JUnit, Python unittest). According to
&lt;a
href="https://www.youtube.com/watch?v=507n-t0sfcU"
target="_blank"
>Brendan Higgins (the author of KUnit) at LPC2019&lt;/a>, the need for yet another framework is because other frameworks have their own style and conventions, which does not match kernel conventions. Since the kernel community is huge and telling everyone to change their conventions is a laborious idea, KUnit was made specifically to cater to kernel standards and usage.&lt;/p>
&lt;p>Further, quoting Brendan again:&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Tests are also documentation. Documentation gets stale. Tests don&amp;rsquo;t. Tests show how code behaves.&lt;/strong>&lt;/p>
&lt;p>~ Brendan Higgins in
&lt;a
href="https://www.youtube.com/watch?v=i0xrfn5PSsM"
target="_blank"
>an LF Mentorship session&lt;/a>.&lt;/p>
&lt;/blockquote>
&lt;p>So unit testing also provides a degree of documentation, by documenting how a unit behaves and what are its interfaces.&lt;/p>
&lt;p>KUnit works by running tests when the kernel is run. The tests are compiled into the kernel binary, and the kernel basically self-tests itself on boot. The test results are reported in dmesg logs in a format known as Kernel Test Anything Protocol (KTAP).&lt;/p>
&lt;p>While KTAP is sorta human readable, it is not pretty for our eyes. The &lt;code>kunit_tool&lt;/code> Python script (&lt;code>tools/testing/kunit/kunit.py&lt;/code>) can be used to parse KTAP outputs into a nice colour-formatted text on a terminal. &lt;code>kunit_tool&lt;/code> can handle building the kernel, running the tests, and reporting the results all in one go automatically, so it is a very handy tool. Unfortunately, it does not support gcc-7 and higher, one has to use gcc-6 or llvm.&lt;/p>
&lt;p>Tests in KUnit are written as a function known as test case. Each test case has several &amp;ldquo;expectations&amp;rdquo; and &amp;ldquo;assertions&amp;rdquo; on how the code should behave. These expectations are nothing but macros like &lt;code>KUNIT_EXPECT_EQ&lt;/code>, &lt;code>KUNIT_EXPECT_NULL&lt;/code>, &lt;code>KUNIT_ASSERT_EQ&lt;/code>, etc. The difference between an &lt;code>ASSERT&lt;/code> and an &lt;code>EXPECT&lt;/code> is that the former will stop the test case when it fails, while the latter does not. The result will be a fail in both cases though. The
&lt;a
href="https://docs.kernel.org/dev-tools/kunit/usage.html"
target="_blank"
>documentation&lt;/a> consists of various simple examples, such as below (comments are mine):&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-c" data-lang="c">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">/*
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"> * Test basics of an add() function.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"> *
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"> * struct kunit represents instance of a test.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"> * It is defined in /include/kunit/test.h.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"> */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">void&lt;/span> &lt;span style="color:#a6e22e">add_test_basic&lt;/span>(&lt;span style="color:#66d9ef">struct&lt;/span> kunit &lt;span style="color:#f92672">*&lt;/span>test)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e">/*
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"> * Testing 1 + 0 = 1.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"> * Expected output = 1.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"> * Function call to test = add(1, 0).
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"> *
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"> * KUNIT_EXPECT_EQ checks if both are equal.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"> * Order does not matter here.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"> */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">KUNIT_EXPECT_EQ&lt;/span>(test, &lt;span style="color:#ae81ff">1&lt;/span>, &lt;span style="color:#a6e22e">add&lt;/span>(&lt;span style="color:#ae81ff">1&lt;/span>, &lt;span style="color:#ae81ff">0&lt;/span>));
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e">/* Testing 1 + 1 = 2 similarly. */&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#a6e22e">KUNIT_EXPECT_EQ&lt;/span>(test, &lt;span style="color:#ae81ff">2&lt;/span>, &lt;span style="color:#a6e22e">add&lt;/span>(&lt;span style="color:#ae81ff">1&lt;/span>, &lt;span style="color:#ae81ff">1&lt;/span>));
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The structure of KUnit&amp;rsquo;s test collection is referred to as a test suite. It contains the following:&lt;/p>
&lt;ol>
&lt;li>&lt;code>name&lt;/code>: The name of the test suite.&lt;/li>
&lt;li>&lt;code>test_cases&lt;/code>: An array of &lt;code>struct kunit_case&lt;/code>, which encapsulates the test cases.&lt;/li>
&lt;li>&lt;code>init&lt;/code>: Setup/ctor function to run before every test case.&lt;/li>
&lt;li>&lt;code>exit&lt;/code>: Teardown/dtor function to run after every test case.&lt;/li>
&lt;li>&lt;code>suite_init&lt;/code>: Setup/ctor function for the test suite (gets executed first).&lt;/li>
&lt;li>&lt;code>suite_exit&lt;/code>: Teardown/dtor function for the test suite (gets executed last).&lt;/li>
&lt;/ol>
&lt;p>The test files are meant to be housed alongside the code it tests, or in a folder named &lt;code>tests&lt;/code>. The convention for the test files in DRM core seems to be &lt;code>tests/&amp;lt;name&amp;gt;_test.c&lt;/code>.&lt;/p></content></item><item><title>High level introduction to DRM subsystem</title><link>https://bodha.siddh.me/posts/2023/04/03/intro_to_dri/</link><pubDate>Mon, 03 Apr 2023 00:00:00 +0000</pubDate><guid>https://bodha.siddh.me/posts/2023/04/03/intro_to_dri/</guid><description>About DRM subsystem Direct Rendering Manager is very central from the point of view of usability — it is the subsystem responsible for showing what is on our screen, including this post. As such, it is directly responsible for enabling the wide adoption of Linux distros, and is what the user is visibly impacted by.
The DRM subsystem is populated largely by display drivers mainly maintained by the companies who make GPUs.</description><content>&lt;h2 id="about-drm-subsystem">About DRM subsystem&lt;/h2>
&lt;p>Direct Rendering Manager is very central from the point of view of usability — it is &lt;em>&lt;strong>the&lt;/strong>&lt;/em> subsystem responsible for showing what is on our screen, including this post. As such, it is directly responsible for enabling the wide adoption of Linux distros, and is what the user is visibly impacted by.&lt;/p>
&lt;p>The DRM subsystem is populated largely by display drivers mainly maintained by the companies who make GPUs. The &lt;code>drivers/gpu/drm&lt;/code> directory consisting of various drivers for various vendors and devices can be seen on nautilus as below:&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2023/04/03/intro_to_dri/index.assets/drm_files.png">&lt;/p>
&lt;p>Thus, in order to incorporate drivers for different hardware in the kernel, we can&amp;rsquo;t have driver authors churn out duplicate code for the same thing, and want a standardised hardware-independent interface to make lives easier and to have the codebase maintainable. This is fulfilled by the core of the DRM subsystem (&amp;ldquo;DRM core&amp;rdquo; henceforth) — the drivers are then left to manage the hardware-specific nitty-gritties and features.&lt;/p>
&lt;hr>
&lt;h2 id="drm-core-basics---what-and-why">DRM core basics - what and why&lt;/h2>
&lt;p>The DRM subsystem is responsible for the management of GPUs from kernelspace and interfacing them with userspace. It handles all the hardware resources, and allows for multiple programs to use the hardware unlike a giant superuser application providing an indirect interfacing (X server). DRM handles memory management, interrupt handlers, switching between GPUs (like between dGPU and iGPU), mode-setting, and rendering composition of frames.&lt;/p>
&lt;p>A &lt;strong>mode&lt;/strong> is a set of display properties like resolution, color depth, refresh rate, etc. A part of the DRM subsystem known as Kernel Mode Setting (KMS) is responsible for setting the mode and rendering frames on the screen. &lt;u>The working can be boiled down to the following:&lt;/u>&lt;/p>
&lt;p>The pixels to render are stored as frames in GPU&amp;rsquo;s memory buffers known as &lt;strong>framebuffers&lt;/strong>. DRM provides an abstraction to manage these framebuffers. A framebuffer is managed using a &amp;ldquo;&lt;strong>plane&lt;/strong>&amp;rdquo;, which handles cropping and scaling of the frames (so that we have scrolling and zooming).&lt;/p>
&lt;p>A screen may have multiple elements, and we might need to overlay frames on top of other frames (instead of redrawing everything). A good example is the mouse pointer. Thus, we need composition, as well as generate the data to send to the monitor for rendering. This is handled in hardware by &lt;strong>scanout buffers&lt;/strong>. In DRM lingo, they are (unfortunately in my opinion) known as &lt;strong>CRTC&lt;/strong> — from CRT (Cathode Ray Tube) Controller. It is &lt;em>not&lt;/em> related to controlling the magnetic fields in a typical CRT setup. This misleading term is a holdover from the old days when monitors were on CRT technology.&lt;/p>
&lt;p>The DRM CRTC abstraction allows for blending / composition of several planes, and outputs the frame which needs to be rendered on the screen. A chunk of modesetting is done in this part — from screen resolution to refresh rate. This is hence a &lt;strong>central part&lt;/strong> of DRM subsystem, as this is responsible for &lt;em>what&lt;/em> is finally shown on the screen.&lt;/p>
&lt;p>The scanout signals generated by CRTC then needs to travel to the screen over the PHY (the physical interface / wire connecting the GPU to screen). But the PHY&amp;rsquo;s interface (the &amp;ldquo;&lt;strong>connector&lt;/strong>&amp;rdquo; such as VGA, HDMI, etc.) may require the signal in a certain format. Thus, we need to encode the output from the CRTC before giving it to the connector. This is handled by the appropriately named &amp;ldquo;&lt;strong>encoder&lt;/strong>&amp;rdquo;. This also allows for abstraction of the PHY — CRTC code does not need to worry about the &lt;em>where&lt;/em> and &lt;em>how&lt;/em> the signal will travel.&lt;/p>
&lt;p>Schematically, the KMS display pipeline can be shown as follows (courtesy
&lt;a
href="https://dri.freedesktop.org/docs/drm/gpu/drm-kms.html#overview"
target="_blank"
>kernel docs&lt;/a>):&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2023/04/03/intro_to_dri/index.assets/kms_display_pipeline.svg">&lt;/p>
&lt;p>Originally, this needed several different commands to the kernel. This implies going through several different states (the states increase combinatorically with the number of commands). If we try to do an invalid setting, we will come to know of its invalidation only at the point the actual invalid command is sent. This can be after a chunk of setup being done already and rolling back may be impossible. This also yeilds visible &amp;ldquo;tearing&amp;rdquo; — the next frame may not have been rendered properly as refresh rate / VBLANK (time between rendering the last visible line of a frame and the first visible line of the next frame) synchronisation is not guaranteed. Composite frames may render layer-by-layer instead of together (i.e, no &amp;ldquo;perfect&amp;rdquo; frame).&lt;/p>
&lt;p>&amp;ldquo;Atomic mode-setting&amp;rdquo; allows for giving a configuration and having it verified by the driver. If the configuration requested by the program is invalid, the driver lets it know and does not do any changes. Only if the configuration is valid does the driver do any hardware operations. It also allows for perfect frame — allows for queuing multiple configurations and renders them together at the next VBLANK clock cycle.&lt;/p>
&lt;p>According to
&lt;a
href="https://archive.fosdem.org/2015/schedule/event/kms_atomic/"
target="_blank"
>Theirry Redding at FOSDEM 2015&lt;/a>, the interface parameters of stuff like CRTC, planes, etc. are converted to properties of an object. The whole state of hardware is thus encapsulated in atomic state objects. Whenever we want to modify something, we modify the properties of these atomic state objects instead of issuing the command to the hardware directly.&lt;/p>
&lt;p>This way, we can pile up several modifications into one object, and issue the final resultant modification to the hardware. Also, after modification the atomic object is checked whether its configuration is valid or not. If it is valid, only then the configuration is applied to the hardware at the next VBLANK clock cycle. Thus, drivers also don&amp;rsquo;t need to worry about synchronisation.&lt;/p>
&lt;hr>
&lt;h2 id="need-for-tests">Need for tests&lt;/h2>
&lt;p>Naturally, the DRM subsystem (like any other kernel subsystem) is huge. While the code is written and maintained by trustable and qualified kernel developers, such a huge codebase can benefit from hard statistics about its reliability by means of tests, as well as the architectural and behavioural documentation provided by having tests.&lt;/p>
&lt;p>DRM core is, as discussed, a crucial piece of infrastructure, and thus one would expect it to be reliably tested given the importance of enforcing standardisation upon competitive and fragmented market forces. Unfortunately, the core is largely untested, as can be seen in the following coverage report obtained using KUnit:&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2023/04/03/intro_to_dri/index.assets/drm_core_lcov_report.png">&lt;/p>
&lt;p>It is a general consensus in the community that this needs to change, and thus more tests need to be written. Due to the nature of DRM susbsystem, and kernel code in general, unit testing is a good way to go, and already has good support by way of KUnit, which I introduce in the next post.&lt;/p></content></item><item><title>Why don't they just make CPUs bigger and add more transistors so we can have 10 GHz?</title><link>https://bodha.siddh.me/posts/2022/09/02/why_dont_they_just_make_cpus_bigger_and_add_more_transistors_so_we_can_have_10_ghz/</link><pubDate>Fri, 02 Sep 2022 00:00:00 +0000</pubDate><guid>https://bodha.siddh.me/posts/2022/09/02/why_dont_they_just_make_cpus_bigger_and_add_more_transistors_so_we_can_have_10_ghz/</guid><description>Because they don&amp;rsquo;t work on magic. Some points are as below:
It is very hard to build larger chips while maintaining good yeild, i.e., having less defects. When you scale your design up, with more transistors, interconnects, etc., the probability of defects increases. And since the entire chip has to work, your yeild is less as your chip is larger and you can&amp;rsquo;t discard a part of it, so you discard it all.</description><content>&lt;p>Because they don&amp;rsquo;t work on magic. Some points are as below:&lt;/p>
&lt;ul>
&lt;li>It is very hard to build larger chips while maintaining good yeild, i.e., having less defects. When you scale your design up, with more transistors, interconnects, etc., the probability of defects increases. And since the entire chip has to work, your yeild is less as your chip is larger and you can&amp;rsquo;t discard a part of it, so you discard it all.&lt;/li>
&lt;li>Higher clock frequency will cause more power dissipation, so your chip heats up more, and your electricity bill shoots up.&lt;/li>
&lt;li>With so many transistors working, power dissipation will increase massively!&lt;/li>
&lt;li>Power dissipation is the main reason — you will fry your chip! Dissipating heat from dense pockets in the chips is very challenging.&lt;/li>
&lt;li>With so many transistors, your capacitance will increase as every transistor has an associated gate capacitance, causing an increase in rise and fall times if the circuits aren&amp;rsquo;t modular enough.&lt;/li>
&lt;li>If you want faster circuit, you should increase transistor size for a given load capacitance. But increasing size also increases capacitance, so you would need to reduce the transistor count.&lt;/li>
&lt;li>But the capacitance increases due to interconnects now far overshadow that of transistor, and dominates. And you cannot not have interconnects!&lt;/li>
&lt;li>It would be very hard to distribute the 10 GHz clock in the circuit, and routing in general, especially when you are adding more transistors.&lt;/li>
&lt;li>Digital logic operating at 10 GHz would need to switch the states at that speed, which is hard to make.&lt;/li>
&lt;/ul></content></item><item><title>The curious mouse click</title><link>https://bodha.siddh.me/posts/2022/08/26/the_curious_mouse_click/</link><pubDate>Fri, 26 Aug 2022 00:00:00 +0000</pubDate><guid>https://bodha.siddh.me/posts/2022/08/26/the_curious_mouse_click/</guid><description>A fine 45°C May afternoon, with no one to disturb in a room with ceiling fan at full speed and a window AC, was the perfect opportunity for me to study for my upcoming offline end-semester examinations with books on the table at the window. Of course, after studying for quite some time, a break is needed, and I probably took a short break of just 3 hours.
While goofing off on the internet, I came across the Linux Kernel Mentorship Program (LKMP), which is described1 as:</description><content>&lt;p>A fine 45°C May afternoon, with no one to disturb in a room with ceiling fan at full speed and a window AC, was the perfect opportunity for me to study for my upcoming offline end-semester examinations with books on the table at the window. Of course, after studying for quite some time, a break is needed, and I probably took a short break of just 3 hours.&lt;/p>
&lt;p>While goofing off on the internet, I came across the &lt;strong>Linux Kernel Mentorship Program&lt;/strong> (LKMP), which is described&lt;sup id="fnref:1">&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref">1&lt;/a>&lt;/sup> as:&lt;/p>
&lt;blockquote>
&lt;p>The Linux Kernel Mentorship Program offers a structured remote learning opportunity to aspiring Linux Kernel developers. Experienced Linux Kernel developers and maintainers mentor volunteer mentees and help them become contributors to the Linux Kernel.&lt;/p>
&lt;/blockquote>
&lt;p>Being a long time Linux user, this seemed like a good opportunity to work on something which I use everyday, coupled with my affinity towards low-level side of things which I wanted to explore and work on. So I decided to at least take a look at the registration process, as the looming threat of an academic massacre&lt;sup id="fnref:2">&lt;a href="#fn:2" class="footnote-ref" role="doc-noteref">2&lt;/a>&lt;/sup> in the June exam was preventing me from freely thinking about applying.&lt;/p>
&lt;p>The first thing to do was to register on the LFX platform&lt;sup id="fnref:3">&lt;a href="#fn:3" class="footnote-ref" role="doc-noteref">3&lt;/a>&lt;/sup>, which was not exclusive to LKMP and had a multitude of mentorship programs (touching various fields) being hosted there. After making a profile on the platform by filling suspiciously&lt;sup id="fnref:4">&lt;a href="#fn:4" class="footnote-ref" role="doc-noteref">4&lt;/a>&lt;/sup> detailed fields, and searching for what I was looking for, I came across &lt;strong>Linux Kernel Bug Fixing Summer 2022&lt;/strong>&lt;sup id="fnref:5">&lt;a href="#fn:5" class="footnote-ref" role="doc-noteref">5&lt;/a>&lt;/sup>, which had this noticeably big button:&lt;/p>
&lt;p>&lt;img alt="BIG APPLY BUTTON" src="https://bodha.siddh.me/posts/2022/08/26/the_curious_mouse_click/index.assets/apply_button.png">&lt;/p>
&lt;p>I thought &amp;ldquo;&lt;em>let&amp;rsquo;s see how the confirmation page looks like&lt;/em>&amp;rdquo;, and I aimlessly clicked it…&lt;/p>
&lt;p>And it immediately enrolled me. Nothing asked — it just directly led me to the screening tasks.&lt;/p>
&lt;p>&lt;img alt="BIG OOF" src="https://bodha.siddh.me/posts/2022/08/26/the_curious_mouse_click/index.assets/big_oof.gif">&lt;/p>
&lt;hr>
&lt;p>Now that I was into it by my own choice, there is no going back. The screening tasks needed to be completed in a week or so, as the applications were closing on the 18th (&lt;em>maybe I should have goofed off more often&lt;/em>).&lt;/p>
&lt;p>The screening tasks themselves were a good opportunity to learn things, doing which I learnt about the basics of kernel development. Completing the LFD103&lt;sup id="fnref:6">&lt;a href="#fn:6" class="footnote-ref" role="doc-noteref">6&lt;/a>&lt;/sup> course was also a task, and almost all the other tasks were actually related to what I learnt from the online course. I compiled the Linux kernel for the first time on my own machine and booted into it natively, a small step in the journey, &lt;em>yet a very significant one&lt;/em>. After some experimenting, I quickly realised I can&amp;rsquo;t keep rebooting every time I make changes to the kernel (also secure boot needs to be turned off), so I came across QEMU and KVM, which is very convenient.&lt;/p>
&lt;p>QEMU&lt;sup id="fnref:7">&lt;a href="#fn:7" class="footnote-ref" role="doc-noteref">7&lt;/a>&lt;/sup> is a virtualiser and emulator, which can emulate many different CPU architecture and topologies. Using hypervisors, it can emulate the instructions of the virtual machines directly, which yields a performance close to your hardware. If you know about Oracle&amp;rsquo;s VirtualBox, you can think QEMU as a faster, better, more configurable, more extensive version of it. QEMU literally pwns VirtualBox. You can run a virtual machine with full-blown OS with the userspace UI and everything, or you can just boot into a minimal configuration using the terminal, which is exactly what you want for kernel development.&lt;/p>
&lt;p>&lt;img alt="Acceptance email screenshot" src="https://bodha.siddh.me/posts/2022/08/26/the_curious_mouse_click/index.assets/acceptance_email.jpg">&lt;/p>
&lt;p>Towards the end of May, I got selected as a mentee&lt;sup id="fnref:8">&lt;a href="#fn:8" class="footnote-ref" role="doc-noteref">8&lt;/a>&lt;/sup> in the program along with 12 others. The mentors were Shuah Khan, an experienced kernel developer, maintainer, and contributor; and Pavel Skripkin, who is also experienced with the kernel and its internals. Shuah maintains Kernel Selftest (&lt;code>kselftest&lt;/code>), USB over IP, and &lt;code>cpupower&lt;/code> tools, and is a veteran. Pavel has also contributed to other kernel related projects like smatch and syzkaller.&lt;/p>
&lt;hr>
&lt;p>I was free to choose any bug I wanted to work upon. But before that, some specific prerequisite knowledge needs to be there, and thus there were initial tasks around learning kernel event tracing&lt;sup id="fnref:9">&lt;a href="#fn:9" class="footnote-ref" role="doc-noteref">9&lt;/a>&lt;/sup>, dynamic program analysis, fuzzing, etc.&lt;/p>
&lt;p>It is useful to know, during runtime, what is happening and executing, which route did the kernel take, what events are triggered, etc. Thus, tracing the events is a good way to debug bugs, as one can see what is happening when the bug gets triggered. Many different event tracers are available, and &lt;code>function_graph&lt;/code> is particularly helpful as it shows the call stack in a structured way, showing which kernel &lt;em>functions&lt;/em> are executed, along with any context switches which happen. A small sample is:&lt;/p>
&lt;pre tabindex="0">&lt;code> 1) ! 611.961 us | hci_uart_tty_open();
1) | hci_uart_tty_ioctl() {
1) | hci_alloc_dev_priv() {
1) 2.832 us | hci_cmd_sync_init();
1) 8.267 us | hci_request_setup();
1) + 15.134 us | hci_init_sysfs();
1) ! 164.203 us | }
1) | hci_register_dev() {
0) | hci_uart_tty_open() {
&lt;/code>&lt;/pre>&lt;p>Analysis is needed for detecting bugs. Bugs are of a serious concern as they introduce unintended consequences, like program crash, security issues, reducing the quality of code/program, etc. Hunting bugs at a later stage tends to be more costly as some other person has to have a good look at everything again.&lt;/p>
&lt;p>Thus, we should try to find and squash bugs as much as possible before releasing the program to the users. Analysis of program help us in doing that. Broadly, there are two ways employed for analysing the behaviour of programs:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Static analysis&lt;/strong>, wherein we analyse the program&amp;rsquo;s code (usually source code, but one can do analysis of machine code too) and look out for bugs. For instance, a hard-coded out-of-bound bug can be detected using static analysis. The analysis is thus consequently done on properties which will hold for all executions of the program.&lt;/li>
&lt;li>&lt;strong>Dynamic analysis&lt;/strong>, wherein we analyse the program&amp;rsquo;s execution when it is running. For instance, we may have an out-of-bound bug due to dynamic access. That can be easily detected using dynamic analysis compared to static analysis. The analysis is thus consequently done on properties which holds just for that single run of program.&lt;/li>
&lt;/ol>
&lt;p>The analysis of bugs and their subsequent reporting can be classified into two types:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>True positive&lt;/strong>: The bug report is correct, i.e., the behaviour is indeed a bug.&lt;/li>
&lt;li>&lt;strong>False positive&lt;/strong>: The bug report is incorrect, i.e., the behaviour is not a bug and is intended. These are the &lt;em>type-1 errors&lt;/em> in statistical parlance. (Thus, &lt;em>type-2 errors&lt;/em> are just the undetected bugs.)&lt;/li>
&lt;/ol>
&lt;p>From basic statistical and/or practical engineering knowledge, we can infer there must be a trade-off, especially in static analysis, between increasing the number of true positive reports and reducing the number of false positive reports.&lt;/p>
&lt;p>With dynamic analysis, we catch unintended behaviour (like use-after-free or out-of-bound access) at runtime, and hence we are &lt;em>typically&lt;/em> getting no (i.e., zero) false positives. The trade-off comes into play with the fact that these bugs must be triggered during execution in order to detect them. Untriggered bugs are not detected, and thus code coverage is an important metric.&lt;/p>
&lt;p>It has consequently been observed that:&lt;/p>
&lt;ul>
&lt;li>Static analysis may report comparatively more true positives, but they will also report a number of false positives.&lt;/li>
&lt;li>Dynamic analysis may report comparatively lesser true positives, but will report less false positives.&lt;/li>
&lt;/ul>
&lt;p>Analysis can be run in user-space or in kernel-space. Linux kernel allows us to run debugging in kernel-space. Compilers like &lt;code>clang&lt;/code> and &lt;code>gcc&lt;/code>, and tools like &lt;code>coccinelle&lt;/code>&lt;sup id="fnref:10">&lt;a href="#fn:10" class="footnote-ref" role="doc-noteref">10&lt;/a>&lt;/sup> allow for the static analysis of the codebase. Tools like &lt;code>KASAN&lt;/code>&lt;sup id="fnref:11">&lt;a href="#fn:11" class="footnote-ref" role="doc-noteref">11&lt;/a>&lt;/sup>, syzkaller&lt;sup id="fnref:12">&lt;a href="#fn:12" class="footnote-ref" role="doc-noteref">12&lt;/a>&lt;/sup>, etc. help in dynamic analysis of the kernel at runtime.&lt;/p>
&lt;p>Also, there is the superiorest technique of adding print (&lt;code>pr_info&lt;/code>) statements, though they should be added judiciously as sometimes they may interfere in the racing if one is examining race conditions.&lt;/p>
&lt;hr>
&lt;p>In addition to off-the-record conversations with mentors and the mentee peer group, there were also bi-weekly Zoom meetings with Shuah and Pavel, which were very helpful, and helped in learning a lot and solving some doubts. Having a peer group or/and someone to guide is valuable, whoever they may be, since it steers/motivates us in the right direction.&lt;/p>
&lt;p>Linux kernel development happens over email (you can see archives online&lt;sup id="fnref:13">&lt;a href="#fn:13" class="footnote-ref" role="doc-noteref">13&lt;/a>&lt;/sup>), and not something like GitHub or GitLab&lt;sup id="fnref:14">&lt;a href="#fn:14" class="footnote-ref" role="doc-noteref">14&lt;/a>&lt;/sup>. One might think it is because the kernel predates these services (which is true) but should now &amp;ldquo;upgrade&amp;rdquo; to newer technologies. But one must keep in mind the sheer volume and size of the kernel: thousands of contributors are there, the kernel has more than 1.1 lakh commits, and all of this must be accessible with least friction. Email is a ubiquitous protocol, and not a locked-in service by some specific company, and thus it provides the least barrier to jump into sending patches (Signing up to see? What&amp;rsquo;s that?). The alternatives doesn&amp;rsquo;t scale for the sheer size of kernel contributions, and mostly can&amp;rsquo;t be accessed offline. Email also helps in decentralization like git.&lt;/p>
&lt;hr>
&lt;p>The syzkaller dashboard&lt;sup id="fnref:15">&lt;a href="#fn:15" class="footnote-ref" role="doc-noteref">15&lt;/a>&lt;/sup> is the place (along with the &lt;code>syzkaller-bugs&lt;/code> mailing list) where we can find bugs reported by syzbot after fuzzing the Linux kernel. If you want to find bugs to fix, this currently should be your go-to-place to find some.&lt;/p>
&lt;p>&lt;img alt="Screenshot of syzkaller dashboard" src="https://bodha.siddh.me/posts/2022/08/26/the_curious_mouse_click/index.assets/syzkaller_dashboard.png">&lt;/p>
&lt;p>Syzbot reports bugs and provides the kernel config and a reproducer which triggered the bug, so you can reproduce the bug locally on your machine. It also provides helpful patch testing facility by email, which you can use to verify if your fix works for the bot too.&lt;/p>
&lt;p>I had looked at and touched a number of subsystems during the course of my mentorship. The internals of Linux kernel was explored in the process. Of course, initially it was overwhelming (since I had never done this), but over time I learnt how to go about looking at the right places. As the debugging skills improved, I gained more confidence into fixing a bug and eventually sent patches upstream, fixing bugs reported by syzbot and static analysers.&lt;/p>
&lt;p>I fixed bugs related to things like race conditions (use-after-free and null-pointer dereference), logical problems causing warnings to be triggered, things pointed out by static analysis tools and docs.&lt;/p>
&lt;p>As of 26th August, I have 6 patches accepted, some are waiting for review, and some have been rejected. I have also contributed to the stable kernel (i.e. patch gets backported to the &amp;ldquo;stable&amp;rdquo; LTS kernel). The code review on mailing list is direct and to-the-point, and people are very helpful and don&amp;rsquo;t differentiate whether you are a beginner or not.&lt;/p>
&lt;p>You can search for me in kernel git on
&lt;a
href="https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/?qt=grep&amp;amp;q=Siddh&amp;#43;Raman&amp;#43;Pant"
target="_blank"
>https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/?qt=grep&amp;q=Siddh+Raman+Pant&lt;/a>, and can find my mailing list activity on
&lt;a
href="https://lore.kernel.org/all/?q=Siddh&amp;#43;Raman&amp;#43;Pant"
target="_blank"
>https://lore.kernel.org/all/?q=Siddh+Raman+Pant&lt;/a>.&lt;/p>
&lt;p>Three months ago, I never imagined I would be able to do this. It has been a very good learning experience! That one aimlessly curious mouse click resulted in a rabbit hole.&lt;/p>
&lt;hr>
&lt;p>The point&lt;sup id="fnref:16">&lt;a href="#fn:16" class="footnote-ref" role="doc-noteref">16&lt;/a>&lt;/sup> of this post is to encourage the reader to contribute to the Linux kernel.&lt;/p>
&lt;p>We use the kernel everyday, in various forms you might even be unaware of, and the kernel comes for free, as in free lunch, so why not contribute back upstream, whatever the little we can? I&amp;rsquo;m certainly not telling to sell your soul for this, even just observing the working helps. This is the sort of thing where you can learn a lot of interdisciplinary things whatever your field be, and your work &lt;em>will&lt;/em> actually have an impact!&lt;/p>
&lt;p>&lt;strong>When you will update and use Linux, code I have contributed will also run on &lt;em>your&lt;/em> computer and devices!&lt;/strong>&lt;/p>
&lt;p>Isn&amp;rsquo;t that cool™? If it is, what are you waiting for?&lt;/p>
&lt;hr>
&lt;p>I am migrating select content from my Quora account to this blog. This post is part of the same migration, with some minimal changes done. Also, this same post was also posted by me on LinkedIn.&lt;/p>
&lt;p>I also spoke about my mentorship on LFXMS 2023. Slides can be downloaded from
&lt;a
href="https://siddh.me/from_clueless_to_confident.pdf"
target="_blank"
>https://siddh.me/from_clueless_to_confident.pdf&lt;/a>. Let me know your thoughts in the comment section below!&lt;/p>
&lt;div class="footnotes" role="doc-endnotes">
&lt;hr>
&lt;ol>
&lt;li id="fn:1">
&lt;p>
&lt;a
href="https://wiki.linuxfoundation.org/lkmp"
target="_blank"
>https://wiki.linuxfoundation.org/lkmp&lt;/a>&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:2">
&lt;p>92% of class failed in a mid-sem after colleges re-opened, truly an online student moment. Though, it arguably was the hardest semester, with some of the hardest yet very interesting core subjects.&amp;#160;&lt;a href="#fnref:2" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:3">
&lt;p>
&lt;a
href="https://mentorship.lfx.linuxfoundation.org/"
target="_blank"
>https://mentorship.lfx.linuxfoundation.org/&lt;/a>&amp;#160;&lt;a href="#fnref:3" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:4">
&lt;p>The details are probably used for application to the programs, as evident by the one-click application I experienced.&amp;#160;&lt;a href="#fnref:4" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:5">
&lt;p>
&lt;a
href="https://mentorship.lfx.linuxfoundation.org/project/8bdac7b8-403f-489d-8999-ed16bca09cd2"
target="_blank"
>https://mentorship.lfx.linuxfoundation.org/project/8bdac7b8-403f-489d-8999-ed16bca09cd2&lt;/a>&amp;#160;&lt;a href="#fnref:5" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:6">
&lt;p>
&lt;a
href="https://trainingportal.linuxfoundation.org/learn/course/a-beginners-guide-to-linux-kernel-development-lfd103/course-introduction/course-information"
target="_blank"
>https://trainingportal.linuxfoundation.org/learn/course/a-beginners-guide-to-linux-kernel-development-lfd103/course-introduction/course-information&lt;/a>&amp;#160;&lt;a href="#fnref:6" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:7">
&lt;p>
&lt;a
href="https://www.qemu.org"
target="_blank"
>https://www.qemu.org&lt;/a>&amp;#160;&lt;a href="#fnref:7" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:8">
&lt;p>For the period of June start to August end.&amp;#160;&lt;a href="#fnref:8" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:9">
&lt;p>
&lt;a
href="https://www.kernel.org/doc/html/latest/trace/events.html"
target="_blank"
>https://www.kernel.org/doc/html/latest/trace/events.html&lt;/a>&amp;#160;&lt;a href="#fnref:9" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:10">
&lt;p>
&lt;a
href="https://www.kernel.org/doc/html/latest/dev-tools/coccinelle.html"
target="_blank"
>https://www.kernel.org/doc/html/latest/dev-tools/coccinelle.html&lt;/a>&amp;#160;&lt;a href="#fnref:10" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:11">
&lt;p>
&lt;a
href="https://www.kernel.org/doc/html/latest/dev-tools/kasan.html"
target="_blank"
>https://www.kernel.org/doc/html/latest/dev-tools/kasan.html&lt;/a>&amp;#160;&lt;a href="#fnref:11" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:12">
&lt;p>
&lt;a
href="https://github.com/google/syzkaller"
target="_blank"
>https://github.com/google/syzkaller&lt;/a>&amp;#160;&lt;a href="#fnref:12" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:13">
&lt;p>
&lt;a
href="https://lore.kernel.org/"
target="_blank"
>https://lore.kernel.org/&lt;/a>&amp;#160;&lt;a href="#fnref:13" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:14">
&lt;p>Current email ecosystem also comes with its own problems (like patch series/conversation management), so subsystems like DRI are moving towards self-hosted GitLab instances (since GitLab has an open-sourced version unlike GitHub).&amp;#160;&lt;a href="#fnref:14" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:15">
&lt;p>
&lt;a
href="https://syzkaller.appspot.com/upstream"
target="_blank"
>https://syzkaller.appspot.com/upstream&lt;/a>&amp;#160;&lt;a href="#fnref:15" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:16">
&lt;p>Also written because I want to put this out somewhere while it is fresh on my mind.&amp;#160;&lt;a href="#fnref:16" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;/ol>
&lt;/div></content></item><item><title>What is the difference between Hindi spelled हिन्दी and हिंदी?</title><link>https://bodha.siddh.me/posts/2022/03/05/what_is_the_difference_between_hindi_spelled/</link><pubDate>Sat, 05 Mar 2022 00:00:00 +0000</pubDate><guid>https://bodha.siddh.me/posts/2022/03/05/what_is_the_difference_between_hindi_spelled/</guid><description>The former is the correct spelling. The dot (अनुस्वार) in latter is a lazy way of writing first. Ignore any X language vs Y language arguments, since you write languages in a script, and both X and Y are using the same script.
The last letter of each varga (ङ, ञ, ण, न, म) is a nasal letter. Only that letter is a valid transcription of the nasal sound which comes before any letter of the same varga.</description><content>&lt;p>The former is the correct spelling. The dot (अनुस्वार) in latter is a lazy way of writing first. Ignore any X language vs Y language arguments, since you write languages in a script, and both X and Y are using the same script.&lt;/p>
&lt;hr>
&lt;p>The last letter of each varga (ङ, ञ, ण, न, म) is a nasal letter. Only that letter is a valid transcription of the nasal sound which comes before any letter of the same varga. It takes the least distance travelled by the tongue to pronounce those sounds, and you do that too, you just never knew about it.&lt;/p>
&lt;p>The dot is just a placeholder for all nasal sounds and is extremely contextual. Even more now when there is now an implicit n/m contextual heuristics applied by people.&lt;/p>
&lt;p>Another example: गंगा is a corrupted transcription. गङ्गा is the exactly correct form. Now notice when you pronounce it and compare it to the pronunciation of हिन्दी. Pay attention to how you are making the nasal sound.&lt;/p>
&lt;p>&lt;strong>Thus, using the dot everywhere mindlessly is loss of information for a phonetic script like Devanagari. It&amp;rsquo;s not a mere shortcut.&lt;/strong> The whole damn point of all Indian scripts is to be exact, in a “what you see is what you pronounce&amp;quot; fashion (WYSIWYP :-P).&lt;/p>
&lt;hr>
&lt;p>The conversion of dot to the letter is even given a specific name. It&amp;rsquo;s called परसवर्ण सन्धि. While I haven&amp;rsquo;t studied लघुसिद्धान्तकौमुदि, the relevant sutra can be found here:
&lt;a
href="https://ashtadhyayi.com/sutraani/lp115"
target="_blank"
>अनुस्वारस्य ययि परसवर्णः&lt;/a>.&lt;/p>
&lt;p>The dot should be used only in case of ending म् in word, or in cases like succeeding स (or anything in that varga, or basically those without the last nasal letter).&lt;/p>
&lt;hr>
&lt;p>The corruption is first by people initially, then exacerbated by shitty policy of Government of India, but now due to technological laziness and ignorance by American companies like Google and Facebook. Facebook is so lazy that it just defaults to adding a halant instead of making proper conjuncts. And why should they improve? They&amp;rsquo;re Americans first. They just want to be legible enough for their products to be used by people.&lt;/p>
&lt;p>And this is normalising, because Indians (or aptly called endians) are retarded, and are unable to read in their scripts and use their phones in their own languages. Then endians depend on transliteration tools and want to default to sloppy latin script and expect programs to convert it into native script, but are happy with inexact output (even the use of chandrabindu ( ँ ) is reducing because gboard doesn&amp;rsquo;t add it and defaults to… अनुस्वार, aka the dot). This then also creates a disincentive to create a better native keyboard, and this cycle propagates. FWIW, the tools like gboard are damn good roughly (yours truly also uses it) when compared to shitty keyboard designs of Devanagari, which then again fuels the cycle.&lt;/p>
&lt;p>At least people should use something like m17n&amp;rsquo;s mostly convenient implementation of ITRANS (on Linux), but then people don&amp;rsquo;t want to learn anything.&lt;/p></content></item><item><title>How did people count before the invention of the number 0?</title><link>https://bodha.siddh.me/posts/2020/12/27/how_did_people_count_before_the_invention_of_the_number_0/</link><pubDate>Sun, 27 Dec 2020 00:00:00 +0000</pubDate><guid>https://bodha.siddh.me/posts/2020/12/27/how_did_people_count_before_the_invention_of_the_number_0/</guid><description>You don&amp;rsquo;t need zero to count quantities. Zero is the “nothing” value&amp;rsquo;s symbol.
You just go about naming every number, like one, two, three, etc., and there&amp;rsquo;s no limit to it. This is how it used to be in India, which is unsurprisingly the land where the modern placeholder number system was invented.
Here&amp;rsquo;s a small note on the numbering system, given in Sri Desiraju Hanumanta Rao&amp;rsquo;s translation of Sarga 38, Kishkindha Kanda, Valmiki Ramayana:1</description><content>&lt;p>You don&amp;rsquo;t need zero to count quantities. Zero is the “nothing” value&amp;rsquo;s symbol.&lt;/p>
&lt;p>You just go about naming every number, like one, two, three, etc., and there&amp;rsquo;s no limit to it. This is how it used to be in India, which is unsurprisingly the land where the modern placeholder number system was invented.&lt;/p>
&lt;p>Here&amp;rsquo;s a small note on the numbering system, given in Sri Desiraju Hanumanta Rao&amp;rsquo;s translation of Sarga 38, Kishkindha Kanda, Valmiki Ramayana:&lt;sup id="fnref:1">&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref">1&lt;/a>&lt;/sup>&lt;/p>
&lt;hr>
&lt;p>In the Indian counting system hundred thousands becomes one lakh (1,00,000), one hundred lakhs become one crore (1,00,00,000). The ancient Indian legionaries have names like&lt;/p>
&lt;ul>
&lt;li>आयुत (aayuta) = ten thousand per unit&lt;/li>
&lt;li>शङ्कु (shanku) = one lakh crores, i.e., a trillion - 10&lt;sup>12&lt;/sup>&lt;/li>
&lt;li>अर्बुद (arbuda) = 1000 × शङ्कु&lt;/li>
&lt;li>मध्यम (madhyama) = 10 × अर्बुद&lt;/li>
&lt;li>अन्तम् (antam) = 10 × मध्यम&lt;/li>
&lt;li>समुद्र (samudra) = 20 × अन्त्य&lt;/li>
&lt;li>परार्ध (paraardha) = 30 × समुद्र&lt;/li>
&lt;/ul>
&lt;p>Rama Tilaka says that by giving these numbers it is to be understood that &amp;lsquo;innumerable vaanaras are coming&amp;hellip;&amp;rsquo; But others hold the view that the ancients have organised military pattern hence particular nomenclature is given to each, apart from the generalisation of Rama Tilaka.&lt;/p>
&lt;p>Govindaraja takes up the enumeration as given in Indian Astrology, which multiplies ten times each, as said in verse:&lt;/p>
&lt;blockquote>
&lt;p>एकम् दश शतम् अस्मात् सहस्रम् अयुतम् ततः परम् लक्षम् ।&lt;br>
प्रयुतम् कोटिम् अथ अर्बुदम् वृन्दे खर्वम् निखर्वम् च ।&lt;br>
तस्मात् महा सरोजम् शन्कुम् सरिताम् पतिम् त्वत् अन्तम् ।&lt;br>
मध्यम् पराधम् आरूह्य अथ उत्तरम् दश गुणम् तथा ज्ञेयम् ॥&lt;/p>
&lt;p>&amp;lsquo;one, ten, hundred, thousand, ten thousand, one lakh, प्रयुतम् (prayutam), ten lakhs or a million, then a crore and then an अर्बुद (arbuda) ten-crore or a billion, and then ten arbuda-s makes one बृन्द (bRnda) and ten brinda-s make one खर्व (kharva) and ten kharva-s make one निखर्व (nikharva) and ten nikharva-s make one महा पद्म (mahaa padma) and ten mahaa padma-s make one शङ्कु (shanku), one lakh crores or a trillion, and ten shanku-s make one समुद्र (samudra) and then ten samudra-s make one अन्त (anta) and ten anta-s make a मध्यम (madhyama) and ten madhyama-s make one परार्ध (paraardha) it may be known thus&amp;hellip;&lt;/p>
&lt;/blockquote>
&lt;p>By this, the nomenclature of million, billion and trillion was there in ancient days and this may be observed by the names: प्रयुतम् : &amp;lsquo;a million&amp;hellip;&amp;rsquo;, अर्बुद : &amp;lsquo;a billion..&amp;rsquo;, and शङ्कु : &amp;lsquo;a trillion&amp;hellip;&amp;rsquo;, and this exactly relates to the decimal system which is based on the number ten, in which the smaller units are related to the principal units as powers of ten (units, tens, hundreds, thousands, etc.).&lt;/p>
&lt;p>Don&amp;rsquo;t mistake this as just having words for the powers of ten. In Sanskrit (and other Indian languages, but we&amp;rsquo;re talking about ancient times here) one can make up a word for any number by following certain rules and compounding words.&lt;/p>
&lt;p>This way you essentially have a number system without numbers.&lt;/p>
&lt;div class="footnotes" role="doc-endnotes">
&lt;hr>
&lt;ol>
&lt;li id="fn:1">
&lt;p>
&lt;a
href="https://www.valmikiramayan.net/utf8/kish/sarga38/kishkindha_38_frame.htm#Verse30"
target="_blank"
>Valmiki Ramayana - Kishkindha Kanda - Sarga 38﻿ - Verse 30&lt;/a>&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;/ol>
&lt;/div></content></item><item><title>How is the site WhiteHat Jr. for teaching coding for children?</title><link>https://bodha.siddh.me/posts/2020/10/02/how_is_the_site_whitehat_jr_for_teaching_coding_for_children/</link><pubDate>Fri, 02 Oct 2020 00:00:00 +0000</pubDate><guid>https://bodha.siddh.me/posts/2020/10/02/how_is_the_site_whitehat_jr_for_teaching_coding_for_children/</guid><description>This post is a part of migration of my content from Quora. This answer quickly amassed 1k+ upvotes (not common for a no-name user like me) and a lot of interesting comments, in probably less than a week. After that, it was shadow-collapsed by Quora (for no mentioned reason, indicating potential mass reporting), and I didn&amp;rsquo;t even know that for quite a lot of months. An email appeal to reinstate the answer was successful, but it was too late at that point.</description><content>&lt;p>This post is a part of migration of my content from Quora. This answer quickly amassed 1k+ upvotes (not common for a no-name user like me) and a lot of interesting comments, in probably less than a week. After that, it was shadow-collapsed by Quora (for no mentioned reason, indicating potential mass reporting), and I didn&amp;rsquo;t even know that for quite a &lt;em>lot&lt;/em> of months. An email appeal to reinstate the answer was successful, but it was too late at that point.&lt;/p>
&lt;hr>
&lt;p>&lt;strong>TL;DR: WhiteHatJr fools people with buzzwords and mines &amp;amp; profiles every shred of their kids&amp;rsquo; (and probably parents&amp;rsquo; too) data.&lt;/strong>&lt;/p>
&lt;p>I will use
&lt;a
href="http://web.archive.org"
target="_blank"
>Wayback Machine&lt;/a> links for references so as to save the snapshot incase they change the website.&lt;/p>
&lt;p>I will also use mobile screenshots instead of a desktop so as to make them more readable for mobile users.&lt;/p>
&lt;p>Let&amp;rsquo;s start with a cursory look at their homepage.&lt;sup id="fnref:1">&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref">1&lt;/a>&lt;/sup>&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2020/10/02/how_is_the_site_whitehat_jr_for_teaching_coding_for_children/index.assets/whjr_homepage_1.jpg">&lt;/p>
&lt;blockquote>
&lt;p>1:1 online coding classes.&lt;/p>
&lt;/blockquote>
&lt;p>Does that mean every child gets personal attention? The teacher&amp;rsquo;s seemingly stock photo there makes me think they want that to imply.&lt;/p>
&lt;blockquote>
&lt;p>*Last 19 Spots Left&lt;/p>
&lt;/blockquote>
&lt;p>We all know this strategy, needs no introduction. Also, it seems like their coders, or the program they coded doesn&amp;rsquo;t know the rules of grammar.&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2020/10/02/how_is_the_site_whitehat_jr_for_teaching_coding_for_children/index.assets/whjr_homepage_2.jpg">&lt;/p>
&lt;p>Lots of buzzwords sprinkled here and there. Silicon valley, Google, Waymo, and what not. I doubt a kid who doesn&amp;rsquo;t know what is 23² would be able to handle the heavy data and statistics used in machine learning at Waymo offices.&lt;/p>
&lt;p>Also, more than 3 lakh reviews by students. Earlier they said there was 1:1 teaching. Did they handle more than 3 lakh personal 1:1 education sessions (since students can review each class and educator)? Lmfao.&lt;/p>
&lt;p>Okay you might say let&amp;rsquo;s cut some slack since the company is fairly recent. So we can assume they have atleast 10% the number of educators. 30k teachers, is it? Apparently, they have 7k teachers. If every educator made the kid capable for a job involving stuff with driverless cars, they are either very supreme beings who decided to stay underground for years and then suddenly come together to work for this company, or the claim is fake.&lt;/p>
&lt;p>The homepage consists of more buzzwords (including a claim about 1 million+ students (1M == 10L) being associated. Adds a cherry to the 1:1 claim) and extolling about their teachers. One particular thing I would like to point out is their age and price requirements:&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2020/10/02/how_is_the_site_whitehat_jr_for_teaching_coding_for_children/index.assets/whjr_homepage_3.jpg">&lt;/p>
&lt;p>Huh a class 1 student who generally doesn&amp;rsquo;t know trigonometry will code for space missions. Just for a nominal price of ₹1L. I guess all our schools and colleges are soon going to be obsolete. &lt;strong>Finally!&lt;/strong> Thanks, whitehatjr! /s&lt;/p>
&lt;hr>
&lt;p>Before proceeding, let us take a quick look at the &lt;em>detailed curriculum&lt;/em> of their ₹99,999 (or I should say ₹1,07,999) plan for grade 1.&lt;sup id="fnref:2">&lt;a href="#fn:2" class="footnote-ref" role="doc-noteref">2&lt;/a>&lt;/sup>&lt;/p>
&lt;p>&lt;em>They don&amp;rsquo;t even use the Indian numbering system, so much for educating India&amp;rsquo;s kids.&lt;/em>&lt;/p>
&lt;p>&lt;img alt="img" src="https://bodha.siddh.me/posts/2020/10/02/how_is_the_site_whitehat_jr_for_teaching_coding_for_children/index.assets/syllabus_1.jpg">&lt;/p>
&lt;p>Woah! So advanced syllabus!&lt;/p>
&lt;p>Jokes and sarcasm aside, I don&amp;rsquo;t even need to go into that “syllabus” to point out it&amp;rsquo;s total scam in the name of “AI/ML” (like almost always). Most of it seems like drag and drop stuff branded like AI/ML.&lt;/p>
&lt;p>Let&amp;rsquo;s cut some slack considering its class 1, let&amp;rsquo;s look at class 10+ curriculum.&lt;sup id="fnref:3">&lt;a href="#fn:3" class="footnote-ref" role="doc-noteref">3&lt;/a>&lt;/sup>&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2020/10/02/how_is_the_site_whitehat_jr_for_teaching_coding_for_children/index.assets/syllabus_2.jpg">&lt;/p>
&lt;p>BRUH MOMENT. You are paying ONE LAKH RUPEES for this, which is just school education. Why do I say this? Here&amp;rsquo;s why:&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2020/10/02/how_is_the_site_whitehat_jr_for_teaching_coding_for_children/index.assets/syllabus_2_1.jpg">&lt;/p>
&lt;p>&lt;em>Hmm cool, let&amp;rsquo;s look at the juicy things I&amp;rsquo;m gonna learn for building the next Google! Aatmanirbhar Bharat, here I come!&lt;/em>&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2020/10/02/how_is_the_site_whitehat_jr_for_teaching_coding_for_children/index.assets/syllabus_2_2.jpg">&lt;/p>
&lt;ol>
&lt;li>For teaching AI/ML to you, they will first teach you what are variables, if else conditionals, loops, and functions.&lt;/li>
&lt;li>Then they will teach you graphs and Pandas “dataframes” and numpy “arrays”. Without any knowledge of what&amp;rsquo;s happening and how their data is actually fed or manipulated!&lt;/li>
&lt;li>&lt;strong>AFTER&lt;/strong> teaching you numpy and cooldude hackerman data science stuff, they will teach you the basic building blocks, viz., strings, list, tuples, and dictionaries!&lt;/li>
&lt;li>Then you&amp;rsquo;ll study some basic statistics taught in class 12. Remember, after graphs, plots, Panda dataframes, and numpy!&lt;/li>
&lt;/ol>
&lt;p>So much bluffing. Similar goes for the tasks on the right.&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2020/10/02/how_is_the_site_whitehat_jr_for_teaching_coding_for_children/index.assets/syllabus_2_3.jpg">&lt;/p>
&lt;p>Some more class 12 statistics and CS stuff. The major bluff here is about “XGBoost”. The arxiv print&lt;sup id="fnref:4">&lt;a href="#fn:4" class="footnote-ref" role="doc-noteref">4&lt;/a>&lt;/sup> (submitted on 2016) has the following abstract:&lt;/p>
&lt;blockquote>
&lt;p>Tree boosting is a highly effective and widely used machine learning method. In this paper, we describe a scalable end-to-end tree boosting system called XGBoost, which is used widely by data scientists to achieve state-of-the-art results on many machine learning challenges. We propose a novel sparsity-aware algorithm for sparse data and weighted quantile sketch for approximate tree learning. More importantly, we provide insights on cache access patterns, data compression and sharding to build a scalable tree boosting system. By combining these insights, XGBoost scales beyond billions of examples using far fewer resources than existing systems.&lt;/p>
&lt;/blockquote>
&lt;p>And the paper consists of stuff like this:&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2020/10/02/how_is_the_site_whitehat_jr_for_teaching_coding_for_children/index.assets/xgboost_1.jpg">&lt;/p>
&lt;p>or&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2020/10/02/how_is_the_site_whitehat_jr_for_teaching_coding_for_children/index.assets/xgboost_2.jpg">&lt;/p>
&lt;p>This is not the stuff a 14 year old learns (unless your kid is some math genius like Terence Tao, at that point you would know it&amp;rsquo;s futile to waste money here). Even yours truly does not know it and hence is unable to explain it to you.&lt;/p>
&lt;p>Finally let&amp;rsquo;s look at the third part. You&amp;rsquo;d expect some more advanced and juicy stuff.&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2020/10/02/how_is_the_site_whitehat_jr_for_teaching_coding_for_children/index.assets/syllabus_2_4.jpg">&lt;/p>
&lt;p>Oh, so we are back to statistics marketed with buzzwords and captivating tasks. We also see a mention about absolute basic things like matrices and covariance, taught in class 12 and college courses which are not on AI or ML. Whitehatjr doesn&amp;rsquo;t fail to disappoint you more, isn&amp;rsquo;t it?&lt;/p>
&lt;hr>
&lt;p>Before proceeding to the last part, I chanced upon a blog post of theirs. This absolutely shreds any credibility they may have in your mind, if you know stuff about programming.&lt;sup id="fnref:5">&lt;a href="#fn:5" class="footnote-ref" role="doc-noteref">5&lt;/a>&lt;/sup> A prior knowledge about programming helps here.&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2020/10/02/how_is_the_site_whitehat_jr_for_teaching_coding_for_children/index.assets/whjr_php.jpg">&lt;/p>
&lt;p>Oh,&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-diff" data-lang="diff">&lt;span style="display:flex;">&lt;span>&amp;gt;programming language of HTML
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;gt;best use of PHP is interactive pages with WordPress and Drupal
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;gt;PHP is LITTLE difficult for “small” kids
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;gt;it is EASY to learn for more mature kids
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;img src="https://bodha.siddh.me/posts/2020/10/02/how_is_the_site_whitehat_jr_for_teaching_coding_for_children/index.assets/whjr_lua.jpg">&lt;/p>
&lt;p>So according to them Lua is the best introductory language, and Lua code is upon Roblox&amp;rsquo;s default (?) boilerplate (they didn&amp;rsquo;t even use the correct word and terminologies lmao).&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2020/10/02/how_is_the_site_whitehat_jr_for_teaching_coding_for_children/index.assets/whjr_python.jpg">&lt;/p>
&lt;p>Well, it turns out learning PHP and Lua was just scratch. Now the actual beast, Python, has entered into the game! Wow! Also, there is a very kid friendly reference,
&lt;a
href="http://python.org"
target="_blank"
>Python.org&lt;/a>, quoted there!&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2020/10/02/how_is_the_site_whitehat_jr_for_teaching_coding_for_children/index.assets/whjr_java.jpg">&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-diff" data-lang="diff">&lt;span style="display:flex;">&lt;span>&amp;gt;So the reason Java is popular is because of Minecraft.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;gt;Minecraft has its own name among programming languages.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;gt;Inb4 Java == Minecraft
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;gt;Minecraft as a learning tool for Java.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&amp;gt;Tfw you realise Minecraft is closed source.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;p>Now, let&amp;rsquo;s see their privacy policy.&lt;sup id="fnref:6">&lt;a href="#fn:6" class="footnote-ref" role="doc-noteref">6&lt;/a>&lt;/sup> I&amp;rsquo;ll just quote it here and add emphasis, since a screenshot would be too impractical.&lt;/p>
&lt;blockquote>
&lt;ul>
&lt;li>We collect information that may be used to identify you or your Child (“Personal Information”) including, but not limited to, (i) name, e-mail ID, photograph, location and other contact information (ii) gender and other demographics (iii) birth date and year of the Child to validate their age.&lt;/li>
&lt;li>We also collect certain information either when you provide it using the Platform or Services and/or automatically as you or the Child navigate through the Platform (which may include usage details, IP address, device ID and type, your browser type and language, the operating system used by the device, access times, and information collected through cookies, web beacons and other tracking technologies). You agree that we may use such information to do internal research on our Users&amp;rsquo; demographics to better understand, protect and serve our Users.&lt;/li>
&lt;/ul>
&lt;/blockquote>
&lt;p>So they collect all PII of the child, and track the child. But this is nothing, see the next part:&lt;/p>
&lt;blockquote>
&lt;ul>
&lt;li>We collect information from your user ID associated with any social media account (such as your Facebook and Google account) that users use to sign into the Platform or connect with or use of our Services. When you sign in with your social media account information, or otherwise connect to your social media account with the Platform, &lt;strong>you consent to our collection, storage, and use, in accordance with this Privacy Policy, of the information that you make available to us through the social media interface. This includes, without limitation, any information that you have made public through your social media account, information that the social media service shares with us or information that is disclosed during the sign-up and sign-in processes.&lt;/strong>&lt;/li>
&lt;/ul>
&lt;/blockquote>
&lt;p>So any social media you link to them, they have the rights to store and mine every single shred of information on that profile which is public, plus the information you give them access to while signing in.&lt;/p>
&lt;p>Basically, you are allowing them to collect every data available on your social media sites.&lt;/p>
&lt;blockquote>
&lt;ul>
&lt;li>If any of the Users allows us to collect information from his or her device phonebook—and you or the Child’s are one of that User’s contacts—we may combine the information we collect from that User’s phonebook with other information we have collected about you. We may also obtain information from other sources and combine that with the information we collect through the Platform.&lt;/li>
&lt;/ul>
&lt;/blockquote>
&lt;p>So they are correlating your profile and information with others, which includes using phonebook and mobile numbers.&lt;/p>
&lt;p>&lt;em>&lt;strong>So basically, you&amp;rsquo;re giving them a free pass to profile your children from their digital infancy.&lt;/strong>&lt;/em> And they make it absolutely clear later:&lt;/p>
&lt;blockquote>
&lt;ul>
&lt;li>You agree that we may use Personal Information about you to improve our marketing and promotional efforts, to analyse site usage, improve the Platform&amp;rsquo;s content and Service offerings, and customize the Platform&amp;rsquo;s content, layout, and Services. These uses improve the Platform and better tailor it to meet your needs, so as to provide you with an efficient, safe and customized experience while using the Platform.&lt;/li>
&lt;/ul>
&lt;/blockquote>
&lt;hr>
&lt;p>So whitehatjr is basically&lt;/p>
&lt;ul>
&lt;li>Bluffing around both at the homepage and at the curriculum.&lt;/li>
&lt;li>Got technicalities about programming itself wrong. So much for teaching programming.&lt;/li>
&lt;li>Meanwhile they capture every bit (pun intended) of information about you and your child to profile you and use it for more targetted advertisement and more tracking. Essentially monetising it while your child is profiled since day 1.&lt;/li>
&lt;li>Your child gets nothing to learn and you lose money on sketchy claims.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;p>Thanks for reading!&lt;/p>
&lt;p>~ &amp;lt;Named link to my profile&amp;gt;&lt;/p>
&lt;hr>
&lt;p>EDIT 1 (4/10/2020):&lt;/p>
&lt;p>Here are some videos which will demonstrate the superior quality of education at whitehatjr!&lt;/p>
&lt;p>
&lt;a
href="https://www.quora.com/_/redirect?sig=979eda&amp;amp;url=https://youtu.be/qbtMCRRSsuc"
target="_blank"
>https://youtu.be/qbtMCRRSsuc&lt;/a>&lt;/p>
&lt;p>
&lt;a
href="https://www.quora.com/_/redirect?sig=834e24&amp;amp;url=https://youtu.be/E09n3BkrI_I"
target="_blank"
>https://youtu.be/E09n3BkrI_I&lt;/a>&lt;/p>
&lt;p>Both have been archived in case they get taken down.&lt;sup id="fnref:7">&lt;a href="#fn:7" class="footnote-ref" role="doc-noteref">7&lt;/a>&lt;/sup> &lt;sup id="fnref:8">&lt;a href="#fn:8" class="footnote-ref" role="doc-noteref">8&lt;/a>&lt;/sup>&lt;/p>
&lt;div class="footnotes" role="doc-endnotes">
&lt;hr>
&lt;ol>
&lt;li id="fn:1">
&lt;p>
&lt;a
href="https://web.archive.org/web/20201001194135/https://www.whitehatjr.com/"
target="_blank"
>https://web.archive.org/web/20201001194135/https://www.whitehatjr.com/&lt;/a>&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:2">
&lt;p>
&lt;a
href="https://web.archive.org/web/20201001200711/https://cdnwhjr.s3.ap-south-1.amazonaws.com/website/curriculumpdf/12-mar-2020/details/BEG.pdf"
target="_blank"
>https://web.archive.org/web/20201001200711/https://cdnwhjr.s3.ap-south-1.amazonaws.com/website/curriculumpdf/12-mar-2020/details/BEG.pdf&lt;/a>&amp;#160;&lt;a href="#fnref:2" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:3">
&lt;p>
&lt;a
href="https://web.archive.org/web/20201001201804/https://cdnwhjr.s3.ap-south-1.amazonaws.com/website/curriculumpdf/12-mar-2020/details/APT.pdf"
target="_blank"
>https://web.archive.org/web/20201001201804/https://cdnwhjr.s3.ap-south-1.amazonaws.com/website/curriculumpdf/12-mar-2020/details/APT.pdf&lt;/a>&amp;#160;&lt;a href="#fnref:3" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:4">
&lt;p>
&lt;a
href="https://arxiv.org/abs/1603.02754"
target="_blank"
>https://arxiv.org/abs/1603.02754&lt;/a>&amp;#160;&lt;a href="#fnref:4" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:5">
&lt;p>
&lt;a
href="https://web.archive.org/web/20201001210711/https://blog.whitehatjr.com/coding-for-kids/the-best-kids-coding-languages/"
target="_blank"
>https://web.archive.org/web/20201001210711/https://blog.whitehatjr.com/coding-for-kids/the-best-kids-coding-languages/&lt;/a>&amp;#160;&lt;a href="#fnref:5" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:6">
&lt;p>
&lt;a
href="https://web.archive.org/web/20201001214127/https://code.whitehatjr.com/privacy-policy"
target="_blank"
>https://web.archive.org/web/20201001214127/https://code.whitehatjr.com/privacy-policy&lt;/a>&amp;#160;&lt;a href="#fnref:6" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:7">
&lt;p>
&lt;a
href="https://web.archive.org/web/20201004065219/https://www.youtube.com/watch?v%3DqbtMCRRSsuc%26feature%3Dyoutu.be"
target="_blank"
>https://web.archive.org/web/20201004065219/https://www.youtube.com/watch?v%3DqbtMCRRSsuc%26feature%3Dyoutu.be&lt;/a>&amp;#160;&lt;a href="#fnref:7" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:8">
&lt;p>
&lt;a
href="https://web.archive.org/web/20201004065406/https://www.youtube.com/watch?v%3DE09n3BkrI_I%26feature%3Dyoutu.be"
target="_blank"
>https://web.archive.org/web/20201004065406/https://www.youtube.com/watch?v%3DE09n3BkrI_I%26feature%3Dyoutu.be&lt;/a>&amp;#160;&lt;a href="#fnref:8" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;/ol>
&lt;/div></content></item><item><title>What is the difference between cryptography and steganography?</title><link>https://bodha.siddh.me/posts/2019/07/28/what_is_the_difference_between_cryptography_and_steganography/</link><pubDate>Sun, 28 Jul 2019 00:00:00 +0000</pubDate><guid>https://bodha.siddh.me/posts/2019/07/28/what_is_the_difference_between_cryptography_and_steganography/</guid><description>Source: https://www.slideshare.net/kinleay/cryptography-its-history-application-and-beyond Cryptography involves itself with encryption/decryption or hashing of the messages. It&amp;rsquo;s almost a mathematical field which has a profound practical impact on our lives. Generally, other guys must not be able to read your data, even if they get hold of it and know how it was encrypted.1
Some of the most noticeable everyday life examples:
Most n00b example everyone comes across: Fb lbh svanyyl qrpelcgrq guvf! :-C If you didn&amp;rsquo;t know words are shifted by 13, this would be garbage for you.</description><content>
&lt;figure class="left" >
&lt;img src="index.assets/cryptography.jpg" />
&lt;figcaption class="center" >Source: https://www.slideshare.net/kinleay/cryptography-its-history-application-and-beyond&lt;/figcaption>
&lt;/figure>
&lt;p>Cryptography involves itself with encryption/decryption or hashing of the messages. &lt;em>&lt;strong>It&amp;rsquo;s almost a mathematical field which has a profound practical impact on our lives.&lt;/strong>&lt;/em> Generally, other guys must not be able to read your data, even if they get hold of it and know how it was encrypted.&lt;sup id="fnref:1">&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref">1&lt;/a>&lt;/sup>&lt;/p>
&lt;p>&lt;em>Some of the most noticeable everyday life examples:&lt;/em>&lt;/p>
&lt;ul>
&lt;li>Most n00b example everyone comes across:
&lt;ul>
&lt;li>Fb lbh svanyyl qrpelcgrq guvf! :-C&lt;/li>
&lt;li>If you didn&amp;rsquo;t know words are shifted by 13, this would be garbage for you.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>To check if data is untampered as it was originally meant to be.&lt;sup id="fnref:2">&lt;a href="#fn:2" class="footnote-ref" role="doc-noteref">2&lt;/a>&lt;/sup>&lt;/li>
&lt;li>It&amp;rsquo;s used to transmit data/messages in a secure and safe way so that any interceptor or evesdropper doesn&amp;rsquo;t get hold of what we are communicating or sending, i.e. secrecy of transmission of communication or data. One way to implement this is the RSA algorithm. But it&amp;rsquo;s not the only way and a myriad of algorithms, more or less powerful, exist.
&lt;ul>
&lt;li>The lock you see on HTTPS websites is a direct consequence of this.&lt;sup id="fnref:3">&lt;a href="#fn:3" class="footnote-ref" role="doc-noteref">3&lt;/a>&lt;/sup>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>As a related point to above, the infamous enigma machine.&lt;sup id="fnref:4">&lt;a href="#fn:4" class="footnote-ref" role="doc-noteref">4&lt;/a>&lt;/sup>&lt;/li>
&lt;li>Storage and verification of passwords while logging in or otherwise.&lt;/li>
&lt;li>Encryption of your stored data.&lt;sup id="fnref:5">&lt;a href="#fn:5" class="footnote-ref" role="doc-noteref">5&lt;/a>&lt;/sup>
&lt;ul>
&lt;li>Having a lock/full disk encryption on your mobile. Your Android phone is decrypted on every reboot.&lt;sup id="fnref:6">&lt;a href="#fn:6" class="footnote-ref" role="doc-noteref">6&lt;/a>&lt;/sup>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>&lt;em>Steganography&lt;/em> (see the next section).&lt;/li>
&lt;/ul>
&lt;p>And much much much much more.&lt;/p>
&lt;p>Steganography involves itself with hiding some file (image/executable/any file or data) &lt;em>&lt;strong>in another file.&lt;/strong>&lt;/em> Essentially you have data hidden in data, like, you hide a paper in a big folder. Not much mathematical theory (when compared to cryptography) is involved in this and is many times supplemented by cryptography.&lt;/p>
&lt;p>It&amp;rsquo;s advantage over cryptography is that since data is hidden &lt;em>&lt;strong>there&amp;rsquo;s a far less probability of suspicion than some exposed cryptic data in case of vanilla cryptographic data transfer.&lt;/strong>&lt;/em> For example, let Germans use the enigma machine and suppose British got hold of it accidentally with a blank mind. Seeing the enigma message would immediately ring bells since the cryptic sequence seems too good to be random. Whereas in steganography that would be hidden behind another thing, like suppose a dank meme on Hitler and Churchill.&lt;/p>
&lt;p>&lt;em>Some normal uses in a huge set of uses:&lt;/em>&lt;/p>
&lt;ul>
&lt;li>Very very very 5yo tier n00b rudimentary and a bad practical example is:
&lt;ul>
&lt;li>NwnyynynfoofynyncNfwnxppbatengfnyncjyjxrwxfjxfykznxOmfwfaqhcibgrgurnafjrenxnyynfzfafxwnxuffygunajfzana&lt;/li>
&lt;li>Find a message in this! :)&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>Someone can hide an executable code in an image. Classic virus propagation strategy.&lt;sup id="fnref:7">&lt;a href="#fn:7" class="footnote-ref" role="doc-noteref">7&lt;/a>&lt;/sup>&lt;/li>
&lt;li>You can hide your files behind another file.&lt;/li>
&lt;li>Hide a message in an image so that it can be seen in a particular colour value only.&lt;sup id="fnref:8">&lt;a href="#fn:8" class="footnote-ref" role="doc-noteref">8&lt;/a>&lt;/sup> Or in audio files.&lt;sup id="fnref:9">&lt;a href="#fn:9" class="footnote-ref" role="doc-noteref">9&lt;/a>&lt;/sup> List is endless.&lt;/li>
&lt;li>Printers printing barely visible data on every page about the machine and date time, so that the document can be traced back.&lt;sup id="fnref:10">&lt;a href="#fn:10" class="footnote-ref" role="doc-noteref">10&lt;/a>&lt;/sup>&lt;/li>
&lt;/ul>
&lt;p>And much much much more.&lt;/p>
&lt;p>Thanks for reading!&lt;/p>
&lt;div class="footnotes" role="doc-endnotes">
&lt;hr>
&lt;ol>
&lt;li id="fn:1">
&lt;p>
&lt;a
href="https://en.m.wikipedia.org/wiki/Kerckhoffs%27s_principle"
target="_blank"
>Kerckhoffs&amp;rsquo;s principle - Wikipedia&lt;/a>&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:2">
&lt;p>
&lt;a
href="https://en.m.wikipedia.org/wiki/Checksum"
target="_blank"
>Checksum - Wikipedia&lt;/a>&amp;#160;&lt;a href="#fnref:2" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:3">
&lt;p>
&lt;a
href="https://en.m.wikipedia.org/wiki/Public_key_certificate"
target="_blank"
>Public key certificate - Wikipedia&lt;/a>&amp;#160;&lt;a href="#fnref:3" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:4">
&lt;p>
&lt;a
href="https://en.m.wikipedia.org/wiki/Enigma_machine"
target="_blank"
>Enigma machine - Wikipedia&lt;/a>&amp;#160;&lt;a href="#fnref:4" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:5">
&lt;p>
&lt;a
href="https://www.thalesesecurity.com/faq/encryption/what-storage-encryption"
target="_blank"
>What is Storage Encryption?&lt;/a>&amp;#160;&lt;a href="#fnref:5" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:6">
&lt;p>
&lt;a
href="https://source.android.com/security/encryption/full-disk"
target="_blank"
>Full-Disk Encryption | Android Open Source Project&lt;/a>&amp;#160;&lt;a href="#fnref:6" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:7">
&lt;p>
&lt;a
href="https://securelist.com/png-embedded-malicious-payload-hidden-in-a-png-file/74297/"
target="_blank"
>PNG Embedded – Malicious payload hidden in a PNG file&lt;/a>&amp;#160;&lt;a href="#fnref:7" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:8">
&lt;p>
&lt;a
href="https://en.wikipedia.org/wiki/File:Steganography.png%23mw-jump-to-license"
target="_blank"
>File:Steganography.png - Wikipedia&lt;/a>&amp;#160;&lt;a href="#fnref:8" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:9">
&lt;p>
&lt;a
href="https://bastijn.io/2018/Steganography-and-WAV.html"
target="_blank"
>Steganography and .WAV&lt;/a>&amp;#160;&lt;a href="#fnref:9" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:10">
&lt;p>
&lt;a
href="https://en.m.wikipedia.org/wiki/Machine_Identification_Code"
target="_blank"
>Machine Identification Code - Wikipedia&lt;/a>&amp;#160;&lt;a href="#fnref:10" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;/ol>
&lt;/div></content></item><item><title>What is the maximum amount of damage you can inflict on the universe by altering one word in any one of Newton's three laws of motion?</title><link>https://bodha.siddh.me/posts/2019/03/13/max_damage_by_altering_one_word_in_any_newton_law/</link><pubDate>Wed, 13 Mar 2019 00:00:00 +0000</pubDate><guid>https://bodha.siddh.me/posts/2019/03/13/max_damage_by_altering_one_word_in_any_newton_law/</guid><description>The holy second law is untouched till now (note: in the question thread), such is the power of the second law. It is in a way the basis of force as we perceive in daily life. Yeah, let&amp;rsquo;s play with the force itself.
Here&amp;rsquo;s the second law.
The rate of change of momentum of a body is directly proportional to the force applied, and this change in momentum takes place in the direction of the applied force.</description><content>&lt;p>The holy second law is untouched till now (note: in the question thread), such is the power of the second law. It is in a way the basis of &lt;em>force&lt;/em> as we perceive in daily life. Yeah, let&amp;rsquo;s play with the force itself.&lt;/p>
&lt;p>Here&amp;rsquo;s the second law.&lt;/p>
&lt;blockquote>
&lt;p>The rate of change of momentum of a body is directly proportional to the force applied, and this change in momentum takes place in the direction of the applied force.&lt;/p>
&lt;/blockquote>
&lt;p>So we write it in mathematical notation as
$$
\vec{F} \propto \dot{\vec{p}}
$$&lt;/p>
&lt;hr>
&lt;p>I modify the law to be…&lt;/p>
&lt;blockquote>
&lt;p>The rate of change of momentum of a body is &lt;em>&lt;strong>inversely&lt;/strong>&lt;/em> proportional to the force applied, and this change in momentum takes place in the direction of the applied force.&lt;/p>
&lt;/blockquote>
&lt;p>Oooh, so now the mathematical form would change to…&lt;/p>
&lt;p>$$
\vec{F} \propto \dfrac{1}{\dot{\vec{p}}}
$$&lt;/p>
&lt;p>Oh, hey, since $\vec{p}=m\vec{v}$, as you slow down the force would &lt;em>&lt;strong>increase&lt;/strong>&lt;/em>.&lt;/p>
&lt;p>That is, in familiar form…&lt;/p>
&lt;p>$$
\vec{F} = \dfrac{1}{m\vec{a}}
$$&lt;/p>
&lt;p>I can&amp;rsquo;t fathom the craziness it would make… like, an ant commits a genocide?&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2019/03/13/max_damage_by_altering_one_word_in_any_newton_law/index.assets/ant_remembers.jpg">&lt;/p>
&lt;p>To lessen the force, you would need to go &lt;em>more&lt;/em> faster.&lt;/p>
&lt;p>So when a car hits you, it needs to go &lt;em>&lt;strong>faster to stop.&lt;/strong>&lt;/em>&lt;/p>
&lt;p>I must have made the grandfather of paradoxical physics proud.&lt;/p>
&lt;hr>
&lt;p>On the flip side, we can travel faster than light. Yay!&lt;/p>
&lt;p>&lt;em>(Pun totally not intended)&lt;/em>&lt;/p></content></item><item><title>How can we improve Aadhaar's security?</title><link>https://bodha.siddh.me/posts/2019/03/08/how_can_we_improve_aadhaars_security/</link><pubDate>Fri, 08 Mar 2019 00:00:00 +0000</pubDate><guid>https://bodha.siddh.me/posts/2019/03/08/how_can_we_improve_aadhaars_security/</guid><description>Warning! Not your average bitching answer.
Well, let&amp;rsquo;s do a quick recap of what Aadhaar, an authentication system, does.
The end-user/application supplies some data to the system, like Aadhaar number, name, age, DOB, etc. which is to be authenticated. The Aadhaar system compares this with its own record, and would like to verify with OTP and biometrics that the authentication request is indeed by the guy whose data is being processed.</description><content>&lt;p>&lt;em>Warning! Not your average bitching answer.&lt;/em>&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2019/03/08/how_can_we_improve_aadhaars_security/index.assets/lock.jpg">&lt;/p>
&lt;p>Well, let&amp;rsquo;s do a quick recap of what Aadhaar, an authentication system, does.&lt;/p>
&lt;ol>
&lt;li>The end-user/application supplies some data to the system, like Aadhaar number, name, age, DOB, etc. which is to be authenticated.&lt;/li>
&lt;li>The Aadhaar system compares this with its own record, and would like to verify with OTP and biometrics that the authentication request is indeed by the guy whose data is being processed.&lt;/li>
&lt;li>If the comparison and verification is successful, the system would tell back that the information supplied is correct according to its record and hence, authenticated, and &lt;em>sometimes sends back the information in database.&lt;/em>&lt;/li>
&lt;li>The user/application sees this and does whatever it wants to do by getting the confirmation.&lt;/li>
&lt;/ol>
&lt;hr>
&lt;p>&lt;em>Isn&amp;rsquo;t this working sorta&lt;/em> &lt;em>like…… password?&lt;/em>&lt;/p>
&lt;p>With the exception of sending back data, it is working exactly how a password works.&lt;/p>
&lt;p>So… maybe we can get rid of the exception?!&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2019/03/08/how_can_we_improve_aadhaars_security/index.assets/aadhaar_high_level.png">&lt;/p>
&lt;p>&lt;em>Source: Introduction to Aadhaar, TRAI.&lt;sup id="fnref:1">&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref">1&lt;/a>&lt;/sup>&lt;/em>&lt;/p>
&lt;p>&lt;em>&lt;strong>Aadhaar is primarily an authentication system.&lt;/strong>&lt;/em> It is not concerned and doesn&amp;rsquo;t care two shits about what the end-user does with the information. A bank may use it for your account or government for DBT. All the system cares about is the integrity of information provided.&lt;/p>
&lt;p>As far as I know, and I would be happy to be corrected, Aadhaar uses PKI+AES and sprinkle of other cryptographic functions to store the database as it is intact, with names and addresses available if requested by the system.&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2019/03/08/how_can_we_improve_aadhaars_security/index.assets/pki.jpg">&lt;/p>
&lt;p>But Aadhaar is an authentication system. It should &lt;strong>not&lt;/strong> be concerned about giving back any data. A yes/no reply by the system, as the same system does when verifying biometric&lt;sup id="fnref:2">&lt;a href="#fn:2" class="footnote-ref" role="doc-noteref">2&lt;/a>&lt;/sup>, should ideally be the case.&lt;/p>
&lt;p>&lt;em>&lt;strong>Thus, we can make it to work and store the data just like password!&lt;/strong>&lt;/em>&lt;/p>
&lt;p>(If you don&amp;rsquo;t know how password works, my
&lt;a
href="https://bodha.siddh.me/posts/2017/12/24/in-simple-language-how-do-passwords-work-how-does-an-application-reject-the-wrong-password/"
> answer to In simple language, how do passwords work? How does an application reject the wrong password?&lt;/a> would be a good introduction to it, along with terms like salting, hashing.)&lt;/p>
&lt;hr>
&lt;p>Thus, Aadhaar data in database can be ideally treated as &lt;em>accounts,&lt;/em> identified by the Aadhaar number or the virtual ID.&lt;/p>
&lt;p>&lt;em>&lt;strong>The details tied to the Aadhaar number can be salted and hashed, just like a password for, say, your Quora account.&lt;/strong>&lt;/em>&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2019/03/08/how_can_we_improve_aadhaars_security/index.assets/hashing.png">&lt;/p>
&lt;p>&lt;em>Source: Pluke, CC0, via Wikimedia Commons.&lt;sup id="fnref:3">&lt;a href="#fn:3" class="footnote-ref" role="doc-noteref">3&lt;/a>&lt;/sup>&lt;/em>&lt;/p>
&lt;p>So when there&amp;rsquo;s an authentication request, the information supplied by the &lt;strong>user&lt;/strong> would be salted and hashed, and &lt;em>then&lt;/em> compared to the stored hashes! The verification (OTP, biometric stuff) can be done by the system as it did earlier. This improves the security, and it also has the potential to eliminate raw data transmission over the network entirely.&lt;/p>
&lt;p>This way, integrity of data could be verified, and data leaks can be minimised because &lt;em>hashes are one-way cryptographic functions.&lt;sup id="fnref:4">&lt;a href="#fn:4" class="footnote-ref" role="doc-noteref">4&lt;/a>&lt;/sup> Once you have a hash, you can&amp;rsquo;t have the thing which you hashed back from the hash,&lt;/em> unless you brute-force (which would take trillions of years) or precomputed data in rainbow tables.&lt;sup id="fnref:5">&lt;a href="#fn:5" class="footnote-ref" role="doc-noteref">5&lt;/a>&lt;/sup>&lt;/p>
&lt;p>The 2&lt;sup>n/2&lt;/sup> bound&lt;sup id="fnref:6">&lt;a href="#fn:6" class="footnote-ref" role="doc-noteref">6&lt;/a>&lt;/sup> for avoiding collision can easily be taken care of by, say, SHA512. The population of India (or the world) is unlikely to be anywhere near even 0.00000000000000000000000000000000000000000000000000000000000001% of 2&lt;sup>256&lt;/sup> .&lt;/p>
&lt;p>There&amp;rsquo;s one thing to this, even the Government would be unable to access the raw data from UIDAI Aadhaar database when they would need to. But do they even need to? :)&lt;/p>
&lt;hr>
&lt;p>Thanks for reading!&lt;/p>
&lt;p>~ &amp;lt;Named Quora profile link signoff&amp;gt;&lt;/p>
&lt;div class="footnotes" role="doc-endnotes">
&lt;hr>
&lt;ol>
&lt;li id="fn:1">
&lt;p>
&lt;a
href="https://trai.gov.in/sites/default/files/presentations_&amp;amp;_cv/Day-3_25Aug2017/Session2_Digital%20world/Digital%20Identifiers_Ashok%20Kumar.pdf"
target="_blank"
>https://trai.gov.in/sites/default/files/presentations_&amp;_cv/Day-3_25Aug2017/Session2_Digital%20world/Digital%20Identifiers_Ashok%20Kumar.pdf&lt;/a>&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:2">
&lt;p>
&lt;a
href="https://web.archive.org/web/20191217193438/https://ekdrishti.in/understanding-aadhaar-data-security-85d361d47f72"
target="_blank"
>Understanding Aadhaar: Data Security — ekdrishti (archived)&lt;/a>&amp;#160;&lt;a href="#fnref:2" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:3">
&lt;p>
&lt;a
href="https://commons.wikimedia.org/wiki/File:CPT-Hashing-Password-Hashed.svg"
target="_blank"
>https://commons.wikimedia.org/wiki/File:CPT-Hashing-Password-Hashed.svg&lt;/a>&amp;#160;&lt;a href="#fnref:3" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:4">
&lt;p>
&lt;a
href="https://en.wikipedia.org/wiki/Cryptographic_hash_function"
target="_blank"
>Cryptographic hash function - Wikipedia&lt;/a>&amp;#160;&lt;a href="#fnref:4" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:5">
&lt;p>
&lt;a
href="https://en.wikipedia.org/wiki/Rainbow_table"
target="_blank"
>Rainbow table - Wikipedia&lt;/a>&amp;#160;&lt;a href="#fnref:5" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:6">
&lt;p>
&lt;a
href="https://en.wikipedia.org/wiki/Birthday_attack"
target="_blank"
>Birthday attack - Wikipedia&lt;/a>&amp;#160;&lt;a href="#fnref:6" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;/ol>
&lt;/div></content></item><item><title>Conceptually, what is DDoS and darknet?</title><link>https://bodha.siddh.me/posts/2018/06/25/conceptually_what_is_ddos_and_darknet/</link><pubDate>Mon, 25 Jun 2018 00:00:00 +0000</pubDate><guid>https://bodha.siddh.me/posts/2018/06/25/conceptually_what_is_ddos_and_darknet/</guid><description>Essentially, without any pseudo-childish-hacking fuss, it simply goes like this:
DDoS attack is like a mob attack on a shop or a riot. When that happens, the shop is shut down and curfew maybe imposed on the area. DDoS is a coordinated attack on a web server, overflowing it with huge amounts of requests and traffic that the poor server&amp;rsquo;s resources are forced to become unavailable. Darknet is just like an area of abandoned houses.</description><content>&lt;p>Essentially, without any pseudo-childish-hacking fuss, it &lt;em>simply&lt;/em> goes like this:&lt;/p>
&lt;ul>
&lt;li>DDoS attack is like a mob attack on a shop or a riot. When that happens, the shop is shut down and curfew maybe imposed on the area.
&lt;ul>
&lt;li>DDoS is a coordinated attack on a web server, overflowing it with huge amounts of requests and traffic that the poor server&amp;rsquo;s resources are forced to become unavailable.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2018/06/25/conceptually_what_is_ddos_and_darknet/index.assets/mob.jpg">&lt;/p>
&lt;ul>
&lt;li>Darknet is just like an area of abandoned houses. You can ring their doorbells but you won&amp;rsquo;t get an answer back. You aren&amp;rsquo;t supposed to be there in the first place.
&lt;ul>
&lt;li>A darknet is a portion of routed, allocated IP space not running any services. Traffic arriving to such IP dark space is undesired since it has no active hosts. (
&lt;a
href="https://en.m.wikipedia.org/wiki/Darknet"
target="_blank"
>Darknet - Wikipedia&lt;/a> )&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2018/06/25/conceptually_what_is_ddos_and_darknet/index.assets/deserted_house.jpg">&lt;/p>
&lt;ul>
&lt;li>Dark web are websites which cannot be indexed by search engines and can only be accessed using special software. (Note that search engines can&amp;rsquo;t index your inbox, but you don&amp;rsquo;t need a special software to access your inbox. Your inbox is also referred as &amp;ldquo;deep web&amp;rdquo;.) Softwares and systems providing access to darknet cloak your identity by changing your names many times.
&lt;ul>
&lt;li>Dark web&amp;rsquo;s overlay network route your connection through several proxies so that your identity is anonymous. These websites can&amp;rsquo;t be indexed by search engines and requires specially configured software to access them.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2018/06/25/conceptually_what_is_ddos_and_darknet/index.assets/card.jpg">&lt;/p>
&lt;p>Don&amp;rsquo;t go by others on internet. This isn&amp;rsquo;t complicated, as you can see the similarity between points and sub points above.&lt;/p>
&lt;p>One thing - &lt;em>Dark web isn&amp;rsquo;t dangerous in itself.&lt;/em> Communicating and interacting with random strangers over the internet is.&lt;/p>
&lt;p>&lt;em>Ignore online fanatic fantasies.&lt;/em> And you&amp;rsquo;re good to go.&lt;/p></content></item><item><title>Is cryptography important? Why?</title><link>https://bodha.siddh.me/posts/2018/04/16/is_cryptography_important_why/</link><pubDate>Mon, 16 Apr 2018 00:00:00 +0000</pubDate><guid>https://bodha.siddh.me/posts/2018/04/16/is_cryptography_important_why/</guid><description>Let&amp;rsquo;s make it interesting.
Okay so for a minute think you&amp;rsquo;re an agent for intelligence agencies like IB/RAW. You have some top secret information about a new weapon system of another country which would wreck havoc in the world. You have to transfer the information obtained by espionage back to Delhi without getting caught, but the bummer is that you know someone named Eve is spying on you and would intercept any message you send.</description><content>&lt;p>Let&amp;rsquo;s make it interesting.&lt;/p>
&lt;hr>
&lt;p>Okay so for a minute think you&amp;rsquo;re an agent for intelligence agencies like IB/RAW. You have some top secret information about a new weapon system of another country which would wreck havoc in the world. You have to transfer the information obtained by espionage back to Delhi without getting caught, but the bummer is that you know someone named Eve is spying on you and would intercept any message you send.&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2018/04/16/is_cryptography_important_why/index.assets/top_secret.jpg">&lt;/p>
&lt;p>How would you store and subsequently transfer the data?&lt;/p>
&lt;hr>
&lt;p>This is where cryptography comes in.&lt;/p>
&lt;p>When you apply the cryptographic algorithm (i.e use cryptography), &lt;strong>your message changes, successfully hiding it for the time being.&lt;/strong> Hence the word &lt;strong>
&lt;a
href="https://dictionary.cambridge.org/dictionary/english/crypto"
target="_blank"
>crypto&lt;/a>&lt;/strong>.&lt;/p>
&lt;p>The message is said to be encrypted, which can be decrypted using algorithms, keys or passwords, depending upon the type of cryptographic method you use.&lt;/p>
&lt;p>Now your espionage report doesn&amp;rsquo;t make any sense to Eve.&lt;/p>
&lt;p>Your mission is successful. Congratulations!&lt;/p>
&lt;hr>
&lt;p>Cryptography is important as it allows us to transfer data on an insecure, unencrypted, prone to eavesdropping environment. It&amp;rsquo;s like taking a bag of money in an area of criminals.&lt;/p>
&lt;p>Cryptography is used in everyday life. It&amp;rsquo;s used in banking,
&lt;a
href="http://www.thehindu.com/news/national/cbse-fights-leaks-with-encrypted-question-papers/article23417712.ece"
target="_blank"
>CBSE board exams&lt;/a>, confidential databases (like SSN, Aadhaar), sign-in on websites, and many more. It&amp;rsquo;s used even while you&amp;rsquo;re just browsing the internet, which is an extremely important application.&lt;/p>
&lt;p>Cryptography is just lock and key.&lt;/p></content></item><item><title>In simple language, how do passwords work? How does an application reject the wrong password?</title><link>https://bodha.siddh.me/posts/2017/12/24/in-simple-language-how-do-passwords-work-how-does-an-application-reject-the-wrong-password/</link><pubDate>Sun, 24 Dec 2017 00:00:00 +0000</pubDate><guid>https://bodha.siddh.me/posts/2017/12/24/in-simple-language-how-do-passwords-work-how-does-an-application-reject-the-wrong-password/</guid><description>Almost on every reputed website password isn’t stored in plain-text. It is hashed ( Cryptographic hash function - Wikipedia) and salted. If you store passwords in plain-text then any intruder can just get hold of &amp;rsquo;em.
A cryptographic hash function is, you can say, a mathematical algorithm (hence a function) to convert an arbitrary input (aka message) to a string (bit array, to be precise) of a fixed size, which is called a hash/digest.</description><content>&lt;p>Almost on every reputed website password isn’t stored in plain-text. It is hashed &lt;em>(&lt;/em>
&lt;a
href="https://en.wikipedia.org/wiki/Cryptographic_hash_function"
target="_blank"
>&lt;em>Cryptographic hash function - Wikipedia&lt;/em>&lt;/a>&lt;em>)&lt;/em> and salted. If you store passwords in plain-text then any intruder can just get hold of &amp;rsquo;em.&lt;/p>
&lt;p>&lt;img src="https://bodha.siddh.me/posts/2017/12/24/in-simple-language-how-do-passwords-work-how-does-an-application-reject-the-wrong-password/index.assets/password.jpg">&lt;/p>
&lt;p>A cryptographic hash function is, you can say, a mathematical algorithm (hence a function) to convert an arbitrary input (aka message) to a string (bit array, to be precise) of a fixed size, which is called a hash/digest. These are designed to be one-way functions, i.e., you can&amp;rsquo;t get the message from the hash. The only way is to brute-force (which could take millions of years for a strong password), or use rainbow tables (which contains precomputed data). Going deep into this subject is out of scope of this answer, as it requests explanation in simple terms.&lt;/p>
&lt;p>Salt is a random string which is concatenated or added in the password for extra security, which is then hashed. In this way, the password is more secure as the hash of real password is different from the hash of salted password. For example,&lt;/p>
&lt;p>Password = upvote_this_answer_NOW&lt;/p>
&lt;p>Salt = shklf87et6ehbg&lt;/p>
&lt;p>Salted password = upvote_this_answer_NOWshklf87et6ehbg&lt;/p>
&lt;pre tabindex="0">&lt;code>Salted password’s hash = e10be86c2fc46dcf669d49f5f29e1dd7b1bf4e135f07cb4541e106ee0a591db6d5823187b1e88154775f2a9c1e3926eb88ee68f1d9bbedd372324185118c4a10
Real password’s hash = fecf3e2c732cce39f056937cba78bbd4797b091865deb2eae88ef645cc167d353cf3d24163430268ba18c110e68c4b218eb369f341d82c334c673b464601443e
&lt;/code>&lt;/pre>&lt;p>Clearly, the hashes&lt;sup id="fnref:1">&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref">1&lt;/a>&lt;/sup> are different. (Future 2023 addendum: So the hacker doesn&amp;rsquo;t have to cringe at the shameless string, oh god I was stupid in 2017.)&lt;/p>
&lt;p>Now, here&amp;rsquo;s what happens behind the scene when you enter a password:&lt;/p>
&lt;ul>
&lt;li>You enter the password.&lt;/li>
&lt;li>It is then salted.&lt;/li>
&lt;li>The password is then hashed using the cryptographic hash functions in use.&lt;/li>
&lt;li>The hash is compared to the stored hash. If it matches, the password is correct.&lt;/li>
&lt;/ul>
&lt;p>Contains excerpts from
&lt;a
href="https://bodha.siddh.me/posts/2017/07/06/how-does-one-create-a-strong-password-any-tips"
>my answer to How does one create a strong password? Any tips?&lt;/a>.&lt;/p>
&lt;p>Thanks for reading!&lt;/p>
&lt;div class="footnotes" role="doc-endnotes">
&lt;hr>
&lt;ol>
&lt;li id="fn:1">
&lt;p>Used SHA512.&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;/ol>
&lt;/div></content></item><item><title>Has anyone solved the makkhichoose puzzle?</title><link>https://bodha.siddh.me/posts/2016/04/05/has_anyone_solved_the_makkhichoose_puzzle/</link><pubDate>Tue, 05 Apr 2016 00:00:00 +0000</pubDate><guid>https://bodha.siddh.me/posts/2016/04/05/has_anyone_solved_the_makkhichoose_puzzle/</guid><description>Well, they use that puzzle for hiring, so I won&amp;rsquo;t provide the answer here, or their purpose would be defeated.
But nevertheless, I will provide you a hint. Look at the JS file in POST data.
Confused? Can&amp;rsquo;t find? Here it is!
js function sendData(in_data,dest_url) { var req_send = $.ajax({ url: dest_url, type: &amp;#39;POST&amp;#39;, contentType: &amp;#39;application/json&amp;#39;, data: in_data, dataType: &amp;#39;json&amp;#39; }); return req_send; }; //sendData function munchClues(data) { var makkhi_link= &amp;#39;&amp;lt;a href=&amp;#34;MakkhiChoose&amp;#34; target=&amp;#34;_blank&amp;#34; title=&amp;#34;MakkhiChoose browser plug-in, open in new window&amp;#34;&amp;gt;MakkhiChoose&amp;lt;/a&amp;gt;&amp;#39;; var econ_link = &amp;#39;&amp;lt;a href=&amp;#34;MakkhiChoose - Tricks and extensions to enhance your browsing experience - The Economic Times&amp;#34; target=&amp;#34;_blank&amp;#34; title=&amp;#34;Press Coverage in The Times of India&amp;#34;&amp;gt;1.</description><content>&lt;p>Well, they use that puzzle for hiring, so I won&amp;rsquo;t provide the answer here, or their purpose would be defeated.&lt;/p>
&lt;p>But nevertheless, I will provide you a hint. Look at the JS file in POST data.&lt;/p>
&lt;p>Confused? Can&amp;rsquo;t find? Here it is!&lt;/p>
&lt;div class="collapsable-code">
&lt;input id="129378564" type="checkbox" checked />
&lt;label for="129378564">
&lt;span class="collapsable-code__language">js&lt;/span>
&lt;span class="collapsable-code__toggle" data-label-expand="Show" data-label-collapse="Hide">&lt;/span>
&lt;/label>
&lt;pre class="language-js" >&lt;code>
function sendData(in_data,dest_url) {
var req_send = $.ajax({
url: dest_url,
type: &amp;#39;POST&amp;#39;,
contentType: &amp;#39;application/json&amp;#39;,
data: in_data,
dataType: &amp;#39;json&amp;#39;
});
return req_send;
}; //sendData
function munchClues(data) {
var makkhi_link= &amp;#39;&amp;lt;a href=&amp;#34;MakkhiChoose&amp;#34; target=&amp;#34;_blank&amp;#34; title=&amp;#34;MakkhiChoose browser plug-in, open in new window&amp;#34;&amp;gt;MakkhiChoose&amp;lt;/a&amp;gt;&amp;#39;;
var econ_link = &amp;#39;&amp;lt;a href=&amp;#34;MakkhiChoose - Tricks and extensions to enhance your browsing experience - The Economic Times&amp;#34; target=&amp;#34;_blank&amp;#34; title=&amp;#34;Press Coverage in The Times of India&amp;#34;&amp;gt;1.5 Lakh Indians&amp;lt;/a&amp;gt;.&amp;#39;;
var disp_arr=[ &amp;#34;Hey you! There&amp;#39;s a puzzle in here. Click on the arrow for more clues.&amp;#34;,
&amp;#34;This is a coding puzzle. You&amp;#39;ll need to write some code.&amp;#34;,
&amp;#34;It isn&amp;#39;t tough. The clues are all here, in this page&amp;#34;,
&amp;#34;But you&amp;#39;ll have to look closely.&amp;#34;,
&amp;#34;It might not even be in these sentences.&amp;#34;,
&amp;#34;Look under the covers, as any good detective would&amp;#34;,
&amp;#34;Once you get the secret phrase, type it in the box to the left&amp;#34;,
&amp;#34;Who are we? We are the makers of &amp;#34;&amp;#43;makkhi_link,
&amp;#34;Dont have it? Install &amp;#34;&amp;#43;makkhi_link&amp;#43;&amp;#34; and you&amp;#39;ll get one more BIG clue!&amp;#34;,
&amp;#34;The best way to save while shopping online, according to more than &amp;#34;&amp;#43;econ_link,
&amp;#34;&amp;lt;b&amp;gt;You&amp;lt;/b&amp;gt; can help us make it better, if you are good enough to crack this puzzle&amp;#34;,
&amp;#34;OK, that&amp;#39;s all the help you&amp;#39;ll get. Good luck!&amp;#34;]
var disp_msg;
if (data[&amp;#39;i&amp;#39;]){
var next_val = parseInt(data[&amp;#39;n&amp;#39;]);
$(&amp;#39;#riddle&amp;#39;).attr(&amp;#39;index&amp;#39;,next_val-1);
$(&amp;#39;#riddle&amp;#39;).attr(&amp;#39;next&amp;#39;,next_val);
$(&amp;#39;#riddle&amp;#39;).attr(&amp;#39;word&amp;#39;,data[&amp;#39;w&amp;#39;]);
$(&amp;#39;#riddle&amp;#39;).html(disp_arr[(next_val-1)%12]);
if (next_val%5==0) {
$(&amp;#39;#riddle&amp;#39;).attr(&amp;#39;message&amp;#39;,&amp;#39;Here is another hint for you: it involves some prime numbers. But not in a straightforward way.&amp;#39;);
} else {
$(&amp;#39;#riddle&amp;#39;).removeAttr(&amp;#39;message&amp;#39;);
}
}
else {
$(&amp;#39;#riddle&amp;#39;).attr(&amp;#39;index&amp;#39;,0);
$(&amp;#39;#riddle&amp;#39;).attr(&amp;#39;next&amp;#39;,1);
$(&amp;#39;#riddle&amp;#39;).attr(&amp;#39;word&amp;#39;,&amp;#39;right&amp;#39;);
$(&amp;#39;#riddle&amp;#39;).attr(&amp;#39;message&amp;#39;,&amp;#39;try numbers between 0 and 197&amp;#39;);
disp_msg= &amp;#34;Hey you! There&amp;#39;s a puzzle in here. Click on the arrow for more clues.&amp;#34;;
$(&amp;#39;#riddle&amp;#39;).html(disp_msg);
}
}
function clueFail(data) {
disp_msg= &amp;#34;Whoops! Lots of puzzlers here. Can&amp;#39;t reach the server, sorry. Try later&amp;#34;;
$(&amp;#39;#riddle&amp;#39;).html(disp_msg);
}
function phraseFail(data) {
disp_msg= &amp;#34;Whoops! Lots of puzzlers here. Can&amp;#39;t load the next clue, sorry. Try later&amp;#34;;
typeAns(disp_msg);
}
function submitN() {
switchMCImage();
var i_val = $(&amp;#39;#riddle&amp;#39;).attr(&amp;#39;next&amp;#39;);
req_n = sendData(JSON.stringify({&amp;#39;i&amp;#39;:i_val}),&amp;#39;/clue&amp;#39;);
req_n.done(munchClues);
req_n.fail(clueFail);
}
function munchPhrase(data) {
if (data[&amp;#39;i&amp;#39;]){
typeAns(data[&amp;#39;m&amp;#39;]);
$(&amp;#39;#riddle&amp;#39;).remove();
$(&amp;#39;#nBut&amp;#39;).remove();
$(&amp;#39;#askr&amp;#39;).remove();
}
else {
var wrogn_kholi = Math.floor((Math.random()*16)&amp;#43;1);
if (wrogn_kholi&amp;lt;8) {
typeAns(&amp;#34;Sorry, that isn&amp;#39;t it.&amp;#34;);
}
else {
typeAns(data[&amp;#39;m&amp;#39;]);
}
}
}//munchPhrase
function submitQ() {
if ($(&amp;#39;#answr&amp;#39;).hasClass(&amp;#39;typing&amp;#39;)) {
return true;
}
$(&amp;#39;#answr&amp;#39;).addClass(&amp;#39;typing&amp;#39;);
var sendQuest = true;
var q_val = $.trim($(&amp;#39;textarea&amp;#39;).val()).toLowerCase();
var answer_val;
if ((q_val == &amp;#39;&amp;#39;) || (q_val==&amp;#39;type in the secret phrase...&amp;#39;)){
answer_val = &amp;#34;That isn&amp;#39;t it. Have you tried to solve the puzzle?&amp;#34;;
sendQuest = false;
typeAns(answer_val);
}
else if ((q_val.match(/shit/gi)) || (q_val.match(/fuck/gi)) || (q_val.match(/dumb/gi)) || (q_val.match(/whore/gi))) {
answer_val = &amp;#34;Hey now! No reason to get snappy. Wash your mouth with soap water&amp;#34;;
sendQuest = false;
typeAns(answer_val);
}
else if ((q_val.match(/cricket|baby|ipad|varun|windows|nokia|lumia/gi))) {
answer_val = &amp;#34;No, the clues are not in the images. This is a coding puzzle.&amp;#34;;
sendQuest = false;
typeAns(answer_val);
}
else if ((q_val.match(/aaa/gi)) || (q_val.match(/jjj/gi)) || (q_val.match(/ooo/gi)) || (q_val.match(/abc/gi)) || (q_val.match(/sfg/gi)) || (q_val.match(/jkjk/gi)) || (q_val.match(/sdj/gi)) || (q_val.match(/sdg/gi)) || (q_val.match(/jhg/gi)) || (q_val.match(/asd/gi)) || (q_val.match(/\d/gi)) || (q_val.match(/puz/gi)) || (q_val.match(/rid/gi)) || (q_val.match(/que/gi)) || (q_val.match(/fuc/gi)) || (q_val.match(/shi/gi))) {
answer_val = &amp;#34;You are typing in random strings. That&amp;#39;s a good strategy -- if you have a team of a hundred thousand monkeys&amp;#34;;
sendQuest = false;
typeAns(answer_val);
}
else {
​
req_phrase = sendData(JSON.stringify({&amp;#39;q&amp;#39;:q_val}),&amp;#39;/phrase&amp;#39;);
req_phrase.done(munchPhrase);
req_phrase.fail(phraseFail);
}
} //submitQ
function typeAns(answer_val) {
$(&amp;#39;#answr&amp;#39;).empty();
var wordArray = answer_val.split(&amp;#39; &amp;#39;), i = 0;
INV = setInterval(function () {
if (i &amp;gt;= wordArray.length - 1) {
clearInterval(INV);
$(&amp;#39;textarea&amp;#39;).val(&amp;#39;&amp;#39;);
$(&amp;#39;#answr&amp;#39;).removeClass(&amp;#39;typing&amp;#39;);
switchMCImage();
}
$(&amp;#39;#answr&amp;#39;).append(wordArray[i] &amp;#43; &amp;#39; &amp;#39;);
i&amp;#43;&amp;#43;;
}, 200);
} //typeAns
function switchMCImage() {
var show_logo_int = Math.floor((Math.random()*6)&amp;#43;1);
$(&amp;#39;#makkhiimg&amp;#39;).attr(&amp;#39;src&amp;#39;,&amp;#39;Makkhi/files/makkhi_alt_&amp;#39;&amp;#43;show_logo_int&amp;#43;&amp;#39;.png&amp;#39;)
} //switchMCImage
function typeAnswer(answer_val) {
var wrdArray = answer_val.split(&amp;#39; &amp;#39;), i = 0;
return function(){
if (i &amp;gt;= wrdArray.length - 1) {
clearInterval(INV);
}
$el.append(wrdArray[i] &amp;#43; &amp;#39; &amp;#39;);
} //closure
} //typeAnswer
var orig_img_src;
$(document).ready(function(){
orig_img_src = $(&amp;#39;#rgimg&amp;#39;).attr(&amp;#39;src&amp;#39;);
$(&amp;#39;textarea&amp;#39;).one(&amp;#39;click&amp;#39;,function(){$(this).html(&amp;#39;&amp;#39;);});
$(&amp;#39;#qBut&amp;#39;).click(submitQ);
$(&amp;#39;#nBut&amp;#39;).click(submitN);
$(&amp;#39;textarea&amp;#39;).keypress(function(e){
if(e.keyCode == 13 &amp;amp;&amp;amp; !e.shiftKey) {
e.preventDefault();
if ($(&amp;#39;#answr&amp;#39;).hasClass(&amp;#39;typing&amp;#39;)) {
//do nothing
}
else {
submitQ();
}
}
});
});//documentready
&lt;/code>&lt;/pre>
&lt;/div>
&lt;p>Now I won&amp;rsquo;t say anything more. Rest is up to you.&lt;/p>
&lt;p>If you are scratching your head for the other puzzle (which is fun &amp;amp; a LOT easier), then I will provide a solution for it here.&lt;/p>
&lt;p>You need to put off the javascript timer of the website.&lt;/p>
&lt;p>To do that, just enter this in the URL bar :&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-js" data-lang="js">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#a6e22e">javascript&lt;/span>&lt;span style="color:#f92672">:&lt;/span>window.&lt;span style="color:#a6e22e">setTimeout&lt;/span> &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#66d9ef">function&lt;/span>(&lt;span style="color:#a6e22e">func&lt;/span>, &lt;span style="color:#a6e22e">delay&lt;/span>) {};window.&lt;span style="color:#a6e22e">setInterval&lt;/span> &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#66d9ef">function&lt;/span>(&lt;span style="color:#a6e22e">func&lt;/span>, &lt;span style="color:#a6e22e">delay&lt;/span>) {};document.&lt;span style="color:#a6e22e">getElementById&lt;/span>(&lt;span style="color:#e6db74">&amp;#34;timer&amp;#34;&lt;/span>).&lt;span style="color:#a6e22e">innerHTML&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;200&amp;#34;&lt;/span>;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Now you have 200 seconds for that. And if you have difficulty finding the red box, then hold Ctrl+A and solve the puzzle.&lt;/p>
&lt;p>Thanks for reading!&lt;/p></content></item></channel></rss>