1
00:00:00,000 --> 00:00:05,007
(upbeat music)

2
00:00:05,007 --> 00:00:08,004
- [Instructor] We've got some good challenges for you here.

3
00:00:08,004 --> 00:00:10,008
So we got to do some kernel configuration.

4
00:00:10,008 --> 00:00:15,006
I'm just going to use make menuconfig.

5
00:00:15,006 --> 00:00:21,000
The first one is remove ReiserFS support.

6
00:00:21,000 --> 00:00:23,005
And that's a file system.

7
00:00:23,005 --> 00:00:26,004
So we look at the top level here.

8
00:00:26,004 --> 00:00:29,007
We find file systems

9
00:00:29,007 --> 00:00:33,007
and we look for ReiserFS and we find it right there.

10
00:00:33,007 --> 00:00:38,000
It's currently by default chosen as a module.

11
00:00:38,000 --> 00:00:42,003
It is deprecated though, so I'm going to hit space bar.

12
00:00:42,003 --> 00:00:44,001
That turns it into an asterisk.

13
00:00:44,001 --> 00:00:47,001
I hit space bar again, turns it off.

14
00:00:47,001 --> 00:00:49,008
So that removes it.

15
00:00:49,008 --> 00:00:52,008
And then I can get out of file systems here by moving

16
00:00:52,008 --> 00:00:55,003
with my arrow key over to exit.

17
00:00:55,003 --> 00:01:00,008
And the next one was choosing debug atomic sleep.

18
00:01:00,008 --> 00:01:03,000
So where could that be?

19
00:01:03,000 --> 00:01:06,007
Now one thing you could do with these is you could do a grep

20
00:01:06,007 --> 00:01:10,004
throughout the kernel source looking at K config files.

21
00:01:10,004 --> 00:01:12,009
And I do that sometimes.

22
00:01:12,009 --> 00:01:15,006
You could try a search in here.

23
00:01:15,006 --> 00:01:18,006
I'll leave that up to you how you find it.

24
00:01:18,006 --> 00:01:20,007
But I believe debug atomic sleep

25
00:01:20,007 --> 00:01:23,007
is underneath kernel hacking.

26
00:01:23,007 --> 00:01:27,009
So there's kernel hacking

27
00:01:27,009 --> 00:01:33,006
and where would it be under there?

28
00:01:33,006 --> 00:01:37,005
Okay, I don't see it at this level.

29
00:01:37,005 --> 00:01:40,001
Scheduler?

30
00:01:40,001 --> 00:01:41,003
No.

31
00:01:41,003 --> 00:01:45,004
Alright, so this is the process of trying to find stuff.

32
00:01:45,004 --> 00:01:46,002
Let's see.

33
00:01:46,002 --> 00:01:47,004
It's debug atomic sleep.

34
00:01:47,004 --> 00:01:50,005
That's locking.

35
00:01:50,005 --> 00:01:53,006
So how about lock debugging?

36
00:01:53,006 --> 00:01:58,002
We're looking for debug atomic sleep.

37
00:01:58,002 --> 00:02:02,007
How about sleep inside atomic section checking.

38
00:02:02,007 --> 00:02:04,005
Let's see if that could be it.

39
00:02:04,005 --> 00:02:06,009
We go to help.

40
00:02:06,009 --> 00:02:11,004
And the top there says config debug_atomic_sleep.

41
00:02:11,004 --> 00:02:13,004
So we could have searched for that.

42
00:02:13,004 --> 00:02:16,005
Maybe did that, you found it quickly, alright?

43
00:02:16,005 --> 00:02:19,008
And we want to turn that on.

44
00:02:19,008 --> 00:02:22,000
So we exit out of the help here.

45
00:02:22,000 --> 00:02:25,003
We hit the space bar, that turns it on.

46
00:02:25,003 --> 00:02:28,002
And then we got some questions

47
00:02:28,002 --> 00:02:31,006
about disable heap randomization.

48
00:02:31,006 --> 00:02:34,007
It's another challenging one to find.

49
00:02:34,007 --> 00:02:37,008
I'm going to the top level here

50
00:02:37,008 --> 00:02:44,005
and I believe that's under memory management options.

51
00:02:44,005 --> 00:02:48,006
We're looking for disable heap randomization.

52
00:02:48,006 --> 00:02:49,004
There it is.

53
00:02:49,004 --> 00:02:51,004
It's off.

54
00:02:51,004 --> 00:02:53,001
The challenge didn't say to turn it on,

55
00:02:53,001 --> 00:02:56,001
it just said is it safe for recent distros.

56
00:02:56,001 --> 00:02:58,000
And what's the default?

57
00:02:58,000 --> 00:03:00,006
So let's do the help.

58
00:03:00,006 --> 00:03:04,003
Okay, so it was off, so the default was off.

59
00:03:04,003 --> 00:03:06,004
That's also known as n.

60
00:03:06,004 --> 00:03:09,003
So we see that equals n there.

61
00:03:09,003 --> 00:03:13,005
That means the default is not on.

62
00:03:13,005 --> 00:03:18,001
And it says here on ancient distros,

63
00:03:18,001 --> 00:03:22,002
post 2000 ones, off is usually a safe choice.

64
00:03:22,002 --> 00:03:24,006
So we could turn it off.

65
00:03:24,006 --> 00:03:26,006
That would be okay.

66
00:03:26,006 --> 00:03:30,002
Alright, so we found that documentation

67
00:03:30,002 --> 00:03:34,005
and then we want to find KVM.

68
00:03:34,005 --> 00:03:36,003
Is that enabled as a module?

69
00:03:36,003 --> 00:03:38,004
What'll be the module name?

70
00:03:38,004 --> 00:03:40,004
So that's kernel virtual machines.

71
00:03:40,004 --> 00:03:43,007
Let's look under virtualization.

72
00:03:43,007 --> 00:03:46,006
There's KVM right there.

73
00:03:46,006 --> 00:03:49,001
It's enabled as a module, yes.

74
00:03:49,001 --> 00:03:52,002
And then we do a help on that.

75
00:03:52,002 --> 00:03:56,001
And here in documentation it says the module

76
00:03:56,001 --> 00:03:58,007
will be called KVM.

77
00:03:58,007 --> 00:04:02,000
So if we do an LS mod, we could see if KVM is loaded.

78
00:04:02,000 --> 00:04:04,007
Otherwise we could do a mod probe on that.

79
00:04:04,007 --> 00:04:08,004
What device file will refer to it.

80
00:04:08,004 --> 00:04:11,001
And it says right here a character device node

81
00:04:11,001 --> 00:04:13,007
or file will be called dev/kvm.

82
00:04:13,007 --> 00:04:15,000
There you go.

83
00:04:15,000 --> 00:04:18,000
Alright, so we did a bunch of config related stuff.

84
00:04:18,000 --> 00:04:21,003
We're going to exit out of here.

85
00:04:21,003 --> 00:04:23,004
Let's build bzImage.

86
00:04:23,004 --> 00:04:26,009
Now if you did change any configuration options

87
00:04:26,009 --> 00:04:29,004
and you had already built it, it might take a while

88
00:04:29,004 --> 00:04:32,006
to build it again, but I built it

89
00:04:32,006 --> 00:04:33,008
and didn't change anything,

90
00:04:33,008 --> 00:04:37,001
so I'm just going to do the command to do it again.

91
00:04:37,001 --> 00:04:40,009
And it shouldn't take long.

92
00:04:40,009 --> 00:04:50,004
In fact, we'll time it and we'll spell it correctly.

93
00:04:50,004 --> 00:04:52,008
Alright, it only took 11 and a half seconds.

94
00:04:52,008 --> 00:04:55,003
It says it's right there.

95
00:04:55,003 --> 00:05:06,003
Let's see how big it is.

96
00:05:06,003 --> 00:05:11,005
So it is about 14 meg.

97
00:05:11,005 --> 00:05:20,008
Let's look how big the kernel image we boot from,

98
00:05:20,008 --> 00:05:24,004
how big that file is.

99
00:05:24,004 --> 00:05:27,009
And it's pretty close to the same size, right?

100
00:05:27,009 --> 00:05:29,009
And then what about VM Linux?

101
00:05:29,009 --> 00:05:31,004
Well, it turns out VM Linux

102
00:05:31,004 --> 00:05:35,001
is in the top level kernel directory.

103
00:05:35,001 --> 00:05:39,000
And if we look at that,

104
00:05:39,000 --> 00:05:42,000
that file is much, much bigger.

105
00:05:42,000 --> 00:05:47,008
So let's see, that's like 397 meg.

106
00:05:47,008 --> 00:05:51,006
And if we ask what kind of file is that?

107
00:05:51,006 --> 00:05:58,009
It's actually a statically linked x86-64 executable.

108
00:05:58,009 --> 00:06:01,005
You need the VM Linux file sometimes

109
00:06:01,005 --> 00:06:02,006
for like debugging the kernel

110
00:06:02,006 --> 00:06:07,002
'cause it's got the symbols in it and so forth.

111
00:06:07,002 --> 00:06:10,000
But otherwise you don't need it

112
00:06:10,000 --> 00:06:14,001
and you're booting with the bzImage file renamed

113
00:06:14,001 --> 00:06:15,008
and put in boot.

114
00:06:15,008 --> 00:06:17,001
Alright, I hope that was helpful.

115
00:06:17,001 --> 00:06:19,008
I hope you learned a lot about the kernel.

116
00:06:19,008 --> 00:06:24,000
It's really useful and cool stuff, thanks.

