-
Notifications
You must be signed in to change notification settings - Fork 6
/
examples.html
315 lines (268 loc) · 10.5 KB
/
examples.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<!doctype html>
<html>
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-EER1LDV4TH"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-EER1LDV4TH');
</script>
<title>PatchDB</title>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1">
<link href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" media="screen" rel="stylesheet" type="text/css" />
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/base/jquery-ui.css" media="screen" rel="stylesheet" type="text/css" />
<link href="css/frame.css" media="screen" rel="stylesheet" type="text/css" />
<link href="css/controls.css" media="screen" rel="stylesheet" type="text/css" />
<link href="css/widgets.css" media="screen" rel="stylesheet" type="text/css" />
<link href="css/custom.css" media="screen" rel="stylesheet" type="text/css" />
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700' rel='stylesheet' type='text/css'>
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="js/menu.js"></script>
<script src="js/widgets.js"></script>
<script src="js/custom.js"></script>
<style>
.menu-examples {
color: rgb(255, 255, 255) !important;
opacity: 1 !important;
font-weight: 700 !important;
}
pre {
font-family: Consolas, "courier new";
color: gray;
background-color: #f1f1f1;
padding: 10px;
font-size: 90%;
}
</style>
</head>
<body>
<div class="menu-container"></div>
<div class="content-container">
<div class="content">
<div class="content-table flex-column">
<!-------------------------------------------------------------------------------------------->
<div class="flex-row">
<div class="flex-item flex-column">
<h2 class="add-top-margin">Typical Examples</h2>
<hr>
<p style="font-size:14pt;">
Security Patches contains multiple categories.
</p>
<ul style="font-size:13pt;">
<li>buffer overflow</li>
<li>improper input validation</li>
<li>info leakage</li>
<li>double free/use after free</li>
<li>integer overflow</li>
<li>NULL pointer dereference</li>
<li>improper authentication</li>
<li>uncontrolled resource consumption</li>
<li>race condition</li>
<li>unintialized use</li>
<li>et al.</li>
</ul>
<p style="font-size:14pt;">
Below are some typical examples in PatchDB.
</p>
<p style="font-size:15pt;">
<strong>Example I: Buffer Overflow</strong>
</p>
<pre>
From 8514068150759c1d6a46d4605d2351babfde1601 Mon Sep 17 00:00:00 2001
From: Johan Hedberg <johan.hedberg@intel.com>
Date: Wed, 7 Sep 2016 08:45:12 +0300
Subject: tools/csr: Fix possible buffer overflow
<font color="black">Make sure we don't write past the end of the array.</font>
---
tools/csr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
<font color="#5114D9">diff --git a/tools/csr.c b/tools/csr.c</font>
index 2c0918909..15ae7c4fb 100644
<font color="#cf3a4b">--- a/tools/csr.c</font>
<font color="#1e9c41">+++ b/tools/csr.c</font>
<font color="#9A21F0">@@ -2756,7 +2756,7 @@</font> static int parse_line(char *str)
off++;
<font color="#cf3a4b">- while (1) {</font>
<font color="#1e9c41">+ while (length <= sizeof(array) - 2) {</font>
value = strtol(off, &end, 16);
if (value == 0 && off == end)
break;
--
cgit 1.2-0.3.lf.el7</pre>
<p style="font-size:15pt;">
<strong>Example II: Info Leakage</strong>
</p>
<pre>
From 0f6ceabab0a8849b47f67d727aa526c2656089ba Mon Sep 17 00:00:00 2001
From: Klas Lindfors <klas@yubico.com>
Date: Tue, 3 Apr 2018 09:19:53 +0200
Subject: [PATCH] util: make sure to close the authfile before returning
success
<font color="black">fixes #136</font>
---
util.c | 2 ++
1 file changed, 2 insertions(+)
<font color="#5114D9">diff --git a/util.c b/util.c</font>
index 6cb4a79..32bca06 100644
<font color="#cf3a4b">--- a/util.c</font>
<font color="#1e9c41">+++ b/util.c</font>
<font color="#9A21F0">@@ -167,6 +167,8 @@</font> check_user_token (const char *authfile,
{
if(verbose)
D (debug_file, "Match user/token as %s/%s", username, otp_id);
<font color="#1e9c41">+
+ fclose(opwfile);</font>
return AUTH_FOUND;
}
}</pre>
<p style="font-size:15pt;">
<strong>Example III: Double Free</strong>
</p>
<pre>
From 9b54d816e00425c3a517514e0d677bb3cec49258 Mon Sep 17 00:00:00 2001
From: Hou Tao <houtao1@huawei.com>
Date: Fri, 3 Feb 2017 17:19:07 +0800
Subject: [PATCH] blkcg: fix double free of new_blkg in blkcg_init_queue
<font color="black">If blkg_create fails, new_blkg passed as an argument will
be freed by blkg_create, so there is no need to free it again.</font>
Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
---
block/blk-cgroup.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
<font color="#5114D9">diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c</font>
index 37fe595cfd700..295e98c2c8ccd 100644
<font color="#cf3a4b">--- a/block/blk-cgroup.c</font>
<font color="#1e9c41">+++ b/block/blk-cgroup.c</font>
<font color="#9A21F0">@@ -1079,10 +1079,8 @@</font> int blkcg_init_queue(struct request_queue *q)
if (preloaded)
radix_tree_preload_end();
<font color="#cf3a4b">- if (IS_ERR(blkg)) {
- blkg_free(new_blkg);</font>
<font color="#1e9c41">+ if (IS_ERR(blkg))</font>
return PTR_ERR(blkg);
<font color="#cf3a4b">- }</font>
q->root_blkg = blkg;
q->root_rl.blkg = blkg;</pre>
<p style="font-size:15pt;">
<strong>Example IV: Integer Overflow</strong>
</p>
<pre>
From cab60de930684c33f67d4e32c7509b567f8c445b Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Wed, 26 Mar 2014 13:05:53 +0100
Subject: [PATCH] qcow2: Fix new L1 table size check (CVE-2014-0143)
<font color="black">The size in bytes is assigned to an int later, so check that instead of
the number of entries.</font>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/qcow2-cluster.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
<font color="#5114D9">diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c</font>
index 9499df9..242e1f8 100644
<font color="#cf3a4b">--- a/block/qcow2-cluster.c</font>
<font color="#1e9c41">+++ b/block/qcow2-cluster.c</font>
<font color="#9A21F0">@@ -55,7 +55,7 @@</font> int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size,
}
}
<font color="#cf3a4b">- if (new_l1_size > INT_MAX) {</font>
<font color="#1e9c41">+ if (new_l1_size > INT_MAX / sizeof(uint64_t)) {</font>
return -EFBIG;
}
--
1.8.3.1</pre>
<p style="font-size:15pt;">
<strong>Example V: NULL Pointer Dereference</strong>
</p>
<pre>
From f58c25069cf4a986fe17a80c5b38687e31feb539 Mon Sep 17 00:00:00 2001
From: Sebastian Pipping <sebastian@pipping.org>
Date: Wed, 10 Oct 2018 14:49:51 +0200
Subject: [PATCH] ResetUri: Protect against NULL
---
src/UriCommon.c | 3 +++
1 file changed, 3 insertions(+)
<font color="#5114D9">diff --git a/src/UriCommon.c b/src/UriCommon.c</font>
index 3775306..039beda 100644
<font color="#cf3a4b">--- a/src/UriCommon.c</font>
<font color="#1e9c41">+++ b/src/UriCommon.c</font>
<font color="#9A21F0">@@ -75,6 +75,9 @@</font>
void URI_FUNC(ResetUri)(URI_TYPE(Uri) * uri) {
<font color="#1e9c41">+ if (uri == NULL) {
+ return;
+ }</font>
memset(uri, 0, sizeof(URI_TYPE(Uri)));
}</pre>
<p style="font-size:15pt;">
<strong>Example VI: Race Condition</strong>
</p>
<pre>
From 2febc839133280d5a5e8e1179c94ea674489dae2 Mon Sep 17 00:00:00 2001
From: Andy Honig <ahonig@google.com>
Date: Wed, 27 Aug 2014 14:42:54 -0700
Subject: [PATCH] KVM: x86: Improve thread safety in pit
<font color="black">There's a race condition in the PIT emulation code in KVM. In
__kvm_migrate_pit_timer the pit_timer object is accessed without
synchronization. If the race condition occurs at the wrong time this
can crash the host kernel.
This fixes CVE-2014-3611.</font>
Cc: stable@vger.kernel.org
Signed-off-by: Andrew Honig <ahonig@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
arch/x86/kvm/i8254.c | 2 ++
1 file changed, 2 insertions(+)
<font color="#5114D9">diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c</font>
index 518d86471b76f..298781d4cfb44 100644
<font color="#cf3a4b">--- a/arch/x86/kvm/i8254.c</font>
<font color="#1e9c41">+++ b/arch/x86/kvm/i8254.c</font>
<font color="#9A21F0">@@ -262,8 +262,10 @@</font> void __kvm_migrate_pit_timer(struct kvm_vcpu *vcpu)
return;
timer = &pit->pit_state.timer;
<font color="#1e9c41">+ mutex_lock(&pit->pit_state.lock);</font>
if (hrtimer_cancel(timer))
hrtimer_start_expires(timer, HRTIMER_MODE_ABS);
<font color="#1e9c41">+ mutex_unlock(&pit->pit_state.lock);</font>
}
static void destroy_pit_timer(struct kvm_pit *pit)</pre>
<p style="font-size:15pt;">
<strong>Example VII: Non-security Patch</strong>
</p>
<pre>
commit 822959238c224535e2d71e936e9f8c8d27a10a59
Author: roberto@precise64 <roberto@precise64>
Date: Thu Feb 23 16:58:36 2012 +0100
<font color="black"> fixed a bug with --set</font>
<font color="#5114D9">diff --git a/uwsgi.c b/uwsgi.c</font>
index 3a24f6aa..178fb5db 100644
<font color="#cf3a4b">--- a/uwsgi.c</font>
<font color="#1e9c41">+++ b/uwsgi.c</font>
<font color="#9A21F0">@@ -3387,7 +3387,7 @@</font> void uwsgi_opt_set_placeholder(char *opt, char *value, void *none) {
p[0] = 0;
add_exported_option(uwsgi_str(value), p+1, 1);
<font color="#cf3a4b">- p[1] = '=';</font>
<font color="#1e9c41">+ p[0] = '=';</font>
}</pre>
</div>
</div>
<!-------------------------------------------------------------------------------------------->
<div class="flex-row">
<div class="flex-item flex-item-stretch flex-column">
<br /><br />
<p class="text text-small text-italic">
The PatchDB Dataset | <span class="highlight-text">Sun Security Laboratory</span> at <span class="highlight-text">George Mason University</span>
</p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>