<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>Fascinating engineering Archives - Pietari Heino&#039;s personal website</title>
	<atom:link href="https://www.extreg.com/blog/category/fascinating-engineering/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.extreg.com</link>
	<description></description>
	<lastBuildDate>Sun, 05 Nov 2017 17:09:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.6.7</generator>
<site xmlns="com-wordpress:feed-additions:1">99365322</site>	<item>
		<title>Wicked cool neural network video primer</title>
		<link>https://www.extreg.com/blog/2017/11/wicked-cool-neural-network-video-primer/</link>
					<comments>https://www.extreg.com/blog/2017/11/wicked-cool-neural-network-video-primer/#respond</comments>
		
		<dc:creator><![CDATA[Pietari]]></dc:creator>
		<pubDate>Sun, 05 Nov 2017 17:09:22 +0000</pubDate>
				<category><![CDATA[Fascinating engineering]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[3blue1brown]]></category>
		<category><![CDATA[machine learning]]></category>
		<category><![CDATA[neural networks]]></category>
		<category><![CDATA[video series]]></category>
		<guid isPermaLink="false">https://extreg.com/?p=239</guid>

					<description><![CDATA[<p>One of those people who have heard about neural networks and machine learning n+1 times but don&#8217;t really understand the actual fundamental basics behind it? I surely am. Well, of course I know that there are some ways of training a network with pre-labeled data and then discovering similarities in never-seen data and yada yada ... <span class="more"><a class="more-link" href="https://www.extreg.com/blog/2017/11/wicked-cool-neural-network-video-primer/">[Read more...]</a></span></p>
<p>The post <a rel="nofollow" href="https://www.extreg.com/blog/2017/11/wicked-cool-neural-network-video-primer/">Wicked cool neural network video primer</a> appeared first on <a rel="nofollow" href="https://www.extreg.com">Pietari Heino&#039;s personal website</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>One of those people who have heard about neural networks and machine learning n+1 times but don&#8217;t really understand the actual fundamental basics behind it? I surely am. Well, of course I know that there are some ways of training a network with pre-labeled data and then discovering similarities in never-seen data and yada yada but I&#8217;m not a person to teach the inner workings to anyone. It&#8217;s one of the subjects that are so this and that and buzzing all over the place but I&#8217;ve never found it so interesting that I would have dug into it.</p>
<p>I really suggest you watch <a href="https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw/videos">3Blue1Brown&#8217;s</a> series on the subject. Watch through all of them. Don&#8217;t skip anything.</p>
<p>One of the best series I&#8217;ve seen anywhere. Check them out!</p>
<p><a href="https://www.youtube.com/watch?v=aircAruvnKk" target="_blank" rel="noopener">But what *is* a Neural Network? | Deep learning, chapter 1</a><br />
<a href="https://www.youtube.com/watch?v=IHZwWFHWa-w">Gradient descent, how neural networks learn | Deep learning, chapter 2</a><br />
<a href="https://www.youtube.com/watch?v=Ilg3gGewQ5U">What is backpropagation and what is it actually doing? | Deep learning, chapter 3</a><br />
<a href="https://www.youtube.com/watch?v=tIeHLnjs5U8">Backpropagation calculus | Appendix to deep learning chapter 3</a></p>
<p>The post <a rel="nofollow" href="https://www.extreg.com/blog/2017/11/wicked-cool-neural-network-video-primer/">Wicked cool neural network video primer</a> appeared first on <a rel="nofollow" href="https://www.extreg.com">Pietari Heino&#039;s personal website</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.extreg.com/blog/2017/11/wicked-cool-neural-network-video-primer/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">239</post-id>	</item>
		<item>
		<title>DocHub: so smooth</title>
		<link>https://www.extreg.com/blog/2017/03/dochub-so-smooth/</link>
					<comments>https://www.extreg.com/blog/2017/03/dochub-so-smooth/#respond</comments>
		
		<dc:creator><![CDATA[Pietari]]></dc:creator>
		<pubDate>Fri, 24 Mar 2017 16:40:20 +0000</pubDate>
				<category><![CDATA[Fascinating engineering]]></category>
		<category><![CDATA[dochub]]></category>
		<category><![CDATA[sign pdf]]></category>
		<category><![CDATA[smooth]]></category>
		<guid isPermaLink="false">https://extreg.com/?p=164</guid>

					<description><![CDATA[<p>I had to sign a PDF. I knew Google Drive has been offering me some &#8220;open with&#8221; options for ages and I decided to try DocHub.com. Absolutely brilliant. I opened the pdf I clicked sign They sent me an SMS with a link that opened a &#8220;sign here&#8221; web page I signed, refreshed the original web ... <span class="more"><a class="more-link" href="https://www.extreg.com/blog/2017/03/dochub-so-smooth/">[Read more...]</a></span></p>
<p>The post <a rel="nofollow" href="https://www.extreg.com/blog/2017/03/dochub-so-smooth/">DocHub: so smooth</a> appeared first on <a rel="nofollow" href="https://www.extreg.com">Pietari Heino&#039;s personal website</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I had to sign a PDF. I knew Google Drive has been offering me some &#8220;open with&#8221; options for ages and I decided to try <a href="https://dochub.com/">DocHub.com</a>. Absolutely brilliant.</p>
<ol>
<li>I opened the pdf</li>
<li>I clicked sign</li>
<li>They sent me an SMS with a link that opened a &#8220;sign here&#8221; web page</li>
<li>I signed, refreshed the original web page, and vóila, DocHub let me attach the signature to the document, resize it, change the colouring and so forth</li>
</ol>
<p>Like seriously — they <em><strong>just </strong></em>sent me a text and I opened the link. I didn&#8217;t sign in to any page on my phone. I didn&#8217;t sign in to Google, to DocHub, to anything. It just worked.</p>
<p>One of those moments when you really feel that the engineering work is impeccable and so flawlessly superior to the everyday sw one usually encounters. So good.</p>
<p>The post <a rel="nofollow" href="https://www.extreg.com/blog/2017/03/dochub-so-smooth/">DocHub: so smooth</a> appeared first on <a rel="nofollow" href="https://www.extreg.com">Pietari Heino&#039;s personal website</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.extreg.com/blog/2017/03/dochub-so-smooth/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">164</post-id>	</item>
		<item>
		<title>Google&#8217;s ultra-large-scale monolithic source code repository</title>
		<link>https://www.extreg.com/blog/2017/02/googles-ultra-large-scale-monolithic-source-code-repository/</link>
					<comments>https://www.extreg.com/blog/2017/02/googles-ultra-large-scale-monolithic-source-code-repository/#respond</comments>
		
		<dc:creator><![CDATA[Pietari]]></dc:creator>
		<pubDate>Wed, 15 Feb 2017 08:42:57 +0000</pubDate>
				<category><![CDATA[Fascinating engineering]]></category>
		<category><![CDATA[atk]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google clients in the cloud]]></category>
		<category><![CDATA[google piper]]></category>
		<category><![CDATA[google source-code]]></category>
		<category><![CDATA[google tools]]></category>
		<category><![CDATA[google workflow]]></category>
		<category><![CDATA[piper]]></category>
		<category><![CDATA[trunk-based development]]></category>
		<category><![CDATA[version control]]></category>
		<guid isPermaLink="false">https://extreg.com/?p=142</guid>

					<description><![CDATA[<p>Why Google Stores Billions of Lines of Code in a Single Repository is an excellent paper by Rachel Potvin and Josh Levenberg. They both work at Google, Rachel being an engineering manager and Josh a software engineer. Their writing, published in the Communications of the ACM in July 2016, may be found here. They provide a fascinating ... <span class="more"><a class="more-link" href="https://www.extreg.com/blog/2017/02/googles-ultra-large-scale-monolithic-source-code-repository/">[Read more...]</a></span></p>
<p>The post <a rel="nofollow" href="https://www.extreg.com/blog/2017/02/googles-ultra-large-scale-monolithic-source-code-repository/">Google&#8217;s ultra-large-scale monolithic source code repository</a> appeared first on <a rel="nofollow" href="https://www.extreg.com">Pietari Heino&#039;s personal website</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><em>Why Google Stores Billions of Lines of Code in a Single Repository</em> is an <strong>excellent</strong> paper by Rachel Potvin and Josh Levenberg. They both work at Google, Rachel being an engineering manager and Josh a software engineer. Their writing, published in the Communications of the ACM in July 2016, may be found <a href="http://cacm.acm.org/magazines/2016/7/204032-why-google-stores-billions-of-lines-of-code-in-a-single-repository/fulltext">here</a>. They provide a fascinating deepdive into the way Google handles source code in a monolithic single repository, the trunk based development, the Google workflow, all the Google-built tooling, pros and cons, and an analysis of using a single repo at ultra-scale.</p>
<p>I <strong>really</strong> hope you read the paper, it&#8217;s wicked fascinating software engineering. I liked the piece so much that I decided to read it again and write some notes/summaries of the different topics touched. Scroll through them below and read the paper (which is <strong>vastly more infromative </strong>than what you can find here!).</p>
<p><span id="more-142"></span></p>
<p><strong>Super-shortly:</strong><br />
Pros: unified versioning, extensive code sharing, simplified dependency management, atomic changes, large-scale refactoring, collaboration across teams, flexible code ownership, code visibility<br />
Cons: having to create *and* scale tools for development and exectuion and maintain code health (also a possibility of potential codebase complexity)</p>
<p><strong>The repo:</strong><br />
~1 billion files<br />
~35 million commits<br />
~85 TB of data<br />
~2 billion lines of code<br />
~9 million source files</p>
<p>2014: 15 million lines of code changed in 250,000 files. 25,000 users and avg 500,000 queries per second.<br />
note: most of the traffic comes from Google&#8217;s automated build and test systems</p>
<p>Compare to Linux kernel: ~15 million lines of code in ~40 000 files</p>
<p><strong>Google Piper design</strong><br />
&#8211; stores a single large repository<br />
&#8211; implemented on top of standard Google infra, namely Spanner<br />
&#8211; distributed on 10 datacenters<br />
&#8211; Paxos for replica consistency<br />
&#8211; Google infra and private networks cut the latency and deliver needed speed<br />
&#8211; Google originally used a massive Perforce instance with custom-built caching and other infra for over 10 years</p>
<p><strong>Piper security</strong><br />
&#8211; supports file-level access control lists<br />
&#8211; most of the stuff seen by everyone, anything may be hidden if needed<br />
&#8211; read/write logs; owner can see who viewed, when, and what<br />
&#8211; purgin of accidental critical secrets<br />
&#8211; for instance business critical secrets like algorithms might not be available for everyone (but: over 99 % of all version-controlled stuff is seen by all full-time Googlers)</p>
<p><strong>Piper workflow</strong><br />
&#8211; create a local copy, store files in the developer&#8217;s workspace<br />
&#8211; &#8211; this is like working copy in Subversion, local clone in Git, or client in Perforce<br />
&#8211; pull updates from Piper<br />
&#8211; share the workspace as a snapshot for other devs to review<br />
&#8211; commit *only* after code-review</p>
<p><strong>Clients in the Cloud, or CitC</strong><br />
&#8211; cloud-based storage backend + Linux-only FUSE fs<br />
&#8211; Piper workspaces seen as directories in the fs<br />
&#8211; support the usual Unix tools<br />
&#8211; local changes laid on top<br />
&#8211; browsing, searching, editing any files in the Piper repo<br />
&#8211; only edited files stored locally<br />
&#8211; avg workspace has &lt;10 files while still showing everything in the Piper repo<br />
&#8211; *all writes* stored automatically, can be tagged, named, and rollbacked</p>
<p><strong>Trunk-based development</strong><br />
&#8211; vast majority of Piper users work on &#8220;head&#8221;, &#8220;trunk&#8221;, or &#8220;mainline&#8221;, that is the most recent version of everything<br />
&#8211; all commits in there<br />
&#8211; all changes seen by everyone using Piper after every commit (remember: commits only after code-review)<br />
&#8211; using branches very very rare except for releases<br />
&#8211; releases usually a snapshot of the trunk + cherry-picks from it<br />
&#8211; no dev branches, no feature branches, no nothing<br />
&#8211; feature-development through the use of feature-flags in code<br />
&#8211; feature-flags controlled by conf. files, no need for new binaries<br />
&#8211; feature-flags typically used in project-specific code, not libraries<br />
&#8211; easy to experiment with small amount of users</p>
<p><strong>Code review</strong><br />
&#8211; nothing is committed without a code review<br />
&#8211; the committer can enable a flag for auto-commit if the review passes<br />
&#8211; the reviewers have tools for viewing and adjusting the code easily anywhere in the Piper repo (tools are named Critique and CodeSearch)<br />
&#8211; commits have to be accepted by directory owners<br />
&#8211; remember: the whole Piper repo is availabe for anyone -&gt; anyone can propose changes in any piece of code anywhere, but the owners of directories have to accept them<br />
&#8211; directory owners are the people most familiar with the code/project/library in question</p>
<p><strong>Commit-infra &amp; refactoring</strong><br />
&#8211; automatic rebuild of all dependencies, testing<br />
&#8211; automatic rollback in case of widespread breakage<br />
&#8211; vast and customizable pre-submit testing and analysis, runs before anything is committed<br />
&#8211; static analysis system called Tricorder<br />
&#8211; &#8211; provides data on code quality, test coverage, test results<br />
&#8211; &#8211; provides automatic suggestions for fixes with one-click applying<br />
&#8211; &#8211; triggered after all changes and periodically<br />
&#8211; &#8211; used to ensure codebase health<br />
&#8211; set of devs periodically dig through Piper directories to refactor code in order to keep it healthy<br />
&#8211; large backwards-compatible changes first, removing unused paths second<br />
&#8211; tool called Rosie suppors that by splitting the large patches made by the devs into smaller patches that are individually reviewed by the directory owners</p>
<p><strong>Analysis</strong><br />
<strong>Advantages</strong><br />
&#8211; unified versioning, one source of truth<br />
&#8211; extensive code-sharing and reuse<br />
&#8211; simplified dependency management<br />
&#8211; atomic changes<br />
&#8211; large-scale refactoring<br />
&#8211; collaboration across teams<br />
&#8211; flexible team boundaries, code ownership and visibility, implicit namespacing<br />
&#8211; all code depend on other code directly<br />
&#8211; the diamond-dependency problem is gone<br />
&#8211; atomic changes enable refactorings of variables or api calls for hundreds of thousands of files without test/build breakage (in a single commit)<br />
&#8211; engineers don&#8217;t depend on specific versions -&gt; no need to update them<br />
&#8211; all files uniquely identified<br />
&#8211; a good example:<br />
&#8211; &#8211; the Google compiler team can run regression etc. tests nightly on all affected code and validate new versions<br />
&#8211; &#8211; code can be refactored to support new versions of compilers before shipping them<br />
&#8211; &#8211; ~20 compiler releases a year<br />
&#8211; &#8211; compilers can be tuned to use best possible default settings</p>
<p><strong>Drawbacks, trade-offs etc.</strong><br />
&#8211; tooling investment is HUGE<br />
&#8211; couldn&#8217;t be used without all the special support-systems<br />
&#8211; codebase complexity,<br />
&#8211; unnecessary dependencies<br />
&#8211; discoverity difficulties<br />
&#8211; effort in code health<br />
&#8211; sometimes hard to explore code<br />
&#8211; the usual suspects like grep unusable from time to time<br />
&#8211; too easy to add dependencies -&gt; unused dependencies<br />
&#8211; lack of will to write documentation if everyone can look up the apis themselves<br />
&#8211; depending on more than just the api because you see how the code works</p>
<p><strong>Alternatives</strong><br />
&#8211; the favoring and use of DVCSs has have grown -&gt; moving has been investigated<br />
&#8211; moving to a DVCS (eg Git) would require a split to thousands of repos<br />
&#8211; &#8211; Android is Git hosted and North of 800 repos<br />
&#8211; currently available DCVSs don&#8217;t provide needed security controls<br />
&#8211; investigating whether Mercurial could be made to support Google scale</p>
<p>Checkout the wonderful paper <a href="http://cacm.acm.org/magazines/2016/7/204032-why-google-stores-billions-of-lines-of-code-in-a-single-repository/fulltext">here</a>.</p>
<p>The post <a rel="nofollow" href="https://www.extreg.com/blog/2017/02/googles-ultra-large-scale-monolithic-source-code-repository/">Google&#8217;s ultra-large-scale monolithic source code repository</a> appeared first on <a rel="nofollow" href="https://www.extreg.com">Pietari Heino&#039;s personal website</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.extreg.com/blog/2017/02/googles-ultra-large-scale-monolithic-source-code-repository/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">142</post-id>	</item>
		<item>
		<title>Interesting reading: data compression from Deflate to Zstandard</title>
		<link>https://www.extreg.com/blog/2016/09/interesting-reading-compression-deflate-zstandard/</link>
					<comments>https://www.extreg.com/blog/2016/09/interesting-reading-compression-deflate-zstandard/#respond</comments>
		
		<dc:creator><![CDATA[Pietari]]></dc:creator>
		<pubDate>Thu, 08 Sep 2016 19:21:05 +0000</pubDate>
				<category><![CDATA[Fascinating engineering]]></category>
		<category><![CDATA[data compression]]></category>
		<category><![CDATA[deflate]]></category>
		<category><![CDATA[zstandard]]></category>
		<guid isPermaLink="false">https://extreg.com/?p=84</guid>

					<description><![CDATA[<p>Data compression is a fascinating topic if you ask me. If you&#8217;re curious about it, I suggest you to read these two pieces of nice writing: The Elegance of Deflate and Smaller and faster data compression with Zstandard. The first gives you a deep-dive into the inner-workings of widely used Deflate algorithm and the second ... <span class="more"><a class="more-link" href="https://www.extreg.com/blog/2016/09/interesting-reading-compression-deflate-zstandard/">[Read more...]</a></span></p>
<p>The post <a rel="nofollow" href="https://www.extreg.com/blog/2016/09/interesting-reading-compression-deflate-zstandard/">Interesting reading: data compression from Deflate to Zstandard</a> appeared first on <a rel="nofollow" href="https://www.extreg.com">Pietari Heino&#039;s personal website</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Data compression is a fascinating topic if you ask me. If you&#8217;re curious about it, I suggest you to read these two pieces of nice writing: <a href="http://www.codersnotes.com/notes/elegance-of-deflate/">The Elegance of Deflate</a> and <a href="https://code.facebook.com/posts/1658392934479273/smaller-and-faster-data-compression-with-zstandard/">Smaller and faster data compression with Zstandard</a>.</p>
<p>The first gives you a deep-dive into the inner-workings of widely used Deflate algorithm and the second is a piece from Facebook&#8217;s dev blog introducing their new data compression algorithm Zstandard.</p>
<p>Start with the first one.</p>
<p>The post <a rel="nofollow" href="https://www.extreg.com/blog/2016/09/interesting-reading-compression-deflate-zstandard/">Interesting reading: data compression from Deflate to Zstandard</a> appeared first on <a rel="nofollow" href="https://www.extreg.com">Pietari Heino&#039;s personal website</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.extreg.com/blog/2016/09/interesting-reading-compression-deflate-zstandard/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">84</post-id>	</item>
		<item>
		<title>Control-flow Enforcement Technology to fight against ROP</title>
		<link>https://www.extreg.com/blog/2016/06/control-flow-enforcement-technology-to-fight-against-rop/</link>
					<comments>https://www.extreg.com/blog/2016/06/control-flow-enforcement-technology-to-fight-against-rop/#respond</comments>
		
		<dc:creator><![CDATA[Pietari]]></dc:creator>
		<pubDate>Fri, 24 Jun 2016 10:30:10 +0000</pubDate>
				<category><![CDATA[Fascinating engineering]]></category>
		<category><![CDATA[Things I like]]></category>
		<category><![CDATA[cet]]></category>
		<category><![CDATA[control-flow enforcement technology]]></category>
		<category><![CDATA[endbranch]]></category>
		<category><![CDATA[return-oriented programming]]></category>
		<category><![CDATA[rop]]></category>
		<category><![CDATA[shadow stack]]></category>
		<category><![CDATA[stack]]></category>
		<guid isPermaLink="false">https://extreg.com/?p=64</guid>

					<description><![CDATA[<p>In this blog post I&#8217;m writing about something that I consider really interesting and also very fascinating from the engineering perspective. I&#8217;m a huge fan of computer security related stuff and am intrigued by the many branches (ha!) it covers top to bottom with so many different aspects that you really cannot know everything at ... <span class="more"><a class="more-link" href="https://www.extreg.com/blog/2016/06/control-flow-enforcement-technology-to-fight-against-rop/">[Read more...]</a></span></p>
<p>The post <a rel="nofollow" href="https://www.extreg.com/blog/2016/06/control-flow-enforcement-technology-to-fight-against-rop/">Control-flow Enforcement Technology to fight against ROP</a> appeared first on <a rel="nofollow" href="https://www.extreg.com">Pietari Heino&#039;s personal website</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In this blog post I&#8217;m writing about something that I consider really interesting and also very fascinating from the engineering perspective. I&#8217;m a huge fan of computer security related stuff and am intrigued by the many branches (ha!) it covers top to bottom with so many different aspects that you really cannot know everything at all. There&#8217;s always so much more to discover. This is not supposed to be a deep-dive or a complete guide to anything at all, more than just to give you a brief introduction to something that you could also find interesting and possibly study on your own. <strong>Please</strong>, if you don&#8217;t read this posting, at least checkout the link from the second to last paragraph!</p>
<p>So back in the day CPU architectures introduced the stack in order to allow better control of the programs&#8217; execution flow and for instance make recursion possible (if it&#8217;s not clear for you, read this post and try to come up with the reason why you cannot have recursion without the stack!). Nowadays stack is a must and you cannot find a piece of hardware executing software without a stack (as far as I know). The stack is interesting. It grows with the push operations and decreases with the pop operations. Every time the CPU calls a new function the stack is grown and every time the execution of a function is over the stack is decreased. What goes in there, specifically, are the local variables for a function and the return address to use after the execution. So lets say the CPU calls a void function called <em>count </em>that is supposed to print numbers from 0 to 10. What we push to the stack is the return address which is the address of the next instruction that is supposed to be executed right after the function is done and space for the <em>count&#8217;s </em>local variables (it supposedly needs a loop and a loop variable). When <em>count </em>is done, we decrease the stack with pop operation which then gets rid off the <em>count&#8217;s </em>local variables and returns the execution to the location pushed to the stack earlier. It grows dynamically, so to say, and the whole thing is really interesting, the way it works and the cleverness of it. It&#8217;s automatically grown and decreased and always keeps each functions&#8217; environments intact and stores the addresses for continuing execution. It&#8217;s very simple but really powerful at the same time.</p>
<div id="attachment_66" style="width: 315px" class="wp-caption alignright"><a href="https://extreg.com/blog/2016/06/control-flow-enforcement-technology-to-fight-against-rop/ars-technica-basic-stack-exploit-trampoline/"><img aria-describedby="caption-attachment-66" loading="lazy" class="wp-image-66" src="https://extreg.com/wp-content/uploads/2016/06/ars-technica-basic-stack-exploit-trampoline-837x1024.png" alt="Stack exploiting trampoline, (c) Ars Technica" width="305" height="373" srcset="https://www.extreg.com/wp-content/uploads/2016/06/ars-technica-basic-stack-exploit-trampoline-837x1024.png 837w, https://www.extreg.com/wp-content/uploads/2016/06/ars-technica-basic-stack-exploit-trampoline-245x300.png 245w, https://www.extreg.com/wp-content/uploads/2016/06/ars-technica-basic-stack-exploit-trampoline-768x939.png 768w, https://www.extreg.com/wp-content/uploads/2016/06/ars-technica-basic-stack-exploit-trampoline.png 1502w" sizes="(max-width: 305px) 100vw, 305px" /></a><p id="caption-attachment-66" class="wp-caption-text">Stack exploiting trampoline, (c) Ars Technica</p></div>
<p><strong>The problem is&#8230; </strong>what if an adversary party could write some malicious code into your stack and override the bits that holds the information where to go next? Specifically, overwrite the return address from the stack with a return address of the party&#8217;s own. That would inherently make the control flow jump to execute whatever the malicious party wanted. That&#8217;s what bad guys started doing and which lead to DEP and ASRL. DEP stands for Data Execution Protection, a technology which separates the dynamic, software written data from the instructions that the CPU is going to execute. ASRL stands for Address-Space Layout Randomization, which changes the location of the software, the kernel code, the operating system&#8217;s libraries, and so forth, in the RAM so that the malicious party cannot know where certain pieces of software logic lies in the address-space which makes the use of known locations of useful code a no-go for execution. <strong>DEP and ASRL </strong>are both themselves really fascinating stuff and if you&#8217;re interested, go check them out in more detail, my few words here don&#8217;t really get you covered on them at all.</p>
<p><strong>Return-Oriented Programming (ROP) </strong>is a way of getting control of the stack and changing bits and pieces of software logic towards the end of subroutines so that the CPU would then execute code that would diverge the program flow to an adversary route. That would of course, done correctly, lead to takeover of the operating system since the malicious party could execute whatever it wishes. Now Intel and Microsoft have come up with a new piece of fascinating technology called <strong>Control-Flow Enforcement Technology </strong>that adds more protection specifically to the stack operations. There are two new things to fight the problem:</p>
<ol>
<li><strong>ENDBRANCH</strong> instruction is added to the new x86/x64 architecture instructions sets. When the software is compiled with a CET supporting compiler that targets new CPUs, all legal (valid) calls and jumps are directed to an endbranch instruction. That is to say that whenever a subroutine is called, the first instruction to be found inside the subroutine must be an endbranch. If it&#8217;s not, the CPU throws an exception and the hell breaks loose. So the program gets compiled in a way that the subroutine/call/jump flow is <em><strong>enforced</strong></em> to obey the original intent of the programmer – thus the name Control-Flow Enforcement. Today&#8217;s processors can return to any valid place the kernel lets them to return to no matter what instructions lie there, but that&#8217;s going to be changed with CET. That makes it impossible for an attacker to redirect the program flow for example into middle of a library or so that could then lead to overtake. The brilliance of the endbranch instruction is that it&#8217;s implemented as a NOP in all the current Intel chips so it&#8217;s 100 % backwards compatible and requires no tricks from the software programmer.</li>
<li><strong>Shadow stack</strong> which is a separate, hidden, you-cannot-touch-me stack living along the usual stack. For all the calls and jumps the software makes the return addresses are pushed to the stack but on the new chips they are also pushed to a new shadow stack – which happens automatically. Then when the pop op comes and it&#8217;s time for returning to a previous location, the CPU checks whether both the shadow stack and the normal stack have the same return address or not. If they match, ok, continue execution. If they don&#8217;t match, it means that someone has had their fingers on the normal stack&#8217;s return address and that all execution should be stopped. The programmer has no any sort of control over the shadow stack, it just operates in the background and is implemented in the hardware so that you cannot trick it nor touch it.</li>
</ol>
<p>Together these two additions will make it absurdly hard to alter the execution flow.</p>
<p>If you found any of this interesting, do your homework for DEP, ASRL, CET and before that, take a look at Ars Techinca&#8217;s brilliant article <em><strong><a href="http://arstechnica.com/security/2015/08/how-security-flaws-work-the-buffer-overflow/">How security flaws work: The buff</a></strong><strong><a href="http://arstechnica.com/security/2015/08/how-security-flaws-work-the-buffer-overflow/">er</a></strong><strong><a href="http://arstechnica.com/security/2015/08/how-security-flaws-work-the-buffer-overflow/"> overflow</a></strong></em>. That&#8217;s a really nice piece on the whole stack and the security questions around it and gives you many pointers for more things to discover.</p>
<p>Some links: <a href="https://blogs.intel.com/evangelists/2016/06/09/intel-release-new-technology-specifications-protect-rop-attacks/">Intel&#8217;s blogposting</a>, <a href="https://en.wikipedia.org/wiki/Return-oriented_programming">ROP on Wikipedia</a>, <a href="https://twit.tv/shows/security-now/episodes/565?autostart=false">TWIT.tv episode of Security Now</a></p>
<p>The post <a rel="nofollow" href="https://www.extreg.com/blog/2016/06/control-flow-enforcement-technology-to-fight-against-rop/">Control-flow Enforcement Technology to fight against ROP</a> appeared first on <a rel="nofollow" href="https://www.extreg.com">Pietari Heino&#039;s personal website</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.extreg.com/blog/2016/06/control-flow-enforcement-technology-to-fight-against-rop/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">64</post-id>	</item>
	</channel>
</rss>
