WEBVTT
Kind: captions
Language: en

00:00:00.240 --> 00:00:01.670 align:start position:0%
 
Today<00:00:00.560><c> we're</c><00:00:00.719><c> going</c><00:00:00.800><c> to</c><00:00:00.880><c> look</c><00:00:01.040><c> at</c><00:00:01.199><c> a</c><00:00:01.360><c> common</c>

00:00:01.670 --> 00:00:01.680 align:start position:0%
Today we're going to look at a common
 

00:00:01.680 --> 00:00:03.750 align:start position:0%
Today we're going to look at a common
vulnerability<00:00:02.240><c> type</c><00:00:02.639><c> seen</c><00:00:02.879><c> across</c><00:00:03.120><c> the</c><00:00:03.360><c> iOS</c>

00:00:03.750 --> 00:00:03.760 align:start position:0%
vulnerability type seen across the iOS
 

00:00:03.760 --> 00:00:06.070 align:start position:0%
vulnerability type seen across the iOS
and<00:00:04.000><c> Mac</c><00:00:04.160><c> OS</c><00:00:04.480><c> platforms</c><00:00:05.200><c> and</c><00:00:05.440><c> a</c><00:00:05.680><c> specific</c>

00:00:06.070 --> 00:00:06.080 align:start position:0%
and Mac OS platforms and a specific
 

00:00:06.080 --> 00:00:07.909 align:start position:0%
and Mac OS platforms and a specific
kernel<00:00:06.480><c> bug</c><00:00:06.640><c> that</c><00:00:06.879><c> was</c><00:00:07.040><c> present</c><00:00:07.279><c> even</c><00:00:07.520><c> in</c><00:00:07.759><c> the</c>

00:00:07.909 --> 00:00:07.919 align:start position:0%
kernel bug that was present even in the
 

00:00:07.919 --> 00:00:09.990 align:start position:0%
kernel bug that was present even in the
original<00:00:08.320><c> iPhone</c><00:00:08.800><c> and</c><00:00:09.040><c> was</c><00:00:09.200><c> exploited</c><00:00:09.679><c> in</c><00:00:09.920><c> the</c>

00:00:09.990 --> 00:00:10.000 align:start position:0%
original iPhone and was exploited in the
 

00:00:10.000 --> 00:00:12.870 align:start position:0%
original iPhone and was exploited in the
wild<00:00:10.320><c> in</c><00:00:10.719><c> 2017.</c><00:00:11.599><c> These</c><00:00:11.920><c> types</c><00:00:12.080><c> of</c><00:00:12.240><c> bugs</c><00:00:12.559><c> are</c>

00:00:12.870 --> 00:00:12.880 align:start position:0%
wild in 2017. These types of bugs are
 

00:00:12.880 --> 00:00:15.270 align:start position:0%
wild in 2017. These types of bugs are
reference<00:00:13.360><c> counting</c><00:00:13.840><c> use</c><00:00:14.080><c> after</c><00:00:14.400><c> freeze.</c><00:00:15.040><c> If</c>

00:00:15.270 --> 00:00:15.280 align:start position:0%
reference counting use after freeze. If
 

00:00:15.280 --> 00:00:16.870 align:start position:0%
reference counting use after freeze. If
you<00:00:15.440><c> appreciate</c><00:00:15.759><c> the</c><00:00:16.000><c> research</c><00:00:16.400><c> effort</c><00:00:16.640><c> that</c>

00:00:16.870 --> 00:00:16.880 align:start position:0%
you appreciate the research effort that
 

00:00:16.880 --> 00:00:18.470 align:start position:0%
you appreciate the research effort that
goes<00:00:17.119><c> into</c><00:00:17.359><c> making</c><00:00:17.760><c> technical</c><00:00:18.160><c> video</c>

00:00:18.470 --> 00:00:18.480 align:start position:0%
goes into making technical video
 

00:00:18.480 --> 00:00:20.390 align:start position:0%
goes into making technical video
breakdowns<00:00:18.960><c> like</c><00:00:19.119><c> this,</c><00:00:19.680><c> then</c><00:00:19.920><c> consider</c>

00:00:20.390 --> 00:00:20.400 align:start position:0%
breakdowns like this, then consider
 

00:00:20.400 --> 00:00:22.230 align:start position:0%
breakdowns like this, then consider
subscribing<00:00:20.880><c> and</c><00:00:21.199><c> liking</c><00:00:21.520><c> this</c><00:00:21.760><c> video</c><00:00:22.000><c> to</c>

00:00:22.230 --> 00:00:22.240 align:start position:0%
subscribing and liking this video to
 

00:00:22.240 --> 00:00:24.150 align:start position:0%
subscribing and liking this video to
help<00:00:22.480><c> the</c><00:00:22.640><c> growth</c><00:00:22.880><c> of</c><00:00:23.039><c> this</c><00:00:23.279><c> channel.</c><00:00:23.760><c> As</c><00:00:24.000><c> a</c>

00:00:24.150 --> 00:00:24.160 align:start position:0%
help the growth of this channel. As a
 

00:00:24.160 --> 00:00:25.509 align:start position:0%
help the growth of this channel. As a
programmer,<00:00:24.560><c> you're</c><00:00:24.800><c> familiar</c><00:00:25.119><c> with</c><00:00:25.279><c> the</c>

00:00:25.509 --> 00:00:25.519 align:start position:0%
programmer, you're familiar with the
 

00:00:25.519 --> 00:00:27.670 align:start position:0%
programmer, you're familiar with the
concept<00:00:25.760><c> of</c><00:00:26.080><c> allocating</c><00:00:26.640><c> and</c><00:00:26.960><c> deallocating</c>

00:00:27.670 --> 00:00:27.680 align:start position:0%
concept of allocating and deallocating
 

00:00:27.680 --> 00:00:29.750 align:start position:0%
concept of allocating and deallocating
memory.<00:00:28.080><c> In</c><00:00:28.320><c> a</c><00:00:28.480><c> language</c><00:00:28.720><c> like</c><00:00:29.039><c> C,</c><00:00:29.439><c> you</c><00:00:29.599><c> call</c>

00:00:29.750 --> 00:00:29.760 align:start position:0%
memory. In a language like C, you call
 

00:00:29.760 --> 00:00:31.990 align:start position:0%
memory. In a language like C, you call
the<00:00:29.920><c> Malo</c><00:00:30.400><c> function</c><00:00:30.720><c> to</c><00:00:30.960><c> request</c><00:00:31.359><c> a</c><00:00:31.599><c> block</c><00:00:31.840><c> of</c>

00:00:31.990 --> 00:00:32.000 align:start position:0%
the Malo function to request a block of
 

00:00:32.000 --> 00:00:33.830 align:start position:0%
the Malo function to request a block of
memory<00:00:32.239><c> of</c><00:00:32.399><c> a</c><00:00:32.559><c> chosen</c><00:00:32.880><c> size</c><00:00:33.520><c> and</c><00:00:33.680><c> the</c>

00:00:33.830 --> 00:00:33.840 align:start position:0%
memory of a chosen size and the
 

00:00:33.840 --> 00:00:35.590 align:start position:0%
memory of a chosen size and the
allocator<00:00:34.480><c> does</c><00:00:34.640><c> some</c><00:00:34.880><c> magic</c><00:00:35.200><c> behind</c><00:00:35.440><c> the</c>

00:00:35.590 --> 00:00:35.600 align:start position:0%
allocator does some magic behind the
 

00:00:35.600 --> 00:00:37.910 align:start position:0%
allocator does some magic behind the
scenes<00:00:36.160><c> and</c><00:00:36.320><c> then</c><00:00:36.559><c> provides</c><00:00:36.960><c> you</c><00:00:37.120><c> with</c><00:00:37.360><c> a</c><00:00:37.680><c> nice</c>

00:00:37.910 --> 00:00:37.920 align:start position:0%
scenes and then provides you with a nice
 

00:00:37.920 --> 00:00:40.229 align:start position:0%
scenes and then provides you with a nice
empty<00:00:38.320><c> region</c><00:00:38.559><c> of</c><00:00:38.719><c> memory</c><00:00:39.280><c> of</c><00:00:39.520><c> that</c><00:00:39.760><c> requested</c>

00:00:40.229 --> 00:00:40.239 align:start position:0%
empty region of memory of that requested
 

00:00:40.239 --> 00:00:41.990 align:start position:0%
empty region of memory of that requested
size<00:00:40.480><c> for</c><00:00:40.640><c> you</c><00:00:40.800><c> to</c><00:00:40.960><c> work</c><00:00:41.120><c> with.</c><00:00:41.520><c> Once</c><00:00:41.840><c> you're</c>

00:00:41.990 --> 00:00:42.000 align:start position:0%
size for you to work with. Once you're
 

00:00:42.000 --> 00:00:43.510 align:start position:0%
size for you to work with. Once you're
done<00:00:42.239><c> using</c><00:00:42.480><c> the</c><00:00:42.640><c> memory</c><00:00:42.879><c> for</c><00:00:43.120><c> whichever</c>

00:00:43.510 --> 00:00:43.520 align:start position:0%
done using the memory for whichever
 

00:00:43.520 --> 00:00:45.110 align:start position:0%
done using the memory for whichever
task,<00:00:44.079><c> you</c><00:00:44.239><c> should</c><00:00:44.399><c> free</c><00:00:44.559><c> it</c><00:00:44.719><c> back</c><00:00:44.879><c> to</c><00:00:44.960><c> the</c>

00:00:45.110 --> 00:00:45.120 align:start position:0%
task, you should free it back to the
 

00:00:45.120 --> 00:00:47.270 align:start position:0%
task, you should free it back to the
allocator<00:00:45.600><c> by</c><00:00:45.760><c> calling</c><00:00:46.239><c> free.</c><00:00:46.800><c> This</c><00:00:47.039><c> allows</c>

00:00:47.270 --> 00:00:47.280 align:start position:0%
allocator by calling free. This allows
 

00:00:47.280 --> 00:00:49.110 align:start position:0%
allocator by calling free. This allows
that<00:00:47.520><c> block</c><00:00:47.760><c> to</c><00:00:47.920><c> be</c><00:00:48.079><c> reused</c><00:00:48.399><c> at</c><00:00:48.559><c> a</c><00:00:48.719><c> later</c><00:00:48.960><c> point</c>

00:00:49.110 --> 00:00:49.120 align:start position:0%
that block to be reused at a later point
 

00:00:49.120 --> 00:00:50.950 align:start position:0%
that block to be reused at a later point
in<00:00:49.360><c> the</c><00:00:49.520><c> program</c><00:00:49.760><c> for</c><00:00:50.000><c> something</c><00:00:50.239><c> else.</c>

00:00:50.950 --> 00:00:50.960 align:start position:0%
in the program for something else.
 

00:00:50.960 --> 00:00:52.549 align:start position:0%
in the program for something else.
Freeing<00:00:51.280><c> the</c><00:00:51.440><c> memory</c><00:00:51.600><c> that</c><00:00:51.760><c> is</c><00:00:51.920><c> no</c><00:00:52.160><c> longer</c><00:00:52.320><c> in</c>

00:00:52.549 --> 00:00:52.559 align:start position:0%
Freeing the memory that is no longer in
 

00:00:52.559 --> 00:00:54.069 align:start position:0%
Freeing the memory that is no longer in
use<00:00:52.719><c> is</c><00:00:52.960><c> of</c><00:00:53.120><c> course</c><00:00:53.280><c> very</c><00:00:53.600><c> important</c>

00:00:54.069 --> 00:00:54.079 align:start position:0%
use is of course very important
 

00:00:54.079 --> 00:00:55.910 align:start position:0%
use is of course very important
especially<00:00:54.399><c> in</c><00:00:54.719><c> larger</c><00:00:55.199><c> complex</c><00:00:55.600><c> programs</c>

00:00:55.910 --> 00:00:55.920 align:start position:0%
especially in larger complex programs
 

00:00:55.920 --> 00:00:57.910 align:start position:0%
especially in larger complex programs
like<00:00:56.079><c> the</c><00:00:56.239><c> kernel</c><00:00:56.559><c> itself</c><00:00:57.280><c> where</c><00:00:57.520><c> without</c>

00:00:57.910 --> 00:00:57.920 align:start position:0%
like the kernel itself where without
 

00:00:57.920 --> 00:00:59.670 align:start position:0%
like the kernel itself where without
freeing<00:00:58.239><c> any</c><00:00:58.480><c> old</c><00:00:58.640><c> allocations</c><00:00:59.280><c> you</c><00:00:59.520><c> would</c>

00:00:59.670 --> 00:00:59.680 align:start position:0%
freeing any old allocations you would
 

00:00:59.680 --> 00:01:01.670 align:start position:0%
freeing any old allocations you would
risk<00:01:00.000><c> exhausting</c><00:01:00.640><c> all</c><00:01:00.800><c> the</c><00:01:00.960><c> memory</c><00:01:01.280><c> capacity</c>

00:01:01.670 --> 00:01:01.680 align:start position:0%
risk exhausting all the memory capacity
 

00:01:01.680 --> 00:01:03.670 align:start position:0%
risk exhausting all the memory capacity
available<00:01:02.480><c> leaving</c><00:01:02.719><c> the</c><00:01:02.960><c> system</c><00:01:03.199><c> no</c><00:01:03.440><c> choice</c>

00:01:03.670 --> 00:01:03.680 align:start position:0%
available leaving the system no choice
 

00:01:03.680 --> 00:01:05.910 align:start position:0%
available leaving the system no choice
but<00:01:03.840><c> to</c><00:01:04.000><c> terminate.</c><00:01:04.640><c> Keeping</c><00:01:05.119><c> track</c><00:01:05.360><c> of</c><00:01:05.600><c> which</c>

00:01:05.910 --> 00:01:05.920 align:start position:0%
but to terminate. Keeping track of which
 

00:01:05.920 --> 00:01:07.910 align:start position:0%
but to terminate. Keeping track of which
allocations<00:01:06.640><c> are</c><00:01:06.880><c> actually</c><00:01:07.200><c> in</c><00:01:07.439><c> use</c><00:01:07.680><c> and</c>

00:01:07.910 --> 00:01:07.920 align:start position:0%
allocations are actually in use and
 

00:01:07.920 --> 00:01:09.670 align:start position:0%
allocations are actually in use and
which<00:01:08.080><c> ones</c><00:01:08.320><c> you</c><00:01:08.479><c> can</c><00:01:08.720><c> free</c><00:01:09.200><c> can</c><00:01:09.439><c> actually</c>

00:01:09.670 --> 00:01:09.680 align:start position:0%
which ones you can free can actually
 

00:01:09.680 --> 00:01:11.190 align:start position:0%
which ones you can free can actually
become<00:01:10.000><c> quite</c><00:01:10.159><c> a</c><00:01:10.320><c> difficult</c><00:01:10.560><c> task</c><00:01:10.799><c> of</c><00:01:10.960><c> its</c>

00:01:11.190 --> 00:01:11.200 align:start position:0%
become quite a difficult task of its
 

00:01:11.200 --> 00:01:12.870 align:start position:0%
become quite a difficult task of its
own.<00:01:11.360><c> However,</c><00:01:11.840><c> in</c><00:01:12.000><c> programs</c><00:01:12.400><c> where</c><00:01:12.560><c> you</c><00:01:12.720><c> have</c>

00:01:12.870 --> 00:01:12.880 align:start position:0%
own. However, in programs where you have
 

00:01:12.880 --> 00:01:14.710 align:start position:0%
own. However, in programs where you have
hundreds<00:01:13.200><c> of</c><00:01:13.360><c> functions</c><00:01:13.840><c> all</c><00:01:14.080><c> operating</c><00:01:14.560><c> at</c>

00:01:14.710 --> 00:01:14.720 align:start position:0%
hundreds of functions all operating at
 

00:01:14.720 --> 00:01:16.550 align:start position:0%
hundreds of functions all operating at
once<00:01:15.040><c> and</c><00:01:15.280><c> all</c><00:01:15.520><c> making</c><00:01:15.840><c> use</c><00:01:16.080><c> of</c><00:01:16.240><c> shared</c>

00:01:16.550 --> 00:01:16.560 align:start position:0%
once and all making use of shared
 

00:01:16.560 --> 00:01:18.550 align:start position:0%
once and all making use of shared
resources,<00:01:17.439><c> it</c><00:01:17.600><c> can</c><00:01:17.759><c> be</c><00:01:17.840><c> almost</c><00:01:18.080><c> impossible</c>

00:01:18.550 --> 00:01:18.560 align:start position:0%
resources, it can be almost impossible
 

00:01:18.560 --> 00:01:20.550 align:start position:0%
resources, it can be almost impossible
to<00:01:18.720><c> know</c><00:01:18.960><c> if</c><00:01:19.200><c> an</c><00:01:19.360><c> object</c><00:01:19.680><c> should</c><00:01:19.920><c> be</c><00:01:20.080><c> freed</c><00:01:20.400><c> or</c>

00:01:20.550 --> 00:01:20.560 align:start position:0%
to know if an object should be freed or
 

00:01:20.560 --> 00:01:22.469 align:start position:0%
to know if an object should be freed or
if<00:01:20.720><c> something</c><00:01:20.960><c> else</c><00:01:21.119><c> is</c><00:01:21.360><c> currently</c><00:01:21.680><c> using</c><00:01:21.920><c> it.</c>

00:01:22.469 --> 00:01:22.479 align:start position:0%
if something else is currently using it.
 

00:01:22.479 --> 00:01:24.070 align:start position:0%
if something else is currently using it.
And<00:01:22.640><c> here</c><00:01:22.880><c> is</c><00:01:23.040><c> where</c><00:01:23.280><c> reference</c><00:01:23.680><c> counting</c>

00:01:24.070 --> 00:01:24.080 align:start position:0%
And here is where reference counting
 

00:01:24.080 --> 00:01:26.070 align:start position:0%
And here is where reference counting
comes<00:01:24.320><c> into</c><00:01:24.560><c> play.</c><00:01:24.960><c> To</c><00:01:25.200><c> solve</c><00:01:25.439><c> this</c><00:01:25.600><c> issue,</c>

00:01:26.070 --> 00:01:26.080 align:start position:0%
comes into play. To solve this issue,
 

00:01:26.080 --> 00:01:27.670 align:start position:0%
comes into play. To solve this issue,
many<00:01:26.400><c> systems</c><00:01:26.799><c> implement</c><00:01:27.280><c> reference</c>

00:01:27.670 --> 00:01:27.680 align:start position:0%
many systems implement reference
 

00:01:27.680 --> 00:01:29.670 align:start position:0%
many systems implement reference
counting<00:01:28.159><c> to</c><00:01:28.400><c> help</c><00:01:28.560><c> keep</c><00:01:28.880><c> track</c><00:01:29.200><c> of</c><00:01:29.439><c> this</c>

00:01:29.670 --> 00:01:29.680 align:start position:0%
counting to help keep track of this
 

00:01:29.680 --> 00:01:32.950 align:start position:0%
counting to help keep track of this
mess.<00:01:30.400><c> The</c><00:01:30.640><c> idea</c><00:01:30.960><c> is</c><00:01:31.119><c> very</c><00:01:31.439><c> simple.</c><00:01:32.400><c> Store</c><00:01:32.720><c> an</c>

00:01:32.950 --> 00:01:32.960 align:start position:0%
mess. The idea is very simple. Store an
 

00:01:32.960 --> 00:01:35.670 align:start position:0%
mess. The idea is very simple. Store an
integer<00:01:33.439><c> field</c><00:01:33.840><c> on</c><00:01:34.159><c> each</c><00:01:34.479><c> allocated</c><00:01:35.040><c> object</c>

00:01:35.670 --> 00:01:35.680 align:start position:0%
integer field on each allocated object
 

00:01:35.680 --> 00:01:37.830 align:start position:0%
integer field on each allocated object
known<00:01:36.000><c> as</c><00:01:36.159><c> the</c><00:01:36.400><c> reference</c><00:01:36.799><c> count.</c><00:01:37.439><c> Whenever</c>

00:01:37.830 --> 00:01:37.840 align:start position:0%
known as the reference count. Whenever
 

00:01:37.840 --> 00:01:39.590 align:start position:0%
known as the reference count. Whenever
some<00:01:38.079><c> function</c><00:01:38.479><c> plans</c><00:01:38.799><c> on</c><00:01:39.119><c> using</c><00:01:39.360><c> this</c>

00:01:39.590 --> 00:01:39.600 align:start position:0%
some function plans on using this
 

00:01:39.600 --> 00:01:42.069 align:start position:0%
some function plans on using this
allocated<00:01:40.159><c> object,</c><00:01:40.799><c> it</c><00:01:41.040><c> first</c><00:01:41.360><c> starts</c><00:01:41.759><c> by</c>

00:01:42.069 --> 00:01:42.079 align:start position:0%
allocated object, it first starts by
 

00:01:42.079 --> 00:01:43.749 align:start position:0%
allocated object, it first starts by
taking<00:01:42.400><c> a</c><00:01:42.640><c> reference</c><00:01:42.960><c> on</c><00:01:43.119><c> it.</c><00:01:43.439><c> In</c><00:01:43.600><c> other</c>

00:01:43.749 --> 00:01:43.759 align:start position:0%
taking a reference on it. In other
 

00:01:43.759 --> 00:01:45.749 align:start position:0%
taking a reference on it. In other
words,<00:01:44.079><c> it</c><00:01:44.320><c> increments</c><00:01:44.880><c> this</c><00:01:45.119><c> counter</c><00:01:45.439><c> value</c>

00:01:45.749 --> 00:01:45.759 align:start position:0%
words, it increments this counter value
 

00:01:45.759 --> 00:01:47.749 align:start position:0%
words, it increments this counter value
by<00:01:46.079><c> one.</c><00:01:46.560><c> And</c><00:01:46.720><c> when</c><00:01:46.880><c> it's</c><00:01:47.119><c> finished</c><00:01:47.360><c> using</c><00:01:47.600><c> the</c>

00:01:47.749 --> 00:01:47.759 align:start position:0%
by one. And when it's finished using the
 

00:01:47.759 --> 00:01:49.749 align:start position:0%
by one. And when it's finished using the
object,<00:01:48.159><c> it</c><00:01:48.399><c> will</c><00:01:48.560><c> release</c><00:01:48.960><c> or</c><00:01:49.280><c> drop</c><00:01:49.520><c> a</c>

00:01:49.749 --> 00:01:49.759 align:start position:0%
object, it will release or drop a
 

00:01:49.759 --> 00:01:51.749 align:start position:0%
object, it will release or drop a
reference<00:01:50.079><c> count.</c><00:01:50.799><c> In</c><00:01:50.960><c> other</c><00:01:51.119><c> words,</c><00:01:51.360><c> it</c><00:01:51.600><c> will</c>

00:01:51.749 --> 00:01:51.759 align:start position:0%
reference count. In other words, it will
 

00:01:51.759 --> 00:01:53.670 align:start position:0%
reference count. In other words, it will
decrement<00:01:52.159><c> the</c><00:01:52.320><c> counter</c><00:01:52.640><c> value</c><00:01:52.880><c> by</c><00:01:53.119><c> one.</c>

00:01:53.670 --> 00:01:53.680 align:start position:0%
decrement the counter value by one.
 

00:01:53.680 --> 00:01:55.109 align:start position:0%
decrement the counter value by one.
Incrementing<00:01:54.320><c> and</c><00:01:54.479><c> decrement</c><00:01:54.799><c> in</c><00:01:55.040><c> the</c>

00:01:55.109 --> 00:01:55.119 align:start position:0%
Incrementing and decrement in the
 

00:01:55.119 --> 00:01:56.389 align:start position:0%
Incrementing and decrement in the
reference<00:01:55.439><c> counter</c><00:01:55.840><c> is</c><00:01:56.079><c> normally</c>

00:01:56.389 --> 00:01:56.399 align:start position:0%
reference counter is normally
 

00:01:56.399 --> 00:01:59.350 align:start position:0%
reference counter is normally
implemented<00:01:57.040><c> as</c><00:01:57.360><c> a</c><00:01:57.600><c> pair</c><00:01:57.840><c> of</c><00:01:58.000><c> functions</c><00:01:58.880><c> named</c>

00:01:59.350 --> 00:01:59.360 align:start position:0%
implemented as a pair of functions named
 

00:01:59.360 --> 00:02:01.830 align:start position:0%
implemented as a pair of functions named
something<00:01:59.600><c> like</c><00:01:59.920><c> reference</c><00:02:00.479><c> and</c><00:02:00.880><c> release.</c>

00:02:01.830 --> 00:02:01.840 align:start position:0%
something like reference and release.
 

00:02:01.840 --> 00:02:03.670 align:start position:0%
something like reference and release.
reference<00:02:02.320><c> simply</c><00:02:02.640><c> has</c><00:02:02.799><c> the</c><00:02:03.040><c> job</c><00:02:03.280><c> of</c><00:02:03.520><c> doing</c>

00:02:03.670 --> 00:02:03.680 align:start position:0%
reference simply has the job of doing
 

00:02:03.680 --> 00:02:05.990 align:start position:0%
reference simply has the job of doing
the<00:02:03.920><c> atomic</c><00:02:04.479><c> increment</c><00:02:04.960><c> on</c><00:02:05.119><c> the</c><00:02:05.280><c> counter.</c>

00:02:05.990 --> 00:02:06.000 align:start position:0%
the atomic increment on the counter.
 

00:02:06.000 --> 00:02:07.830 align:start position:0%
the atomic increment on the counter.
Whereas<00:02:06.399><c> release</c><00:02:06.719><c> has</c><00:02:06.960><c> the</c><00:02:07.119><c> job</c><00:02:07.280><c> of</c><00:02:07.439><c> doing</c><00:02:07.680><c> the</c>

00:02:07.830 --> 00:02:07.840 align:start position:0%
Whereas release has the job of doing the
 

00:02:07.840 --> 00:02:10.309 align:start position:0%
Whereas release has the job of doing the
atomic<00:02:08.319><c> decrement</c><00:02:08.879><c> but</c><00:02:09.200><c> then</c><00:02:09.360><c> also</c><00:02:09.840><c> checking</c>

00:02:10.309 --> 00:02:10.319 align:start position:0%
atomic decrement but then also checking
 

00:02:10.319 --> 00:02:12.869 align:start position:0%
atomic decrement but then also checking
if<00:02:10.560><c> the</c><00:02:10.720><c> counter</c><00:02:11.039><c> value</c><00:02:11.280><c> has</c><00:02:11.520><c> reached</c><00:02:11.920><c> zero.</c>

00:02:12.869 --> 00:02:12.879 align:start position:0%
if the counter value has reached zero.
 

00:02:12.879 --> 00:02:15.110 align:start position:0%
if the counter value has reached zero.
If<00:02:13.040><c> it</c><00:02:13.280><c> has,</c><00:02:13.840><c> it</c><00:02:14.000><c> will</c><00:02:14.160><c> call</c><00:02:14.480><c> free</c><00:02:14.720><c> on</c><00:02:14.959><c> the</c>

00:02:15.110 --> 00:02:15.120 align:start position:0%
If it has, it will call free on the
 

00:02:15.120 --> 00:02:16.869 align:start position:0%
If it has, it will call free on the
object.<00:02:15.760><c> Now</c><00:02:16.080><c> the</c><00:02:16.239><c> programmer</c><00:02:16.640><c> doesn't</c>

00:02:16.869 --> 00:02:16.879 align:start position:0%
object. Now the programmer doesn't
 

00:02:16.879 --> 00:02:18.390 align:start position:0%
object. Now the programmer doesn't
actually<00:02:17.120><c> have</c><00:02:17.280><c> to</c><00:02:17.440><c> worry</c><00:02:17.680><c> about</c><00:02:17.920><c> freeing</c><00:02:18.239><c> the</c>

00:02:18.390 --> 00:02:18.400 align:start position:0%
actually have to worry about freeing the
 

00:02:18.400 --> 00:02:20.390 align:start position:0%
actually have to worry about freeing the
objects<00:02:18.720><c> themselves.</c><00:02:19.760><c> As</c><00:02:19.920><c> long</c><00:02:20.080><c> as</c><00:02:20.160><c> they</c>

00:02:20.390 --> 00:02:20.400 align:start position:0%
objects themselves. As long as they
 

00:02:20.400 --> 00:02:22.229 align:start position:0%
objects themselves. As long as they
follow<00:02:20.640><c> the</c><00:02:20.800><c> pattern</c><00:02:21.120><c> of</c><00:02:21.360><c> taking</c><00:02:21.680><c> a</c><00:02:21.840><c> reference</c>

00:02:22.229 --> 00:02:22.239 align:start position:0%
follow the pattern of taking a reference
 

00:02:22.239 --> 00:02:23.750 align:start position:0%
follow the pattern of taking a reference
and<00:02:22.480><c> dropping</c><00:02:22.800><c> a</c><00:02:22.959><c> reference</c><00:02:23.280><c> when</c><00:02:23.520><c> they're</c>

00:02:23.750 --> 00:02:23.760 align:start position:0%
and dropping a reference when they're
 

00:02:23.760 --> 00:02:25.510 align:start position:0%
and dropping a reference when they're
finished,<00:02:24.560><c> everything</c><00:02:24.879><c> else</c><00:02:25.120><c> should</c><00:02:25.360><c> work</c>

00:02:25.510 --> 00:02:25.520 align:start position:0%
finished, everything else should work
 

00:02:25.520 --> 00:02:27.030 align:start position:0%
finished, everything else should work
out.<00:02:25.760><c> And</c><00:02:25.920><c> objects</c><00:02:26.319><c> that</c><00:02:26.480><c> are</c><00:02:26.640><c> no</c><00:02:26.800><c> longer</c>

00:02:27.030 --> 00:02:27.040 align:start position:0%
out. And objects that are no longer
 

00:02:27.040 --> 00:02:28.869 align:start position:0%
out. And objects that are no longer
being<00:02:27.280><c> referenced</c><00:02:27.760><c> by</c><00:02:28.000><c> anything</c><00:02:28.640><c> will</c>

00:02:28.869 --> 00:02:28.879 align:start position:0%
being referenced by anything will
 

00:02:28.879 --> 00:02:30.309 align:start position:0%
being referenced by anything will
naturally<00:02:29.360><c> be</c><00:02:29.520><c> freed</c><00:02:29.840><c> back</c><00:02:30.000><c> to</c><00:02:30.160><c> the</c>

00:02:30.309 --> 00:02:30.319 align:start position:0%
naturally be freed back to the
 

00:02:30.319 --> 00:02:32.470 align:start position:0%
naturally be freed back to the
allocator.<00:02:31.120><c> In</c><00:02:31.280><c> the</c><00:02:31.440><c> iOS</c><00:02:31.840><c> and</c><00:02:32.000><c> Mac</c><00:02:32.239><c> OS</c>

00:02:32.470 --> 00:02:32.480 align:start position:0%
allocator. In the iOS and Mac OS
 

00:02:32.480 --> 00:02:34.390 align:start position:0%
allocator. In the iOS and Mac OS
kernels,<00:02:33.120><c> reference</c><00:02:33.519><c> counting</c><00:02:33.920><c> is</c><00:02:34.080><c> of</c><00:02:34.239><c> course</c>

00:02:34.390 --> 00:02:34.400 align:start position:0%
kernels, reference counting is of course
 

00:02:34.400 --> 00:02:36.229 align:start position:0%
kernels, reference counting is of course
used<00:02:34.720><c> across</c><00:02:35.040><c> many</c><00:02:35.360><c> subsystems</c><00:02:35.920><c> to</c><00:02:36.080><c> keep</c>

00:02:36.229 --> 00:02:36.239 align:start position:0%
used across many subsystems to keep
 

00:02:36.239 --> 00:02:38.070 align:start position:0%
used across many subsystems to keep
track<00:02:36.480><c> of</c><00:02:36.800><c> allocations</c><00:02:37.360><c> in</c><00:02:37.519><c> the</c><00:02:37.680><c> way</c><00:02:37.760><c> that</c><00:02:37.920><c> we</c>

00:02:38.070 --> 00:02:38.080 align:start position:0%
track of allocations in the way that we
 

00:02:38.080 --> 00:02:39.830 align:start position:0%
track of allocations in the way that we
just<00:02:38.239><c> discussed.</c><00:02:38.879><c> Specifically,</c><00:02:39.440><c> let's</c><00:02:39.680><c> look</c>

00:02:39.830 --> 00:02:39.840 align:start position:0%
just discussed. Specifically, let's look
 

00:02:39.840 --> 00:02:41.430 align:start position:0%
just discussed. Specifically, let's look
at<00:02:40.000><c> the</c><00:02:40.239><c> interprocess</c><00:02:40.879><c> communication</c>

00:02:41.430 --> 00:02:41.440 align:start position:0%
at the interprocess communication
 

00:02:41.440 --> 00:02:44.229 align:start position:0%
at the interprocess communication
subsystem.<00:02:42.319><c> IPC</c><00:02:42.879><c> in</c><00:02:43.120><c> Apple's</c><00:02:43.440><c> codebase</c><00:02:44.000><c> is</c>

00:02:44.229 --> 00:02:44.239 align:start position:0%
subsystem. IPC in Apple's codebase is
 

00:02:44.239 --> 00:02:46.390 align:start position:0%
subsystem. IPC in Apple's codebase is
built<00:02:44.480><c> around</c><00:02:44.720><c> the</c><00:02:44.959><c> concept</c><00:02:45.280><c> of</c><00:02:45.599><c> mock</c><00:02:45.920><c> ports.</c>

00:02:46.390 --> 00:02:46.400 align:start position:0%
built around the concept of mock ports.
 

00:02:46.400 --> 00:02:48.550 align:start position:0%
built around the concept of mock ports.
Mockports<00:02:47.120><c> are</c><00:02:47.360><c> communication</c><00:02:47.920><c> endpoints</c>

00:02:48.550 --> 00:02:48.560 align:start position:0%
Mockports are communication endpoints
 

00:02:48.560 --> 00:02:50.390 align:start position:0%
Mockports are communication endpoints
managed<00:02:48.879><c> by</c><00:02:49.040><c> the</c><00:02:49.200><c> kernel</c><00:02:49.760><c> that</c><00:02:50.080><c> allow</c>

00:02:50.390 --> 00:02:50.400 align:start position:0%
managed by the kernel that allow
 

00:02:50.400 --> 00:02:52.070 align:start position:0%
managed by the kernel that allow
processes<00:02:50.879><c> to</c><00:02:51.120><c> send</c><00:02:51.440><c> messages</c><00:02:51.760><c> to</c><00:02:51.920><c> one</c>

00:02:52.070 --> 00:02:52.080 align:start position:0%
processes to send messages to one
 

00:02:52.080 --> 00:02:53.990 align:start position:0%
processes to send messages to one
another<00:02:52.560><c> or</c><00:02:52.879><c> communicate</c><00:02:53.360><c> with</c><00:02:53.599><c> kernel</c>

00:02:53.990 --> 00:02:54.000 align:start position:0%
another or communicate with kernel
 

00:02:54.000 --> 00:02:55.830 align:start position:0%
another or communicate with kernel
drivers.<00:02:54.720><c> They're</c><00:02:54.959><c> conceptually</c><00:02:55.599><c> quite</c>

00:02:55.830 --> 00:02:55.840 align:start position:0%
drivers. They're conceptually quite
 

00:02:55.840 --> 00:02:57.830 align:start position:0%
drivers. They're conceptually quite
similar<00:02:56.160><c> to</c><00:02:56.400><c> file</c><00:02:56.720><c> descriptors.</c><00:02:57.519><c> You</c><00:02:57.680><c> can</c>

00:02:57.830 --> 00:02:57.840 align:start position:0%
similar to file descriptors. You can
 

00:02:57.840 --> 00:02:59.509 align:start position:0%
similar to file descriptors. You can
create<00:02:57.920><c> a</c><00:02:58.080><c> muckport</c><00:02:58.560><c> in</c><00:02:58.640><c> userland</c><00:02:59.200><c> through</c><00:02:59.360><c> a</c>

00:02:59.509 --> 00:02:59.519 align:start position:0%
create a muckport in userland through a
 

00:02:59.519 --> 00:03:02.229 align:start position:0%
create a muckport in userland through a
mock<00:02:59.840><c> sysl</c><00:03:00.319><c> like</c><00:03:00.640><c> mukport</c><00:03:01.200><c> allocate</c><00:03:02.080><c> and</c>

00:03:02.229 --> 00:03:02.239 align:start position:0%
mock sysl like mukport allocate and
 

00:03:02.239 --> 00:03:04.470 align:start position:0%
mock sysl like mukport allocate and
you'll<00:03:02.480><c> be</c><00:03:02.720><c> returned</c><00:03:03.120><c> a</c><00:03:03.440><c> 32-bit</c><00:03:04.080><c> integer</c>

00:03:04.470 --> 00:03:04.480 align:start position:0%
you'll be returned a 32-bit integer
 

00:03:04.480 --> 00:03:06.790 align:start position:0%
you'll be returned a 32-bit integer
value.<00:03:05.120><c> The</c><00:03:05.280><c> raw</c><00:03:05.599><c> value</c><00:03:05.920><c> itself</c><00:03:06.400><c> would</c><00:03:06.640><c> be</c>

00:03:06.790 --> 00:03:06.800 align:start position:0%
value. The raw value itself would be
 

00:03:06.800 --> 00:03:08.790 align:start position:0%
value. The raw value itself would be
meaningless<00:03:07.280><c> on</c><00:03:07.519><c> its</c><00:03:07.760><c> own,</c><00:03:08.319><c> but</c><00:03:08.560><c> when</c>

00:03:08.790 --> 00:03:08.800 align:start position:0%
meaningless on its own, but when
 

00:03:08.800 --> 00:03:11.270 align:start position:0%
meaningless on its own, but when
interpreted<00:03:09.360><c> by</c><00:03:09.519><c> the</c><00:03:09.760><c> kernel,</c><00:03:10.400><c> it</c><00:03:10.640><c> is</c><00:03:10.800><c> used</c><00:03:11.040><c> as</c>

00:03:11.270 --> 00:03:11.280 align:start position:0%
interpreted by the kernel, it is used as
 

00:03:11.280 --> 00:03:13.990 align:start position:0%
interpreted by the kernel, it is used as
an<00:03:11.519><c> index</c><00:03:11.920><c> into</c><00:03:12.239><c> a</c><00:03:12.480><c> table</c><00:03:12.800><c> of</c><00:03:13.120><c> IPC</c><00:03:13.680><c> port</c>

00:03:13.990 --> 00:03:14.000 align:start position:0%
an index into a table of IPC port
 

00:03:14.000 --> 00:03:15.910 align:start position:0%
an index into a table of IPC port
structures<00:03:14.800><c> owned</c><00:03:15.200><c> by</c><00:03:15.360><c> your</c><00:03:15.599><c> current</c>

00:03:15.910 --> 00:03:15.920 align:start position:0%
structures owned by your current
 

00:03:15.920 --> 00:03:18.390 align:start position:0%
structures owned by your current
process.<00:03:16.800><c> So</c><00:03:16.959><c> when</c><00:03:17.280><c> sending</c><00:03:17.599><c> a</c><00:03:17.760><c> MUK</c><00:03:18.080><c> message</c>

00:03:18.390 --> 00:03:18.400 align:start position:0%
process. So when sending a MUK message
 

00:03:18.400 --> 00:03:20.710 align:start position:0%
process. So when sending a MUK message
to<00:03:18.640><c> a</c><00:03:18.800><c> MUK</c><00:03:19.040><c> port,</c><00:03:19.360><c> for</c><00:03:19.440><c> example,</c><00:03:20.159><c> the</c><00:03:20.400><c> kernel</c>

00:03:20.710 --> 00:03:20.720 align:start position:0%
to a MUK port, for example, the kernel
 

00:03:20.720 --> 00:03:22.869 align:start position:0%
to a MUK port, for example, the kernel
will<00:03:20.959><c> take</c><00:03:21.120><c> the</c><00:03:21.280><c> provided</c><00:03:21.760><c> 32-bit</c><00:03:22.400><c> index</c><00:03:22.720><c> from</c>

00:03:22.869 --> 00:03:22.879 align:start position:0%
will take the provided 32-bit index from
 

00:03:22.879 --> 00:03:24.869 align:start position:0%
will take the provided 32-bit index from
user<00:03:23.200><c> space</c><00:03:23.599><c> and</c><00:03:23.840><c> use</c><00:03:24.080><c> it</c><00:03:24.239><c> to</c><00:03:24.319><c> look</c><00:03:24.560><c> up</c><00:03:24.720><c> the</c>

00:03:24.869 --> 00:03:24.879 align:start position:0%
user space and use it to look up the
 

00:03:24.879 --> 00:03:27.509 align:start position:0%
user space and use it to look up the
associated<00:03:25.440><c> IPC</c><00:03:25.920><c> port</c><00:03:26.159><c> object</c><00:03:26.879><c> in</c><00:03:27.040><c> the</c><00:03:27.200><c> kernel</c>

00:03:27.509 --> 00:03:27.519 align:start position:0%
associated IPC port object in the kernel
 

00:03:27.519 --> 00:03:29.430 align:start position:0%
associated IPC port object in the kernel
space<00:03:27.760><c> to</c><00:03:27.920><c> then</c><00:03:28.080><c> perform</c><00:03:28.400><c> the</c><00:03:28.640><c> actual</c><00:03:28.959><c> sending</c>

00:03:29.430 --> 00:03:29.440 align:start position:0%
space to then perform the actual sending
 

00:03:29.440 --> 00:03:32.229 align:start position:0%
space to then perform the actual sending
logic<00:03:29.760><c> on</c><00:03:30.080><c> that</c><00:03:30.239><c> object.</c><00:03:31.440><c> The</c><00:03:31.599><c> colonel's</c><00:03:32.080><c> own</c>

00:03:32.229 --> 00:03:32.239 align:start position:0%
logic on that object. The colonel's own
 

00:03:32.239 --> 00:03:34.309 align:start position:0%
logic on that object. The colonel's own
representation<00:03:32.799><c> of</c><00:03:32.959><c> a</c><00:03:33.120><c> mockport</c><00:03:33.680><c> is</c><00:03:33.840><c> a</c><00:03:34.080><c> large</c>

00:03:34.309 --> 00:03:34.319 align:start position:0%
representation of a mockport is a large
 

00:03:34.319 --> 00:03:36.070 align:start position:0%
representation of a mockport is a large
structure<00:03:34.879><c> with</c><00:03:35.120><c> a</c><00:03:35.360><c> number</c><00:03:35.519><c> of</c><00:03:35.680><c> important</c>

00:03:36.070 --> 00:03:36.080 align:start position:0%
structure with a number of important
 

00:03:36.080 --> 00:03:38.149 align:start position:0%
structure with a number of important
fields.<00:03:36.799><c> And</c><00:03:37.040><c> one</c><00:03:37.200><c> of</c><00:03:37.280><c> the</c><00:03:37.440><c> first</c><00:03:37.599><c> fields</c><00:03:37.920><c> we</c>

00:03:38.149 --> 00:03:38.159 align:start position:0%
fields. And one of the first fields we
 

00:03:38.159 --> 00:03:40.309 align:start position:0%
fields. And one of the first fields we
see<00:03:38.319><c> here</c><00:03:38.640><c> is</c><00:03:38.879><c> a</c><00:03:39.120><c> reference</c><00:03:39.440><c> count</c><00:03:39.760><c> variable</c>

00:03:40.309 --> 00:03:40.319 align:start position:0%
see here is a reference count variable
 

00:03:40.319 --> 00:03:42.949 align:start position:0%
see here is a reference count variable
named<00:03:40.799><c> IO</c><00:03:41.280><c> references.</c><00:03:42.319><c> This</c><00:03:42.480><c> is</c><00:03:42.560><c> used</c><00:03:42.799><c> to</c>

00:03:42.949 --> 00:03:42.959 align:start position:0%
named IO references. This is used to
 

00:03:42.959 --> 00:03:44.789 align:start position:0%
named IO references. This is used to
keep<00:03:43.200><c> track</c><00:03:43.440><c> of</c><00:03:43.680><c> parts</c><00:03:43.920><c> of</c><00:03:44.080><c> the</c><00:03:44.239><c> code</c><00:03:44.400><c> that</c><00:03:44.640><c> are</c>

00:03:44.789 --> 00:03:44.799 align:start position:0%
keep track of parts of the code that are
 

00:03:44.799 --> 00:03:47.030 align:start position:0%
keep track of parts of the code that are
currently<00:03:45.120><c> using</c><00:03:45.440><c> this</c><00:03:45.680><c> mukport</c><00:03:46.480><c> by</c><00:03:46.720><c> making</c>

00:03:47.030 --> 00:03:47.040 align:start position:0%
currently using this mukport by making
 

00:03:47.040 --> 00:03:48.710 align:start position:0%
currently using this mukport by making
use<00:03:47.200><c> of</c><00:03:47.360><c> the</c><00:03:47.599><c> reference</c><00:03:48.000><c> counting</c><00:03:48.319><c> mechanism</c>

00:03:48.710 --> 00:03:48.720 align:start position:0%
use of the reference counting mechanism
 

00:03:48.720 --> 00:03:50.710 align:start position:0%
use of the reference counting mechanism
that<00:03:48.959><c> we</c><00:03:49.120><c> discussed.</c><00:03:49.920><c> So</c><00:03:50.080><c> when</c><00:03:50.239><c> a</c><00:03:50.400><c> process</c>

00:03:50.710 --> 00:03:50.720 align:start position:0%
that we discussed. So when a process
 

00:03:50.720 --> 00:03:52.710 align:start position:0%
that we discussed. So when a process
first<00:03:50.959><c> creates</c><00:03:51.200><c> a</c><00:03:51.360><c> mukport,</c><00:03:52.080><c> that</c><00:03:52.319><c> port's</c>

00:03:52.710 --> 00:03:52.720 align:start position:0%
first creates a mukport, that port's
 

00:03:52.720 --> 00:03:55.030 align:start position:0%
first creates a mukport, that port's
reference<00:03:53.040><c> count</c><00:03:53.360><c> is</c><00:03:53.599><c> set</c><00:03:53.760><c> to</c><00:03:53.920><c> one.</c><00:03:54.400><c> Any</c><00:03:54.799><c> other</c>

00:03:55.030 --> 00:03:55.040 align:start position:0%
reference count is set to one. Any other
 

00:03:55.040 --> 00:03:56.710 align:start position:0%
reference count is set to one. Any other
subsequent<00:03:55.440><c> action</c><00:03:55.840><c> that</c><00:03:56.080><c> involves</c><00:03:56.480><c> the</c>

00:03:56.710 --> 00:03:56.720 align:start position:0%
subsequent action that involves the
 

00:03:56.720 --> 00:03:58.949 align:start position:0%
subsequent action that involves the
usage<00:03:57.120><c> of</c><00:03:57.360><c> this</c><00:03:57.599><c> port</c><00:03:58.080><c> will</c><00:03:58.319><c> then</c><00:03:58.480><c> in</c><00:03:58.720><c> turn</c>

00:03:58.949 --> 00:03:58.959 align:start position:0%
usage of this port will then in turn
 

00:03:58.959 --> 00:04:01.030 align:start position:0%
usage of this port will then in turn
also<00:03:59.360><c> increment</c><00:03:59.840><c> that</c><00:04:00.080><c> reference</c><00:04:00.400><c> counter.</c>

00:04:01.030 --> 00:04:01.040 align:start position:0%
also increment that reference counter.
 

00:04:01.040 --> 00:04:02.710 align:start position:0%
also increment that reference counter.
For<00:04:01.200><c> example,</c><00:04:01.599><c> sending</c><00:04:01.920><c> that</c><00:04:02.080><c> port</c><00:04:02.319><c> in</c><00:04:02.560><c> a</c>

00:04:02.710 --> 00:04:02.720 align:start position:0%
For example, sending that port in a
 

00:04:02.720 --> 00:04:04.869 align:start position:0%
For example, sending that port in a
message<00:04:03.120><c> to</c><00:04:03.360><c> another</c><00:04:03.680><c> port</c><00:04:03.920><c> will</c><00:04:04.159><c> temporarily</c>

00:04:04.869 --> 00:04:04.879 align:start position:0%
message to another port will temporarily
 

00:04:04.879 --> 00:04:06.550 align:start position:0%
message to another port will temporarily
increase<00:04:05.120><c> the</c><00:04:05.280><c> reference</c><00:04:05.680><c> count</c><00:04:06.000><c> of</c><00:04:06.159><c> the</c><00:04:06.319><c> port</c>

00:04:06.550 --> 00:04:06.560 align:start position:0%
increase the reference count of the port
 

00:04:06.560 --> 00:04:08.949 align:start position:0%
increase the reference count of the port
while<00:04:06.799><c> it's</c><00:04:06.959><c> in</c><00:04:07.120><c> transit.</c><00:04:08.159><c> Once</c><00:04:08.400><c> that</c><00:04:08.640><c> task</c>

00:04:08.949 --> 00:04:08.959 align:start position:0%
while it's in transit. Once that task
 

00:04:08.959 --> 00:04:10.550 align:start position:0%
while it's in transit. Once that task
has<00:04:09.120><c> finished</c><00:04:09.439><c> using</c><00:04:09.680><c> the</c><00:04:09.840><c> port</c><00:04:10.080><c> and</c><00:04:10.239><c> calls</c>

00:04:10.550 --> 00:04:10.560 align:start position:0%
has finished using the port and calls
 

00:04:10.560 --> 00:04:12.949 align:start position:0%
has finished using the port and calls
mukport<00:04:11.120><c> deallocate</c><00:04:11.840><c> to</c><00:04:12.080><c> get</c><00:04:12.239><c> rid</c><00:04:12.400><c> of</c><00:04:12.480><c> it,</c>

00:04:12.949 --> 00:04:12.959 align:start position:0%
mukport deallocate to get rid of it,
 

00:04:12.959 --> 00:04:14.710 align:start position:0%
mukport deallocate to get rid of it,
that<00:04:13.200><c> reference</c><00:04:13.519><c> count</c><00:04:13.760><c> drops</c><00:04:14.000><c> to</c><00:04:14.159><c> zero</c><00:04:14.480><c> and</c>

00:04:14.710 --> 00:04:14.720 align:start position:0%
that reference count drops to zero and
 

00:04:14.720 --> 00:04:16.949 align:start position:0%
that reference count drops to zero and
the<00:04:14.879><c> kernel</c><00:04:15.280><c> will</c><00:04:15.439><c> free</c><00:04:15.680><c> the</c><00:04:15.920><c> underlying</c><00:04:16.400><c> IPC</c>

00:04:16.949 --> 00:04:16.959 align:start position:0%
the kernel will free the underlying IPC
 

00:04:16.959 --> 00:04:18.949 align:start position:0%
the kernel will free the underlying IPC
port<00:04:17.199><c> object.</c><00:04:18.000><c> So</c><00:04:18.160><c> with</c><00:04:18.400><c> that</c><00:04:18.560><c> background</c>

00:04:18.949 --> 00:04:18.959 align:start position:0%
port object. So with that background
 

00:04:18.959 --> 00:04:20.710 align:start position:0%
port object. So with that background
knowledge<00:04:19.280><c> out</c><00:04:19.440><c> of</c><00:04:19.519><c> the</c><00:04:19.680><c> way,</c><00:04:20.239><c> let's</c><00:04:20.479><c> now</c>

00:04:20.710 --> 00:04:20.720 align:start position:0%
knowledge out of the way, let's now
 

00:04:20.720 --> 00:04:22.710 align:start position:0%
knowledge out of the way, let's now
introduce<00:04:21.040><c> a</c><00:04:21.359><c> very</c><00:04:21.600><c> interesting</c><00:04:22.000><c> bug</c><00:04:22.240><c> from</c>

00:04:22.710 --> 00:04:22.720 align:start position:0%
introduce a very interesting bug from
 

00:04:22.720 --> 00:04:27.670 align:start position:0%
introduce a very interesting bug from
2017<00:04:23.840><c> assigned</c><00:04:24.479><c> CVE</c><00:04:25.120><c> 201713861.</c>

00:04:27.670 --> 00:04:27.680 align:start position:0%
2017 assigned CVE 201713861.
 

00:04:27.680 --> 00:04:29.749 align:start position:0%
2017 assigned CVE 201713861.
This<00:04:27.840><c> is</c><00:04:27.919><c> a</c><00:04:28.080><c> bug</c><00:04:28.320><c> in</c><00:04:28.479><c> the</c><00:04:28.639><c> ref</c><00:04:28.960><c> counting</c><00:04:29.280><c> logic</c>

00:04:29.749 --> 00:04:29.759 align:start position:0%
This is a bug in the ref counting logic
 

00:04:29.759 --> 00:04:31.909 align:start position:0%
This is a bug in the ref counting logic
specifically<00:04:30.240><c> affecting</c><00:04:30.720><c> muck</c><00:04:31.040><c> ports</c><00:04:31.600><c> and</c><00:04:31.759><c> it</c>

00:04:31.909 --> 00:04:31.919 align:start position:0%
specifically affecting muck ports and it
 

00:04:31.919 --> 00:04:33.430 align:start position:0%
specifically affecting muck ports and it
was<00:04:32.080><c> actually</c><00:04:32.320><c> found</c><00:04:32.479><c> to</c><00:04:32.639><c> be</c><00:04:32.800><c> exploited</c><00:04:33.280><c> in</c>

00:04:33.430 --> 00:04:33.440 align:start position:0%
was actually found to be exploited in
 

00:04:33.440 --> 00:04:35.270 align:start position:0%
was actually found to be exploited in
the<00:04:33.600><c> wild</c><00:04:33.840><c> to</c><00:04:34.080><c> achieve</c><00:04:34.400><c> full</c><00:04:34.639><c> kernel</c><00:04:35.040><c> code</c>

00:04:35.270 --> 00:04:35.280 align:start position:0%
the wild to achieve full kernel code
 

00:04:35.280 --> 00:04:37.830 align:start position:0%
the wild to achieve full kernel code
execution<00:04:35.759><c> on</c><00:04:36.080><c> iOS</c><00:04:36.560><c> 11</c><00:04:36.880><c> devices.</c><00:04:37.440><c> The</c><00:04:37.600><c> bug</c>

00:04:37.830 --> 00:04:37.840 align:start position:0%
execution on iOS 11 devices. The bug
 

00:04:37.840 --> 00:04:39.909 align:start position:0%
execution on iOS 11 devices. The bug
itself<00:04:38.160><c> is</c><00:04:38.320><c> in</c><00:04:38.560><c> the</c><00:04:38.720><c> function</c><00:04:39.120><c> IO</c><00:04:39.520><c> surface</c>

00:04:39.909 --> 00:04:39.919 align:start position:0%
itself is in the function IO surface
 

00:04:39.919 --> 00:04:42.870 align:start position:0%
itself is in the function IO surface
root<00:04:40.240><c> user</c><00:04:40.639><c> client</c><00:04:41.280><c> set</c><00:04:41.600><c> surface</c><00:04:42.080><c> notify.</c>

00:04:42.870 --> 00:04:42.880 align:start position:0%
root user client set surface notify.
 

00:04:42.880 --> 00:04:44.629 align:start position:0%
root user client set surface notify.
This<00:04:43.120><c> function</c><00:04:43.360><c> is</c><00:04:43.520><c> used</c><00:04:43.680><c> to</c><00:04:43.919><c> register</c><00:04:44.320><c> a</c>

00:04:44.629 --> 00:04:44.639 align:start position:0%
This function is used to register a
 

00:04:44.639 --> 00:04:47.030 align:start position:0%
This function is used to register a
mukport<00:04:45.199><c> onto</c><00:04:45.600><c> some</c><00:04:45.919><c> IO</c><00:04:46.320><c> surface</c><00:04:46.639><c> kernel</c>

00:04:47.030 --> 00:04:47.040 align:start position:0%
mukport onto some IO surface kernel
 

00:04:47.040 --> 00:04:48.790 align:start position:0%
mukport onto some IO surface kernel
object<00:04:47.600><c> and</c><00:04:47.759><c> it's</c><00:04:47.919><c> reachable</c><00:04:48.320><c> from</c><00:04:48.560><c> most</c>

00:04:48.790 --> 00:04:48.800 align:start position:0%
object and it's reachable from most
 

00:04:48.800 --> 00:04:51.110 align:start position:0%
object and it's reachable from most
sandbox<00:04:49.280><c> profiles.</c><00:04:50.000><c> Legitimate</c><00:04:50.560><c> usage</c><00:04:50.960><c> of</c>

00:04:51.110 --> 00:04:51.120 align:start position:0%
sandbox profiles. Legitimate usage of
 

00:04:51.120 --> 00:04:52.469 align:start position:0%
sandbox profiles. Legitimate usage of
this<00:04:51.360><c> function</c><00:04:51.680><c> would</c><00:04:52.080><c> increase</c><00:04:52.320><c> the</c>

00:04:52.469 --> 00:04:52.479 align:start position:0%
this function would increase the
 

00:04:52.479 --> 00:04:54.469 align:start position:0%
this function would increase the
reference<00:04:52.880><c> count</c><00:04:53.120><c> of</c><00:04:53.360><c> a</c><00:04:53.520><c> supplied</c><00:04:53.919><c> mukport.</c>

00:04:54.469 --> 00:04:54.479 align:start position:0%
reference count of a supplied mukport.
 

00:04:54.479 --> 00:04:56.070 align:start position:0%
reference count of a supplied mukport.
However,<00:04:54.720><c> the</c><00:04:54.880><c> vulnerability</c><00:04:55.440><c> here</c><00:04:55.680><c> is</c><00:04:55.919><c> that</c>

00:04:56.070 --> 00:04:56.080 align:start position:0%
However, the vulnerability here is that
 

00:04:56.080 --> 00:04:58.070 align:start position:0%
However, the vulnerability here is that
there<00:04:56.240><c> was</c><00:04:56.320><c> an</c><00:04:56.479><c> incorrect</c><00:04:56.960><c> handling</c><00:04:57.520><c> of</c><00:04:57.840><c> error</c>

00:04:58.070 --> 00:04:58.080 align:start position:0%
there was an incorrect handling of error
 

00:04:58.080 --> 00:05:00.390 align:start position:0%
there was an incorrect handling of error
cases<00:04:58.400><c> within</c><00:04:58.720><c> this</c><00:04:58.960><c> function</c><00:04:59.759><c> as</c><00:05:00.000><c> described</c>

00:05:00.390 --> 00:05:00.400 align:start position:0%
cases within this function as described
 

00:05:00.400 --> 00:05:02.550 align:start position:0%
cases within this function as described
by<00:05:00.560><c> the</c><00:05:00.800><c> project</c><00:05:01.120><c> zero</c><00:05:01.440><c> explanation.</c><00:05:02.240><c> In</c><00:05:02.400><c> the</c>

00:05:02.550 --> 00:05:02.560 align:start position:0%
by the project zero explanation. In the
 

00:05:02.560 --> 00:05:04.230 align:start position:0%
by the project zero explanation. In the
case<00:05:02.639><c> of</c><00:05:02.800><c> an</c><00:05:03.040><c> error</c><00:05:03.280><c> while</c><00:05:03.520><c> executing</c><00:05:04.000><c> this</c>

00:05:04.230 --> 00:05:04.240 align:start position:0%
case of an error while executing this
 

00:05:04.240 --> 00:05:05.909 align:start position:0%
case of an error while executing this
function,<00:05:04.880><c> it</c><00:05:05.120><c> will</c><00:05:05.280><c> actually</c><00:05:05.520><c> drop</c><00:05:05.759><c> a</c>

00:05:05.909 --> 00:05:05.919 align:start position:0%
function, it will actually drop a
 

00:05:05.919 --> 00:05:07.830 align:start position:0%
function, it will actually drop a
reference<00:05:06.240><c> count</c><00:05:06.400><c> on</c><00:05:06.560><c> the</c><00:05:06.639><c> mukport.</c><00:05:07.360><c> However,</c>

00:05:07.830 --> 00:05:07.840 align:start position:0%
reference count on the mukport. However,
 

00:05:07.840 --> 00:05:10.469 align:start position:0%
reference count on the mukport. However,
under<00:05:08.320><c> proper</c><00:05:08.639><c> semantics,</c><00:05:09.360><c> the</c><00:05:09.520><c> kernel</c><00:05:10.000><c> code</c>

00:05:10.469 --> 00:05:10.479 align:start position:0%
under proper semantics, the kernel code
 

00:05:10.479 --> 00:05:12.710 align:start position:0%
under proper semantics, the kernel code
responsible<00:05:11.039><c> for</c><00:05:11.280><c> calling</c><00:05:11.680><c> this</c><00:05:11.840><c> method</c><00:05:12.479><c> is</c>

00:05:12.710 --> 00:05:12.720 align:start position:0%
responsible for calling this method is
 

00:05:12.720 --> 00:05:13.990 align:start position:0%
responsible for calling this method is
what<00:05:12.880><c> is</c><00:05:13.039><c> meant</c><00:05:13.199><c> to</c><00:05:13.280><c> be</c><00:05:13.360><c> in</c><00:05:13.520><c> charge</c><00:05:13.680><c> of</c><00:05:13.840><c> the</c>

00:05:13.990 --> 00:05:14.000 align:start position:0%
what is meant to be in charge of the
 

00:05:14.000 --> 00:05:16.070 align:start position:0%
what is meant to be in charge of the
reference<00:05:14.400><c> counting</c><00:05:14.960><c> and</c><00:05:15.280><c> not</c><00:05:15.440><c> this</c><00:05:15.680><c> function</c>

00:05:16.070 --> 00:05:16.080 align:start position:0%
reference counting and not this function
 

00:05:16.080 --> 00:05:18.150 align:start position:0%
reference counting and not this function
itself.<00:05:16.800><c> So</c><00:05:16.960><c> on</c><00:05:17.120><c> the</c><00:05:17.280><c> case</c><00:05:17.440><c> of</c><00:05:17.600><c> an</c><00:05:17.840><c> error</c><00:05:18.000><c> and</c>

00:05:18.150 --> 00:05:18.160 align:start position:0%
itself. So on the case of an error and
 

00:05:18.160 --> 00:05:20.390 align:start position:0%
itself. So on the case of an error and
an<00:05:18.320><c> early</c><00:05:18.560><c> return,</c><00:05:19.199><c> set</c><00:05:19.520><c> surface</c><00:05:19.919><c> notifier</c>

00:05:20.390 --> 00:05:20.400 align:start position:0%
an early return, set surface notifier
 

00:05:20.400 --> 00:05:22.310 align:start position:0%
an early return, set surface notifier
drops<00:05:20.639><c> a</c><00:05:20.880><c> reference</c><00:05:21.199><c> on</c><00:05:21.360><c> the</c><00:05:21.440><c> muckport</c>

00:05:22.310 --> 00:05:22.320 align:start position:0%
drops a reference on the muckport
 

00:05:22.320 --> 00:05:23.830 align:start position:0%
drops a reference on the muckport
thinking<00:05:22.639><c> it's</c><00:05:22.880><c> doing</c><00:05:23.039><c> the</c><00:05:23.280><c> responsible</c>

00:05:23.830 --> 00:05:23.840 align:start position:0%
thinking it's doing the responsible
 

00:05:23.840 --> 00:05:26.469 align:start position:0%
thinking it's doing the responsible
thing,<00:05:24.400><c> but</c><00:05:24.639><c> then</c><00:05:24.800><c> the</c><00:05:25.039><c> caller</c><00:05:25.680><c> also</c><00:05:26.080><c> drops</c><00:05:26.320><c> a</c>

00:05:26.469 --> 00:05:26.479 align:start position:0%
thing, but then the caller also drops a
 

00:05:26.479 --> 00:05:28.870 align:start position:0%
thing, but then the caller also drops a
reference.<00:05:27.199><c> So</c><00:05:27.280><c> it</c><00:05:27.520><c> plays</c><00:05:27.759><c> out</c><00:05:27.919><c> like</c><00:05:28.080><c> this.</c><00:05:28.639><c> A</c>

00:05:28.870 --> 00:05:28.880 align:start position:0%
reference. So it plays out like this. A
 

00:05:28.880 --> 00:05:31.189 align:start position:0%
reference. So it plays out like this. A
mukport<00:05:29.360><c> is</c><00:05:29.520><c> created</c><00:05:29.840><c> by</c><00:05:30.000><c> a</c><00:05:30.160><c> process</c><00:05:30.560><c> A</c><00:05:30.960><c> and</c>

00:05:31.189 --> 00:05:31.199 align:start position:0%
mukport is created by a process A and
 

00:05:31.199 --> 00:05:33.510 align:start position:0%
mukport is created by a process A and
its<00:05:31.360><c> ref</c><00:05:31.680><c> count</c><00:05:31.840><c> is</c><00:05:32.000><c> initially</c><00:05:32.400><c> set</c><00:05:32.639><c> to</c><00:05:32.960><c> one.</c>

00:05:33.510 --> 00:05:33.520 align:start position:0%
its ref count is initially set to one.
 

00:05:33.520 --> 00:05:35.830 align:start position:0%
its ref count is initially set to one.
Process<00:05:33.919><c> A</c><00:05:34.240><c> calls</c><00:05:34.639><c> set</c><00:05:34.960><c> surface</c><00:05:35.360><c> notifier</c>

00:05:35.830 --> 00:05:35.840 align:start position:0%
Process A calls set surface notifier
 

00:05:35.840 --> 00:05:37.909 align:start position:0%
Process A calls set surface notifier
legitimately<00:05:36.400><c> to</c><00:05:36.720><c> register</c><00:05:37.120><c> this</c><00:05:37.280><c> port</c><00:05:37.759><c> and</c>

00:05:37.909 --> 00:05:37.919 align:start position:0%
legitimately to register this port and
 

00:05:37.919 --> 00:05:40.230 align:start position:0%
legitimately to register this port and
the<00:05:38.080><c> ref</c><00:05:38.320><c> count</c><00:05:38.560><c> goes</c><00:05:38.800><c> up</c><00:05:38.880><c> to</c><00:05:39.039><c> two.</c><00:05:39.520><c> Process</c><00:05:39.919><c> A</c>

00:05:40.230 --> 00:05:40.240 align:start position:0%
the ref count goes up to two. Process A
 

00:05:40.240 --> 00:05:42.550 align:start position:0%
the ref count goes up to two. Process A
then<00:05:40.479><c> calls</c><00:05:40.800><c> set</c><00:05:41.120><c> surface</c><00:05:41.520><c> notifier</c><00:05:42.000><c> again,</c>

00:05:42.550 --> 00:05:42.560 align:start position:0%
then calls set surface notifier again,
 

00:05:42.560 --> 00:05:44.390 align:start position:0%
then calls set surface notifier again,
but<00:05:42.800><c> this</c><00:05:42.960><c> time</c><00:05:43.199><c> causes</c><00:05:43.600><c> an</c><00:05:43.840><c> error</c><00:05:44.000><c> flow</c><00:05:44.240><c> and</c>

00:05:44.390 --> 00:05:44.400 align:start position:0%
but this time causes an error flow and
 

00:05:44.400 --> 00:05:46.070 align:start position:0%
but this time causes an error flow and
an<00:05:44.560><c> early</c><00:05:44.880><c> return</c><00:05:45.199><c> by</c><00:05:45.440><c> trying</c><00:05:45.600><c> to</c><00:05:45.759><c> register</c>

00:05:46.070 --> 00:05:46.080 align:start position:0%
an early return by trying to register
 

00:05:46.080 --> 00:05:48.950 align:start position:0%
an early return by trying to register
the<00:05:46.320><c> same</c><00:05:46.479><c> port</c><00:05:46.800><c> twice.</c><00:05:47.840><c> Upon</c><00:05:48.240><c> entry</c><00:05:48.560><c> to</c><00:05:48.720><c> this</c>

00:05:48.950 --> 00:05:48.960 align:start position:0%
the same port twice. Upon entry to this
 

00:05:48.960 --> 00:05:50.870 align:start position:0%
the same port twice. Upon entry to this
function,<00:05:49.360><c> the</c><00:05:49.520><c> ref</c><00:05:49.840><c> count</c><00:05:50.080><c> goes</c><00:05:50.320><c> up</c><00:05:50.479><c> to</c><00:05:50.639><c> three</c>

00:05:50.870 --> 00:05:50.880 align:start position:0%
function, the ref count goes up to three
 

00:05:50.880 --> 00:05:52.870 align:start position:0%
function, the ref count goes up to three
temporarily.<00:05:51.680><c> And</c><00:05:51.840><c> in</c><00:05:52.000><c> the</c><00:05:52.240><c> error</c><00:05:52.400><c> flow</c><00:05:52.639><c> of</c>

00:05:52.870 --> 00:05:52.880 align:start position:0%
temporarily. And in the error flow of
 

00:05:52.880 --> 00:05:55.189 align:start position:0%
temporarily. And in the error flow of
set<00:05:53.120><c> surface</c><00:05:53.440><c> notify,</c><00:05:54.160><c> it</c><00:05:54.320><c> drops</c><00:05:54.560><c> a</c><00:05:54.800><c> reference</c>

00:05:55.189 --> 00:05:55.199 align:start position:0%
set surface notify, it drops a reference
 

00:05:55.199 --> 00:05:57.029 align:start position:0%
set surface notify, it drops a reference
back<00:05:55.520><c> down</c><00:05:55.680><c> to</c><00:05:55.919><c> two.</c><00:05:56.320><c> We</c><00:05:56.479><c> return</c><00:05:56.720><c> to</c><00:05:56.880><c> the</c>

00:05:57.029 --> 00:05:57.039 align:start position:0%
back down to two. We return to the
 

00:05:57.039 --> 00:05:59.029 align:start position:0%
back down to two. We return to the
caller<00:05:57.360><c> where</c><00:05:57.520><c> the</c><00:05:57.840><c> error</c><00:05:58.000><c> is</c><00:05:58.160><c> recognized</c><00:05:58.880><c> and</c>

00:05:59.029 --> 00:05:59.039 align:start position:0%
caller where the error is recognized and
 

00:05:59.039 --> 00:06:00.790 align:start position:0%
caller where the error is recognized and
the<00:05:59.199><c> ref</c><00:05:59.440><c> count</c><00:05:59.680><c> is</c><00:05:59.840><c> dropped</c><00:06:00.160><c> another</c><00:06:00.479><c> time</c>

00:06:00.790 --> 00:06:00.800 align:start position:0%
the ref count is dropped another time
 

00:06:00.800 --> 00:06:03.029 align:start position:0%
the ref count is dropped another time
down<00:06:00.960><c> to</c><00:06:01.199><c> one.</c><00:06:01.680><c> Now</c><00:06:01.919><c> the</c><00:06:02.160><c> actual</c><00:06:02.479><c> references</c>

00:06:03.029 --> 00:06:03.039 align:start position:0%
down to one. Now the actual references
 

00:06:03.039 --> 00:06:05.029 align:start position:0%
down to one. Now the actual references
of<00:06:03.280><c> two</c><00:06:03.600><c> is</c><00:06:03.759><c> out</c><00:06:04.000><c> of</c><00:06:04.160><c> sync</c><00:06:04.400><c> with</c><00:06:04.560><c> the</c><00:06:04.720><c> reference</c>

00:06:05.029 --> 00:06:05.039 align:start position:0%
of two is out of sync with the reference
 

00:06:05.039 --> 00:06:07.189 align:start position:0%
of two is out of sync with the reference
counter<00:06:05.360><c> value</c><00:06:05.680><c> of</c><00:06:05.840><c> one.</c><00:06:06.400><c> At</c><00:06:06.639><c> this</c><00:06:06.800><c> point</c><00:06:06.960><c> we</c>

00:06:07.189 --> 00:06:07.199 align:start position:0%
counter value of one. At this point we
 

00:06:07.199 --> 00:06:09.590 align:start position:0%
counter value of one. At this point we
can<00:06:07.360><c> call</c><00:06:07.759><c> remove</c><00:06:08.160><c> surface</c><00:06:08.560><c> notify</c><00:06:09.199><c> and</c><00:06:09.360><c> this</c>

00:06:09.590 --> 00:06:09.600 align:start position:0%
can call remove surface notify and this
 

00:06:09.600 --> 00:06:11.590 align:start position:0%
can call remove surface notify and this
will<00:06:09.759><c> drop</c><00:06:10.000><c> another</c><00:06:10.400><c> reference</c><00:06:10.800><c> legitimately</c>

00:06:11.590 --> 00:06:11.600 align:start position:0%
will drop another reference legitimately
 

00:06:11.600 --> 00:06:13.189 align:start position:0%
will drop another reference legitimately
because<00:06:11.840><c> it</c><00:06:12.000><c> is</c><00:06:12.160><c> telling</c><00:06:12.400><c> the</c><00:06:12.479><c> IO</c><00:06:12.880><c> surface</c>

00:06:13.189 --> 00:06:13.199 align:start position:0%
because it is telling the IO surface
 

00:06:13.199 --> 00:06:15.510 align:start position:0%
because it is telling the IO surface
object<00:06:13.600><c> to</c><00:06:13.919><c> remove</c><00:06:14.160><c> that</c><00:06:14.400><c> port.</c><00:06:15.039><c> And</c><00:06:15.199><c> now</c><00:06:15.360><c> the</c>

00:06:15.510 --> 00:06:15.520 align:start position:0%
object to remove that port. And now the
 

00:06:15.520 --> 00:06:17.029 align:start position:0%
object to remove that port. And now the
reference<00:06:15.919><c> counter</c><00:06:16.240><c> has</c><00:06:16.479><c> dropped</c><00:06:16.720><c> down</c><00:06:16.880><c> to</c>

00:06:17.029 --> 00:06:17.039 align:start position:0%
reference counter has dropped down to
 

00:06:17.039 --> 00:06:19.350 align:start position:0%
reference counter has dropped down to
zero<00:06:17.680><c> and</c><00:06:17.840><c> the</c><00:06:18.080><c> IO</c><00:06:18.479><c> release</c><00:06:18.720><c> function</c><00:06:19.039><c> in</c><00:06:19.199><c> the</c>

00:06:19.350 --> 00:06:19.360 align:start position:0%
zero and the IO release function in the
 

00:06:19.360 --> 00:06:21.510 align:start position:0%
zero and the IO release function in the
kernel<00:06:19.759><c> handling</c><00:06:20.160><c> that</c><00:06:20.400><c> drop</c><00:06:20.880><c> will</c><00:06:21.120><c> free</c><00:06:21.360><c> the</c>

00:06:21.510 --> 00:06:21.520 align:start position:0%
kernel handling that drop will free the
 

00:06:21.520 --> 00:06:23.670 align:start position:0%
kernel handling that drop will free the
IPC<00:06:22.000><c> port</c><00:06:22.240><c> structure.</c><00:06:22.960><c> But</c><00:06:23.120><c> of</c><00:06:23.280><c> course</c><00:06:23.440><c> we</c>

00:06:23.670 --> 00:06:23.680 align:start position:0%
IPC port structure. But of course we
 

00:06:23.680 --> 00:06:25.350 align:start position:0%
IPC port structure. But of course we
still<00:06:23.840><c> actually</c><00:06:24.080><c> have</c><00:06:24.319><c> one</c><00:06:24.639><c> real</c><00:06:24.880><c> reference</c>

00:06:25.350 --> 00:06:25.360 align:start position:0%
still actually have one real reference
 

00:06:25.360 --> 00:06:27.670 align:start position:0%
still actually have one real reference
to<00:06:25.600><c> this</c><00:06:25.840><c> freed</c><00:06:26.240><c> port.</c><00:06:26.639><c> The</c><00:06:26.800><c> IPC</c><00:06:27.280><c> port</c><00:06:27.520><c> is</c>

00:06:27.670 --> 00:06:27.680 align:start position:0%
to this freed port. The IPC port is
 

00:06:27.680 --> 00:06:30.070 align:start position:0%
to this freed port. The IPC port is
still<00:06:27.840><c> in</c><00:06:28.080><c> our</c><00:06:28.240><c> tasks</c><00:06:28.720><c> ITK</c><00:06:29.360><c> space</c><00:06:29.600><c> and</c><00:06:29.840><c> we</c><00:06:30.000><c> can</c>

00:06:30.070 --> 00:06:30.080 align:start position:0%
still in our tasks ITK space and we can
 

00:06:30.080 --> 00:06:31.510 align:start position:0%
still in our tasks ITK space and we can
still<00:06:30.240><c> make</c><00:06:30.400><c> use</c><00:06:30.560><c> of</c><00:06:30.720><c> it</c><00:06:30.880><c> just</c><00:06:31.039><c> as</c><00:06:31.199><c> we</c><00:06:31.360><c> would</c>

00:06:31.510 --> 00:06:31.520 align:start position:0%
still make use of it just as we would
 

00:06:31.520 --> 00:06:33.270 align:start position:0%
still make use of it just as we would
with<00:06:31.680><c> any</c><00:06:31.840><c> other</c><00:06:32.000><c> mock</c><00:06:32.319><c> port.</c><00:06:32.720><c> At</c><00:06:32.960><c> this</c><00:06:33.120><c> point,</c>

00:06:33.270 --> 00:06:33.280 align:start position:0%
with any other mock port. At this point,
 

00:06:33.280 --> 00:06:35.110 align:start position:0%
with any other mock port. At this point,
we've<00:06:33.520><c> achieved</c><00:06:33.840><c> a</c><00:06:34.080><c> nice</c><00:06:34.319><c> use</c><00:06:34.560><c> after</c><00:06:34.880><c> free</c>

00:06:35.110 --> 00:06:35.120 align:start position:0%
we've achieved a nice use after free
 

00:06:35.120 --> 00:06:37.029 align:start position:0%
we've achieved a nice use after free
condition<00:06:35.520><c> on</c><00:06:35.759><c> a</c><00:06:36.000><c> pretty</c><00:06:36.240><c> interesting</c><00:06:36.639><c> kernel</c>

00:06:37.029 --> 00:06:37.039 align:start position:0%
condition on a pretty interesting kernel
 

00:06:37.039 --> 00:06:38.710 align:start position:0%
condition on a pretty interesting kernel
object.<00:06:37.440><c> From</c><00:06:37.680><c> here,</c><00:06:37.919><c> an</c><00:06:38.160><c> attacker</c><00:06:38.479><c> would</c>

00:06:38.710 --> 00:06:38.720 align:start position:0%
object. From here, an attacker would
 

00:06:38.720 --> 00:06:40.469 align:start position:0%
object. From here, an attacker would
typically<00:06:39.039><c> want</c><00:06:39.280><c> to</c><00:06:39.440><c> reallocate</c><00:06:40.000><c> the</c><00:06:40.240><c> memory</c>

00:06:40.469 --> 00:06:40.479 align:start position:0%
typically want to reallocate the memory
 

00:06:40.479 --> 00:06:42.390 align:start position:0%
typically want to reallocate the memory
that<00:06:40.720><c> was</c><00:06:40.880><c> once</c><00:06:41.199><c> used</c><00:06:41.360><c> for</c><00:06:41.520><c> the</c><00:06:41.680><c> IPC</c><00:06:42.160><c> port</c>

00:06:42.390 --> 00:06:42.400 align:start position:0%
that was once used for the IPC port
 

00:06:42.400 --> 00:06:44.309 align:start position:0%
that was once used for the IPC port
object<00:06:42.880><c> with</c><00:06:43.120><c> something</c><00:06:43.440><c> new,</c><00:06:44.080><c> something</c>

00:06:44.309 --> 00:06:44.319 align:start position:0%
object with something new, something
 

00:06:44.319 --> 00:06:46.150 align:start position:0%
object with something new, something
that<00:06:44.560><c> they</c><00:06:44.720><c> can</c><00:06:44.880><c> leverage</c><00:06:45.360><c> to</c><00:06:45.600><c> elevate</c><00:06:46.000><c> their</c>

00:06:46.150 --> 00:06:46.160 align:start position:0%
that they can leverage to elevate their
 

00:06:46.160 --> 00:06:47.990 align:start position:0%
that they can leverage to elevate their
privileges<00:06:46.639><c> on</c><00:06:46.800><c> the</c><00:06:47.039><c> system.</c><00:06:47.520><c> Back</c><00:06:47.759><c> in</c><00:06:47.840><c> the</c>

00:06:47.990 --> 00:06:48.000 align:start position:0%
privileges on the system. Back in the
 

00:06:48.000 --> 00:06:50.309 align:start position:0%
privileges on the system. Back in the
days<00:06:48.160><c> of</c><00:06:48.560><c> 2017,</c><00:06:49.280><c> when</c><00:06:49.440><c> this</c><00:06:49.680><c> bug</c><00:06:49.919><c> was</c><00:06:50.080><c> actually</c>

00:06:50.309 --> 00:06:50.319 align:start position:0%
days of 2017, when this bug was actually
 

00:06:50.319 --> 00:06:52.230 align:start position:0%
days of 2017, when this bug was actually
exploited<00:06:50.720><c> in</c><00:06:50.960><c> the</c><00:06:51.039><c> wild,</c><00:06:51.520><c> iOS</c><00:06:51.919><c> heap</c>

00:06:52.230 --> 00:06:52.240 align:start position:0%
exploited in the wild, iOS heap
 

00:06:52.240 --> 00:06:53.990 align:start position:0%
exploited in the wild, iOS heap
manipulation<00:06:52.800><c> techniques</c><00:06:53.360><c> were</c><00:06:53.520><c> at</c><00:06:53.759><c> their</c>

00:06:53.990 --> 00:06:54.000 align:start position:0%
manipulation techniques were at their
 

00:06:54.000 --> 00:06:56.150 align:start position:0%
manipulation techniques were at their
peak.<00:06:54.720><c> It</c><00:06:54.960><c> was</c><00:06:55.039><c> pretty</c><00:06:55.280><c> trivial</c><00:06:55.600><c> to</c><00:06:55.840><c> have</c><00:06:55.919><c> that</c>

00:06:56.150 --> 00:06:56.160 align:start position:0%
peak. It was pretty trivial to have that
 

00:06:56.160 --> 00:06:57.990 align:start position:0%
peak. It was pretty trivial to have that
memory<00:06:56.560><c> reallocated</c><00:06:57.120><c> for</c><00:06:57.280><c> an</c><00:06:57.520><c> object</c><00:06:57.759><c> of</c>

00:06:57.990 --> 00:06:58.000 align:start position:0%
memory reallocated for an object of
 

00:06:58.000 --> 00:06:59.990 align:start position:0%
memory reallocated for an object of
choice<00:06:58.560><c> or</c><00:06:58.800><c> even</c><00:06:59.120><c> completely</c><00:06:59.599><c> controlled</c>

00:06:59.990 --> 00:07:00.000 align:start position:0%
choice or even completely controlled
 

00:07:00.000 --> 00:07:02.070 align:start position:0%
choice or even completely controlled
data.<00:07:00.639><c> For</c><00:07:00.800><c> a</c><00:07:00.960><c> port</c><00:07:01.199><c> use</c><00:07:01.360><c> after</c><00:07:01.680><c> free</c><00:07:01.919><c> like</c>

00:07:02.070 --> 00:07:02.080 align:start position:0%
data. For a port use after free like
 

00:07:02.080 --> 00:07:03.830 align:start position:0%
data. For a port use after free like
this<00:07:02.160><c> one,</c><00:07:02.400><c> a</c><00:07:02.639><c> typical</c><00:07:02.960><c> goal</c><00:07:03.120><c> for</c><00:07:03.280><c> an</c><00:07:03.440><c> attacker</c>

00:07:03.830 --> 00:07:03.840 align:start position:0%
this one, a typical goal for an attacker
 

00:07:03.840 --> 00:07:06.230 align:start position:0%
this one, a typical goal for an attacker
would<00:07:04.080><c> be</c><00:07:04.240><c> to</c><00:07:04.400><c> construct</c><00:07:04.880><c> a</c><00:07:05.199><c> fake</c><00:07:05.520><c> kernel</c><00:07:05.919><c> task</c>

00:07:06.230 --> 00:07:06.240 align:start position:0%
would be to construct a fake kernel task
 

00:07:06.240 --> 00:07:08.390 align:start position:0%
would be to construct a fake kernel task
port<00:07:06.639><c> in</c><00:07:06.880><c> place</c><00:07:07.039><c> of</c><00:07:07.199><c> the</c><00:07:07.360><c> old</c><00:07:07.520><c> port.</c><00:07:08.080><c> Task</c>

00:07:08.390 --> 00:07:08.400 align:start position:0%
port in place of the old port. Task
 

00:07:08.400 --> 00:07:10.230 align:start position:0%
port in place of the old port. Task
ports<00:07:08.800><c> are</c><00:07:08.960><c> basically</c><00:07:09.280><c> a</c><00:07:09.520><c> special</c><00:07:09.840><c> type</c><00:07:10.000><c> of</c>

00:07:10.230 --> 00:07:10.240 align:start position:0%
ports are basically a special type of
 

00:07:10.240 --> 00:07:12.390 align:start position:0%
ports are basically a special type of
mukport<00:07:11.039><c> which</c><00:07:11.280><c> are</c><00:07:11.440><c> used</c><00:07:11.680><c> to</c><00:07:11.840><c> control</c><00:07:12.160><c> an</c>

00:07:12.390 --> 00:07:12.400 align:start position:0%
mukport which are used to control an
 

00:07:12.400 --> 00:07:15.029 align:start position:0%
mukport which are used to control an
entire<00:07:12.800><c> task</c><00:07:13.120><c> or</c><00:07:13.440><c> process.</c><00:07:14.240><c> Given</c><00:07:14.560><c> a</c><00:07:14.720><c> valid</c>

00:07:15.029 --> 00:07:15.039 align:start position:0%
entire task or process. Given a valid
 

00:07:15.039 --> 00:07:16.870 align:start position:0%
entire task or process. Given a valid
task<00:07:15.280><c> port</c><00:07:15.520><c> for</c><00:07:15.759><c> a</c><00:07:15.919><c> process,</c><00:07:16.319><c> you're</c><00:07:16.560><c> able</c><00:07:16.720><c> to</c>

00:07:16.870 --> 00:07:16.880 align:start position:0%
task port for a process, you're able to
 

00:07:16.880 --> 00:07:19.110 align:start position:0%
task port for a process, you're able to
read<00:07:17.039><c> and</c><00:07:17.280><c> write</c><00:07:17.520><c> the</c><00:07:17.680><c> process</c><00:07:18.080><c> memory</c><00:07:18.720><c> and</c>

00:07:19.110 --> 00:07:19.120 align:start position:0%
read and write the process memory and
 

00:07:19.120 --> 00:07:20.710 align:start position:0%
read and write the process memory and
control<00:07:19.440><c> many</c><00:07:19.759><c> other</c><00:07:19.919><c> aspects</c><00:07:20.319><c> of</c><00:07:20.479><c> that</c>

00:07:20.710 --> 00:07:20.720 align:start position:0%
control many other aspects of that
 

00:07:20.720 --> 00:07:22.469 align:start position:0%
control many other aspects of that
process.<00:07:21.440><c> And</c><00:07:21.599><c> so</c><00:07:21.759><c> in</c><00:07:21.919><c> the</c><00:07:22.080><c> case</c><00:07:22.160><c> of</c><00:07:22.319><c> the</c>

00:07:22.469 --> 00:07:22.479 align:start position:0%
process. And so in the case of the
 

00:07:22.479 --> 00:07:24.150 align:start position:0%
process. And so in the case of the
kernel's<00:07:22.880><c> task</c><00:07:23.199><c> port,</c><00:07:23.599><c> you'd</c><00:07:23.840><c> be</c><00:07:23.919><c> able</c><00:07:24.000><c> to</c>

00:07:24.150 --> 00:07:24.160 align:start position:0%
kernel's task port, you'd be able to
 

00:07:24.160 --> 00:07:26.150 align:start position:0%
kernel's task port, you'd be able to
read<00:07:24.319><c> and</c><00:07:24.560><c> write</c><00:07:24.800><c> kernel</c><00:07:25.120><c> memory.</c><00:07:25.840><c> In</c><00:07:26.080><c> order</c>

00:07:26.150 --> 00:07:26.160 align:start position:0%
read and write kernel memory. In order
 

00:07:26.160 --> 00:07:28.070 align:start position:0%
read and write kernel memory. In order
to<00:07:26.319><c> build</c><00:07:26.560><c> a</c><00:07:26.720><c> fake</c><00:07:27.039><c> kernel</c><00:07:27.360><c> task</c><00:07:27.680><c> port,</c><00:07:27.919><c> you</c>

00:07:28.070 --> 00:07:28.080 align:start position:0%
to build a fake kernel task port, you
 

00:07:28.080 --> 00:07:29.510 align:start position:0%
to build a fake kernel task port, you
would<00:07:28.240><c> need</c><00:07:28.319><c> to</c><00:07:28.479><c> place</c><00:07:28.720><c> some</c><00:07:28.960><c> values</c><00:07:29.280><c> in</c>

00:07:29.510 --> 00:07:29.520 align:start position:0%
would need to place some values in
 

00:07:29.520 --> 00:07:31.749 align:start position:0%
would need to place some values in
memory<00:07:30.160><c> that</c><00:07:30.400><c> resemble</c><00:07:30.880><c> the</c><00:07:31.199><c> layout</c><00:07:31.360><c> of</c><00:07:31.520><c> that</c>

00:07:31.749 --> 00:07:31.759 align:start position:0%
memory that resemble the layout of that
 

00:07:31.759 --> 00:07:33.270 align:start position:0%
memory that resemble the layout of that
structure<00:07:32.240><c> and</c><00:07:32.479><c> have</c><00:07:32.560><c> it</c><00:07:32.800><c> so</c><00:07:32.880><c> that</c><00:07:33.039><c> that</c>

00:07:33.270 --> 00:07:33.280 align:start position:0%
structure and have it so that that
 

00:07:33.280 --> 00:07:35.350 align:start position:0%
structure and have it so that that
memory<00:07:33.599><c> directly</c><00:07:34.080><c> overlaps</c><00:07:34.639><c> with</c><00:07:34.800><c> the</c><00:07:34.960><c> freed</c>

00:07:35.350 --> 00:07:35.360 align:start position:0%
memory directly overlaps with the freed
 

00:07:35.360 --> 00:07:37.350 align:start position:0%
memory directly overlaps with the freed
IPC<00:07:35.840><c> port.</c><00:07:36.240><c> Doing</c><00:07:36.479><c> this</c><00:07:36.639><c> reallocation</c>

00:07:37.350 --> 00:07:37.360 align:start position:0%
IPC port. Doing this reallocation
 

00:07:37.360 --> 00:07:39.350 align:start position:0%
IPC port. Doing this reallocation
requires<00:07:37.919><c> some</c><00:07:38.160><c> understanding</c><00:07:38.639><c> of</c><00:07:38.800><c> the</c><00:07:38.960><c> iOS</c>

00:07:39.350 --> 00:07:39.360 align:start position:0%
requires some understanding of the iOS
 

00:07:39.360 --> 00:07:41.029 align:start position:0%
requires some understanding of the iOS
kernel's<00:07:39.680><c> heap</c><00:07:39.919><c> allocator.</c><00:07:40.560><c> As</c><00:07:40.800><c> we've</c>

00:07:41.029 --> 00:07:41.039 align:start position:0%
kernel's heap allocator. As we've
 

00:07:41.039 --> 00:07:42.550 align:start position:0%
kernel's heap allocator. As we've
touched<00:07:41.199><c> on</c><00:07:41.440><c> in</c><00:07:41.680><c> other</c><00:07:41.919><c> videos</c><00:07:42.160><c> on</c><00:07:42.400><c> this</c>

00:07:42.550 --> 00:07:42.560 align:start position:0%
touched on in other videos on this
 

00:07:42.560 --> 00:07:44.629 align:start position:0%
touched on in other videos on this
channel,<00:07:42.880><c> the</c><00:07:43.120><c> iOS</c><00:07:43.440><c> kernel</c><00:07:43.840><c> divides</c><00:07:44.160><c> up</c><00:07:44.400><c> its</c>

00:07:44.629 --> 00:07:44.639 align:start position:0%
channel, the iOS kernel divides up its
 

00:07:44.639 --> 00:07:48.070 align:start position:0%
channel, the iOS kernel divides up its
heap<00:07:45.039><c> into</c><00:07:45.759><c> so-called</c><00:07:46.400><c> zones.</c><00:07:47.199><c> zones</c><00:07:47.759><c> serve</c>

00:07:48.070 --> 00:07:48.080 align:start position:0%
heap into so-called zones. zones serve
 

00:07:48.080 --> 00:07:50.550 align:start position:0%
heap into so-called zones. zones serve
allocations<00:07:48.720><c> for</c><00:07:49.039><c> specific</c><00:07:49.440><c> object</c><00:07:49.840><c> types</c><00:07:50.240><c> or</c>

00:07:50.550 --> 00:07:50.560 align:start position:0%
allocations for specific object types or
 

00:07:50.560 --> 00:07:53.189 align:start position:0%
allocations for specific object types or
sizes,<00:07:51.520><c> and</c><00:07:51.759><c> they</c><00:07:51.919><c> each</c><00:07:52.160><c> have</c><00:07:52.240><c> a</c><00:07:52.479><c> number</c><00:07:52.639><c> of</c><00:07:52.800><c> VM</c>

00:07:53.189 --> 00:07:53.199 align:start position:0%
sizes, and they each have a number of VM
 

00:07:53.199 --> 00:07:54.390 align:start position:0%
sizes, and they each have a number of VM
pages<00:07:53.520><c> to</c><00:07:53.759><c> work</c><00:07:53.919><c> with</c><00:07:54.080><c> for</c><00:07:54.240><c> their</c>

00:07:54.390 --> 00:07:54.400 align:start position:0%
pages to work with for their
 

00:07:54.400 --> 00:07:56.629 align:start position:0%
pages to work with for their
allocations.<00:07:55.280><c> Since</c><00:07:55.599><c> our</c><00:07:55.759><c> freed</c><00:07:56.080><c> object</c><00:07:56.400><c> is</c>

00:07:56.629 --> 00:07:56.639 align:start position:0%
allocations. Since our freed object is
 

00:07:56.639 --> 00:07:58.950 align:start position:0%
allocations. Since our freed object is
an<00:07:56.800><c> IPC</c><00:07:57.360><c> port,</c><00:07:57.759><c> it</c><00:07:57.919><c> was</c><00:07:58.080><c> allocated</c><00:07:58.479><c> within</c><00:07:58.800><c> the</c>

00:07:58.950 --> 00:07:58.960 align:start position:0%
an IPC port, it was allocated within the
 

00:07:58.960 --> 00:08:01.029 align:start position:0%
an IPC port, it was allocated within the
IPC<00:07:59.440><c> ports</c><00:07:59.840><c> zone.</c><00:08:00.400><c> This</c><00:08:00.560><c> is</c><00:08:00.720><c> slightly</c>

00:08:01.029 --> 00:08:01.039 align:start position:0%
IPC ports zone. This is slightly
 

00:08:01.039 --> 00:08:02.950 align:start position:0%
IPC ports zone. This is slightly
annoying<00:08:01.440><c> since</c><00:08:01.759><c> that</c><00:08:02.000><c> zone</c><00:08:02.240><c> is</c><00:08:02.479><c> dedicated</c>

00:08:02.950 --> 00:08:02.960 align:start position:0%
annoying since that zone is dedicated
 

00:08:02.960 --> 00:08:05.270 align:start position:0%
annoying since that zone is dedicated
specifically<00:08:03.440><c> to</c><00:08:03.680><c> IPC</c><00:08:04.160><c> port</c><00:08:04.400><c> structures,</c>

00:08:05.270 --> 00:08:05.280 align:start position:0%
specifically to IPC port structures,
 

00:08:05.280 --> 00:08:06.950 align:start position:0%
specifically to IPC port structures,
meaning<00:08:05.520><c> we</c><00:08:05.759><c> can't</c><00:08:06.000><c> directly</c><00:08:06.479><c> allocate</c>

00:08:06.950 --> 00:08:06.960 align:start position:0%
meaning we can't directly allocate
 

00:08:06.960 --> 00:08:08.869 align:start position:0%
meaning we can't directly allocate
arbitrary<00:08:07.440><c> data</c><00:08:07.680><c> here.</c><00:08:08.160><c> However,</c><00:08:08.479><c> as</c><00:08:08.639><c> a</c>

00:08:08.869 --> 00:08:08.879 align:start position:0%
arbitrary data here. However, as a
 

00:08:08.879 --> 00:08:10.790 align:start position:0%
arbitrary data here. However, as a
simple<00:08:09.120><c> workaround,</c><00:08:09.680><c> we</c><00:08:09.840><c> can</c><00:08:10.000><c> trigger</c><00:08:10.240><c> a</c><00:08:10.479><c> zone</c>

00:08:10.790 --> 00:08:10.800 align:start position:0%
simple workaround, we can trigger a zone
 

00:08:10.800 --> 00:08:12.629 align:start position:0%
simple workaround, we can trigger a zone
garbage<00:08:11.199><c> collection</c><00:08:11.680><c> before</c><00:08:12.000><c> performing</c><00:08:12.479><c> our</c>

00:08:12.629 --> 00:08:12.639 align:start position:0%
garbage collection before performing our
 

00:08:12.639 --> 00:08:14.790 align:start position:0%
garbage collection before performing our
heap<00:08:13.039><c> spray.</c><00:08:13.520><c> Zone</c><00:08:13.840><c> garbage</c><00:08:14.240><c> collections</c>

00:08:14.790 --> 00:08:14.800 align:start position:0%
heap spray. Zone garbage collections
 

00:08:14.800 --> 00:08:16.710 align:start position:0%
heap spray. Zone garbage collections
basically<00:08:15.280><c> scan</c><00:08:15.599><c> for</c><00:08:15.840><c> any</c><00:08:16.080><c> memory</c><00:08:16.400><c> page</c>

00:08:16.710 --> 00:08:16.720 align:start position:0%
basically scan for any memory page
 

00:08:16.720 --> 00:08:18.629 align:start position:0%
basically scan for any memory page
within<00:08:17.039><c> a</c><00:08:17.199><c> given</c><00:08:17.360><c> zone</c><00:08:17.680><c> that</c><00:08:18.000><c> is</c><00:08:18.160><c> completely</c>

00:08:18.629 --> 00:08:18.639 align:start position:0%
within a given zone that is completely
 

00:08:18.639 --> 00:08:21.270 align:start position:0%
within a given zone that is completely
empty<00:08:19.360><c> and</c><00:08:19.599><c> it</c><00:08:19.759><c> will</c><00:08:19.919><c> return</c><00:08:20.240><c> that</c><00:08:20.479><c> VM</c><00:08:20.879><c> page</c>

00:08:21.270 --> 00:08:21.280 align:start position:0%
empty and it will return that VM page
 

00:08:21.280 --> 00:08:23.749 align:start position:0%
empty and it will return that VM page
back<00:08:21.440><c> to</c><00:08:21.599><c> the</c><00:08:21.759><c> page</c><00:08:22.160><c> free</c><00:08:22.400><c> list</c><00:08:23.039><c> ready</c><00:08:23.280><c> for</c><00:08:23.520><c> use</c>

00:08:23.749 --> 00:08:23.759 align:start position:0%
back to the page free list ready for use
 

00:08:23.759 --> 00:08:25.589 align:start position:0%
back to the page free list ready for use
by<00:08:24.080><c> another</c><00:08:24.400><c> zone.</c><00:08:24.879><c> This</c><00:08:25.039><c> is</c><00:08:25.120><c> an</c><00:08:25.360><c> important</c>

00:08:25.589 --> 00:08:25.599 align:start position:0%
by another zone. This is an important
 

00:08:25.599 --> 00:08:27.749 align:start position:0%
by another zone. This is an important
mechanism<00:08:26.160><c> since</c><00:08:26.479><c> otherwise</c><00:08:27.039><c> zones</c><00:08:27.520><c> could</c><00:08:27.680><c> be</c>

00:08:27.749 --> 00:08:27.759 align:start position:0%
mechanism since otherwise zones could be
 

00:08:27.759 --> 00:08:29.350 align:start position:0%
mechanism since otherwise zones could be
hogging<00:08:28.160><c> a</c><00:08:28.319><c> bunch</c><00:08:28.479><c> of</c><00:08:28.560><c> pages</c><00:08:28.960><c> that</c><00:08:29.199><c> they</c>

00:08:29.350 --> 00:08:29.360 align:start position:0%
hogging a bunch of pages that they
 

00:08:29.360 --> 00:08:31.430 align:start position:0%
hogging a bunch of pages that they
aren't<00:08:29.599><c> actually</c><00:08:30.000><c> using</c><00:08:30.800><c> putting</c><00:08:31.120><c> memory</c>

00:08:31.430 --> 00:08:31.440 align:start position:0%
aren't actually using putting memory
 

00:08:31.440 --> 00:08:33.029 align:start position:0%
aren't actually using putting memory
strain<00:08:31.759><c> on</c><00:08:31.919><c> the</c><00:08:32.000><c> rest</c><00:08:32.080><c> of</c><00:08:32.159><c> the</c><00:08:32.320><c> system.</c><00:08:32.719><c> I</c><00:08:32.959><c> was</c>

00:08:33.029 --> 00:08:33.039 align:start position:0%
strain on the rest of the system. I was
 

00:08:33.039 --> 00:08:34.230 align:start position:0%
strain on the rest of the system. I was
playing<00:08:33.200><c> around</c><00:08:33.360><c> with</c><00:08:33.519><c> this</c><00:08:33.680><c> vulnerability</c>

00:08:34.230 --> 00:08:34.240 align:start position:0%
playing around with this vulnerability
 

00:08:34.240 --> 00:08:36.870 align:start position:0%
playing around with this vulnerability
on<00:08:34.479><c> a</c><00:08:34.640><c> very</c><00:08:34.880><c> old</c><00:08:35.200><c> iPhone</c><00:08:35.839><c> and</c><00:08:36.159><c> back</c><00:08:36.399><c> then</c><00:08:36.640><c> there</c>

00:08:36.870 --> 00:08:36.880 align:start position:0%
on a very old iPhone and back then there
 

00:08:36.880 --> 00:08:38.709 align:start position:0%
on a very old iPhone and back then there
actually<00:08:37.200><c> existed</c><00:08:37.680><c> a</c><00:08:37.919><c> system</c><00:08:38.320><c> function</c>

00:08:38.709 --> 00:08:38.719 align:start position:0%
actually existed a system function
 

00:08:38.719 --> 00:08:40.630 align:start position:0%
actually existed a system function
callable<00:08:39.120><c> from</c><00:08:39.360><c> user</c><00:08:39.680><c> space</c><00:08:40.159><c> that</c><00:08:40.399><c> would</c>

00:08:40.630 --> 00:08:40.640 align:start position:0%
callable from user space that would
 

00:08:40.640 --> 00:08:42.550 align:start position:0%
callable from user space that would
trigger<00:08:40.959><c> a</c><00:08:41.279><c> kernel</c><00:08:41.680><c> zone</c><00:08:41.919><c> garbage</c><00:08:42.240><c> collection</c>

00:08:42.550 --> 00:08:42.560 align:start position:0%
trigger a kernel zone garbage collection
 

00:08:42.560 --> 00:08:44.389 align:start position:0%
trigger a kernel zone garbage collection
when<00:08:42.880><c> called.</c><00:08:43.360><c> So</c><00:08:43.519><c> with</c><00:08:43.760><c> that</c><00:08:43.919><c> in</c><00:08:44.000><c> mind,</c><00:08:44.240><c> I</c>

00:08:44.389 --> 00:08:44.399 align:start position:0%
when called. So with that in mind, I
 

00:08:44.399 --> 00:08:46.230 align:start position:0%
when called. So with that in mind, I
performed<00:08:44.720><c> the</c><00:08:44.959><c> following</c><00:08:45.440><c> heap</c><00:08:45.760><c> shaping</c>

00:08:46.230 --> 00:08:46.240 align:start position:0%
performed the following heap shaping
 

00:08:46.240 --> 00:08:48.230 align:start position:0%
performed the following heap shaping
strategy.<00:08:46.880><c> I</c><00:08:47.120><c> first</c><00:08:47.360><c> ensured</c><00:08:47.839><c> that</c><00:08:48.000><c> my</c>

00:08:48.230 --> 00:08:48.240 align:start position:0%
strategy. I first ensured that my
 

00:08:48.240 --> 00:08:49.670 align:start position:0%
strategy. I first ensured that my
dangling<00:08:48.800><c> port</c><00:08:49.040><c> would</c><00:08:49.279><c> actually</c><00:08:49.519><c> be</c>

00:08:49.670 --> 00:08:49.680 align:start position:0%
dangling port would actually be
 

00:08:49.680 --> 00:08:51.910 align:start position:0%
dangling port would actually be
allocated<00:08:50.160><c> on</c><00:08:50.320><c> a</c><00:08:50.480><c> VM</c><00:08:50.880><c> page</c><00:08:51.200><c> full</c><00:08:51.360><c> of</c><00:08:51.600><c> other</c>

00:08:51.910 --> 00:08:51.920 align:start position:0%
allocated on a VM page full of other
 

00:08:51.920 --> 00:08:54.150 align:start position:0%
allocated on a VM page full of other
legitimate<00:08:52.480><c> mock</c><00:08:52.720><c> ports.</c><00:08:53.519><c> Then</c><00:08:53.839><c> after</c>

00:08:54.150 --> 00:08:54.160 align:start position:0%
legitimate mock ports. Then after
 

00:08:54.160 --> 00:08:56.070 align:start position:0%
legitimate mock ports. Then after
freeing<00:08:54.560><c> the</c><00:08:54.720><c> port</c><00:08:54.959><c> with</c><00:08:55.120><c> the</c><00:08:55.360><c> bug,</c><00:08:55.760><c> I</c><00:08:55.920><c> would</c>

00:08:56.070 --> 00:08:56.080 align:start position:0%
freeing the port with the bug, I would
 

00:08:56.080 --> 00:08:57.829 align:start position:0%
freeing the port with the bug, I would
also<00:08:56.399><c> deallocate</c><00:08:56.959><c> all</c><00:08:57.200><c> of</c><00:08:57.279><c> the</c><00:08:57.360><c> other</c><00:08:57.519><c> mock</c>

00:08:57.829 --> 00:08:57.839 align:start position:0%
also deallocate all of the other mock
 

00:08:57.839 --> 00:08:59.110 align:start position:0%
also deallocate all of the other mock
ports<00:08:58.080><c> that</c><00:08:58.160><c> were</c><00:08:58.240><c> on</c><00:08:58.399><c> that</c><00:08:58.560><c> same</c><00:08:58.720><c> memory</c>

00:08:59.110 --> 00:08:59.120 align:start position:0%
ports that were on that same memory
 

00:08:59.120 --> 00:09:01.110 align:start position:0%
ports that were on that same memory
page.<00:08:59.680><c> And</c><00:08:59.839><c> this</c><00:09:00.000><c> would</c><00:09:00.240><c> result</c><00:09:00.399><c> in</c><00:09:00.640><c> having</c><00:09:00.880><c> a</c>

00:09:01.110 --> 00:09:01.120 align:start position:0%
page. And this would result in having a
 

00:09:01.120 --> 00:09:03.110 align:start position:0%
page. And this would result in having a
completely<00:09:01.519><c> empty</c><00:09:01.839><c> page</c><00:09:02.160><c> of</c><00:09:02.320><c> memory</c><00:09:02.800><c> within</c>

00:09:03.110 --> 00:09:03.120 align:start position:0%
completely empty page of memory within
 

00:09:03.120 --> 00:09:05.110 align:start position:0%
completely empty page of memory within
the<00:09:03.279><c> IPC</c><00:09:03.760><c> port</c><00:09:04.080><c> zone</c><00:09:04.399><c> that</c><00:09:04.640><c> houses</c><00:09:04.959><c> our</c>

00:09:05.110 --> 00:09:05.120 align:start position:0%
the IPC port zone that houses our
 

00:09:05.120 --> 00:09:07.190 align:start position:0%
the IPC port zone that houses our
dangling<00:09:05.600><c> ports</c><00:09:05.920><c> address.</c><00:09:06.560><c> Now</c><00:09:06.800><c> when</c><00:09:07.040><c> we</c>

00:09:07.190 --> 00:09:07.200 align:start position:0%
dangling ports address. Now when we
 

00:09:07.200 --> 00:09:08.949 align:start position:0%
dangling ports address. Now when we
trigger<00:09:07.440><c> a</c><00:09:07.600><c> zone</c><00:09:07.839><c> garbage</c><00:09:08.240><c> collection</c><00:09:08.800><c> with</c>

00:09:08.949 --> 00:09:08.959 align:start position:0%
trigger a zone garbage collection with
 

00:09:08.959 --> 00:09:11.590 align:start position:0%
trigger a zone garbage collection with
the<00:09:09.200><c> muck</c><00:09:09.519><c> zone</c><00:09:09.839><c> force</c><00:09:10.240><c> GC</c><00:09:10.640><c> function</c><00:09:11.360><c> because</c>

00:09:11.590 --> 00:09:11.600 align:start position:0%
the muck zone force GC function because
 

00:09:11.600 --> 00:09:13.590 align:start position:0%
the muck zone force GC function because
that<00:09:11.839><c> VM</c><00:09:12.160><c> page</c><00:09:12.480><c> is</c><00:09:12.640><c> empty,</c><00:09:12.959><c> the</c><00:09:13.120><c> colonel</c><00:09:13.440><c> will</c>

00:09:13.590 --> 00:09:13.600 align:start position:0%
that VM page is empty, the colonel will
 

00:09:13.600 --> 00:09:15.030 align:start position:0%
that VM page is empty, the colonel will
give<00:09:13.760><c> that</c><00:09:14.000><c> page</c><00:09:14.320><c> back</c><00:09:14.480><c> to</c><00:09:14.640><c> the</c><00:09:14.800><c> page</c>

00:09:15.030 --> 00:09:15.040 align:start position:0%
give that page back to the page
 

00:09:15.040 --> 00:09:16.870 align:start position:0%
give that page back to the page
allocator.<00:09:15.680><c> Next,</c><00:09:16.000><c> we</c><00:09:16.160><c> need</c><00:09:16.320><c> to</c><00:09:16.399><c> spray</c><00:09:16.720><c> a</c>

00:09:16.870 --> 00:09:16.880 align:start position:0%
allocator. Next, we need to spray a
 

00:09:16.880 --> 00:09:18.630 align:start position:0%
allocator. Next, we need to spray a
large<00:09:17.120><c> amount</c><00:09:17.279><c> of</c><00:09:17.440><c> allocations</c><00:09:18.000><c> in</c><00:09:18.320><c> another</c>

00:09:18.630 --> 00:09:18.640 align:start position:0%
large amount of allocations in another
 

00:09:18.640 --> 00:09:20.470 align:start position:0%
large amount of allocations in another
zone.<00:09:19.040><c> I</c><00:09:19.279><c> chose</c><00:09:19.440><c> to</c><00:09:19.600><c> go</c><00:09:19.680><c> with</c><00:09:19.760><c> the</c><00:09:19.920><c> catalog</c>

00:09:20.470 --> 00:09:20.480 align:start position:0%
zone. I chose to go with the catalog
 

00:09:20.480 --> 00:09:23.590 align:start position:0%
zone. I chose to go with the catalog
1024<00:09:21.279><c> zone,</c><00:09:21.680><c> a</c><00:09:21.839><c> pure</c><00:09:22.160><c> data</c><00:09:22.480><c> zone,</c><00:09:23.120><c> which</c><00:09:23.279><c> I</c><00:09:23.519><c> can</c>

00:09:23.590 --> 00:09:23.600 align:start position:0%
1024 zone, a pure data zone, which I can
 

00:09:23.600 --> 00:09:25.670 align:start position:0%
1024 zone, a pure data zone, which I can
easily<00:09:23.920><c> spray</c><00:09:24.240><c> by</c><00:09:24.480><c> setting</c><00:09:24.880><c> arbitrary</c><00:09:25.360><c> data</c>

00:09:25.670 --> 00:09:25.680 align:start position:0%
easily spray by setting arbitrary data
 

00:09:25.680 --> 00:09:28.070 align:start position:0%
easily spray by setting arbitrary data
objects<00:09:26.160><c> on</c><00:09:26.320><c> an</c><00:09:26.480><c> IO</c><00:09:26.880><c> surface.</c><00:09:27.360><c> I</c><00:09:27.600><c> made</c><00:09:27.760><c> sure</c><00:09:27.920><c> to</c>

00:09:28.070 --> 00:09:28.080 align:start position:0%
objects on an IO surface. I made sure to
 

00:09:28.080 --> 00:09:29.829 align:start position:0%
objects on an IO surface. I made sure to
spray<00:09:28.399><c> enough</c><00:09:28.640><c> allocations</c><00:09:29.200><c> such</c><00:09:29.440><c> that</c><00:09:29.680><c> all</c>

00:09:29.829 --> 00:09:29.839 align:start position:0%
spray enough allocations such that all
 

00:09:29.839 --> 00:09:31.670 align:start position:0%
spray enough allocations such that all
of<00:09:30.000><c> the</c><00:09:30.160><c> free</c><00:09:30.399><c> slots</c><00:09:30.800><c> already</c><00:09:31.120><c> within</c><00:09:31.519><c> this</c>

00:09:31.670 --> 00:09:31.680 align:start position:0%
of the free slots already within this
 

00:09:31.680 --> 00:09:34.070 align:start position:0%
of the free slots already within this
zone<00:09:32.160><c> are</c><00:09:32.399><c> filled</c><00:09:32.800><c> and</c><00:09:33.040><c> a</c><00:09:33.279><c> zone</c><00:09:33.600><c> expansion</c>

00:09:34.070 --> 00:09:34.080 align:start position:0%
zone are filled and a zone expansion
 

00:09:34.080 --> 00:09:36.710 align:start position:0%
zone are filled and a zone expansion
gets<00:09:34.320><c> triggered.</c><00:09:35.120><c> On</c><00:09:35.440><c> expansion,</c><00:09:36.160><c> our</c><00:09:36.399><c> VM</c>

00:09:36.710 --> 00:09:36.720 align:start position:0%
gets triggered. On expansion, our VM
 

00:09:36.720 --> 00:09:38.949 align:start position:0%
gets triggered. On expansion, our VM
page<00:09:37.040><c> that</c><00:09:37.279><c> was</c><00:09:37.440><c> garbage</c><00:09:37.920><c> collected</c><00:09:38.399><c> before</c>

00:09:38.949 --> 00:09:38.959 align:start position:0%
page that was garbage collected before
 

00:09:38.959 --> 00:09:42.389 align:start position:0%
page that was garbage collected before
gets<00:09:39.279><c> assigned</c><00:09:39.760><c> to</c><00:09:39.920><c> the</c><00:09:40.160><c> caloc</c><00:09:40.640><c> 1024</c><00:09:41.360><c> zone</c><00:09:42.080><c> and</c>

00:09:42.389 --> 00:09:42.399 align:start position:0%
gets assigned to the caloc 1024 zone and
 

00:09:42.399 --> 00:09:44.150 align:start position:0%
gets assigned to the caloc 1024 zone and
subsequent<00:09:42.959><c> spray</c><00:09:43.279><c> allocations</c><00:09:43.760><c> will</c><00:09:44.000><c> land</c>

00:09:44.150 --> 00:09:44.160 align:start position:0%
subsequent spray allocations will land
 

00:09:44.160 --> 00:09:46.070 align:start position:0%
subsequent spray allocations will land
on<00:09:44.399><c> that</c><00:09:44.560><c> page.</c><00:09:45.200><c> And</c><00:09:45.360><c> now</c><00:09:45.600><c> we're</c><00:09:45.760><c> in</c><00:09:45.920><c> a</c>

00:09:46.070 --> 00:09:46.080 align:start position:0%
on that page. And now we're in a
 

00:09:46.080 --> 00:09:47.750 align:start position:0%
on that page. And now we're in a
position<00:09:46.240><c> where</c><00:09:46.480><c> the</c><00:09:46.640><c> old</c><00:09:46.880><c> memory</c><00:09:47.360><c> used</c><00:09:47.600><c> by</c>

00:09:47.750 --> 00:09:47.760 align:start position:0%
position where the old memory used by
 

00:09:47.760 --> 00:09:49.670 align:start position:0%
position where the old memory used by
that<00:09:48.000><c> dangling</c><00:09:48.399><c> IPC</c><00:09:48.880><c> port</c><00:09:49.279><c> has</c><00:09:49.519><c> been</c>

00:09:49.670 --> 00:09:49.680 align:start position:0%
that dangling IPC port has been
 

00:09:49.680 --> 00:09:51.509 align:start position:0%
that dangling IPC port has been
reallocated<00:09:50.240><c> with</c><00:09:50.560><c> completely</c><00:09:51.120><c> controlled</c>

00:09:51.509 --> 00:09:51.519 align:start position:0%
reallocated with completely controlled
 

00:09:51.519 --> 00:09:53.190 align:start position:0%
reallocated with completely controlled
contents<00:09:52.080><c> and</c><00:09:52.320><c> can</c><00:09:52.480><c> be</c><00:09:52.640><c> used</c><00:09:52.800><c> to</c><00:09:52.959><c> build</c>

00:09:53.190 --> 00:09:53.200 align:start position:0%
contents and can be used to build
 

00:09:53.200 --> 00:09:55.430 align:start position:0%
contents and can be used to build
powerful<00:09:53.680><c> exploit</c><00:09:54.080><c> primitives.</c><00:09:55.040><c> Reference</c>

00:09:55.430 --> 00:09:55.440 align:start position:0%
powerful exploit primitives. Reference
 

00:09:55.440 --> 00:09:57.269 align:start position:0%
powerful exploit primitives. Reference
counting<00:09:55.839><c> issues</c><00:09:56.240><c> are</c><00:09:56.399><c> a</c><00:09:56.640><c> common</c><00:09:56.880><c> path</c><00:09:57.120><c> to</c>

00:09:57.269 --> 00:09:57.279 align:start position:0%
counting issues are a common path to
 

00:09:57.279 --> 00:09:59.269 align:start position:0%
counting issues are a common path to
reach<00:09:57.440><c> a</c><00:09:57.600><c> use</c><00:09:57.839><c> after</c><00:09:58.160><c> free</c><00:09:58.399><c> condition.</c><00:09:59.120><c> And</c>

00:09:59.269 --> 00:09:59.279 align:start position:0%
reach a use after free condition. And
 

00:09:59.279 --> 00:10:01.190 align:start position:0%
reach a use after free condition. And
this<00:09:59.519><c> example</c><00:09:59.920><c> was</c><00:10:00.080><c> a</c><00:10:00.320><c> particularly</c><00:10:00.800><c> nice</c><00:10:00.959><c> one</c>

00:10:01.190 --> 00:10:01.200 align:start position:0%
this example was a particularly nice one
 

00:10:01.200 --> 00:10:02.630 align:start position:0%
this example was a particularly nice one
as<00:10:01.440><c> it</c><00:10:01.600><c> didn't</c><00:10:01.760><c> actually</c><00:10:02.000><c> involve</c><00:10:02.399><c> any</c>

00:10:02.630 --> 00:10:02.640 align:start position:0%
as it didn't actually involve any
 

00:10:02.640 --> 00:10:04.150 align:start position:0%
as it didn't actually involve any
complex<00:10:03.040><c> timing</c><00:10:03.440><c> issues</c><00:10:03.680><c> that</c><00:10:03.839><c> you</c><00:10:04.000><c> might</c>

00:10:04.150 --> 00:10:04.160 align:start position:0%
complex timing issues that you might
 

00:10:04.160 --> 00:10:06.310 align:start position:0%
complex timing issues that you might
face<00:10:04.480><c> in</c><00:10:04.880><c> race</c><00:10:05.200><c> conditions</c><00:10:05.760><c> which</c><00:10:05.920><c> are</c><00:10:06.160><c> more</c>

00:10:06.310 --> 00:10:06.320 align:start position:0%
face in race conditions which are more
 

00:10:06.320 --> 00:10:08.070 align:start position:0%
face in race conditions which are more
typical<00:10:06.560><c> for</c><00:10:06.800><c> this</c><00:10:06.959><c> bug</c><00:10:07.200><c> class.</c><00:10:07.760><c> Hopefully</c>

00:10:08.070 --> 00:10:08.080 align:start position:0%
typical for this bug class. Hopefully
 

00:10:08.080 --> 00:10:09.590 align:start position:0%
typical for this bug class. Hopefully
you<00:10:08.320><c> guys</c><00:10:08.480><c> learned</c><00:10:08.720><c> something</c><00:10:08.959><c> cool</c><00:10:09.200><c> in</c><00:10:09.440><c> this</c>

00:10:09.590 --> 00:10:09.600 align:start position:0%
you guys learned something cool in this
 

00:10:09.600 --> 00:10:11.430 align:start position:0%
you guys learned something cool in this
video<00:10:09.839><c> and</c><00:10:10.080><c> I'll</c><00:10:10.320><c> leave</c><00:10:10.480><c> all</c><00:10:10.640><c> reference</c><00:10:11.040><c> links</c>

00:10:11.430 --> 00:10:11.440 align:start position:0%
video and I'll leave all reference links
 

00:10:11.440 --> 00:10:13.430 align:start position:0%
video and I'll leave all reference links
down<00:10:11.680><c> below</c><00:10:11.920><c> in</c><00:10:12.160><c> the</c><00:10:12.320><c> description.</c><00:10:13.200><c> Thanks</c>

00:10:13.430 --> 00:10:13.440 align:start position:0%
down below in the description. Thanks
 

00:10:13.440 --> 00:10:14.870 align:start position:0%
down below in the description. Thanks
for<00:10:13.600><c> watching</c><00:10:13.839><c> and</c><00:10:14.079><c> I'll</c><00:10:14.320><c> see</c><00:10:14.480><c> you</c><00:10:14.640><c> in</c><00:10:14.800><c> the</c>

00:10:14.870 --> 00:10:14.880 align:start position:0%
for watching and I'll see you in the
 

00:10:14.880 --> 00:10:17.040 align:start position:0%
for watching and I'll see you in the
next

