Skip to content

Commit 327685c

Browse files
avaginrst0git
authored andcommitted
zdtm/vdso02: unmap vvar_vclock mappings
It is a part of vvar and this test intends to unmap vdso and all vvar mappings. Fixes #2622 Signed-off-by: Andrei Vagin <[email protected]>
1 parent 12bb0de commit 327685c

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

test/zdtm/static/vdso02.c

+24-7
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ static int parse_vm_area(char *buf, struct vm_area *vma)
2929
return -1;
3030
}
3131

32-
static int find_blobs(pid_t pid, struct vm_area *vdso, struct vm_area *vvar)
32+
static int find_blobs(pid_t pid, struct vm_area *vdso,
33+
struct vm_area *vvar, struct vm_area *vvar_vclock)
3334
{
3435
char buf[BUF_SZ];
3536
int ret = -1;
@@ -39,6 +40,8 @@ static int find_blobs(pid_t pid, struct vm_area *vdso, struct vm_area *vvar)
3940
vdso->end = VDSO_BAD_ADDR;
4041
vvar->start = VVAR_BAD_ADDR;
4142
vvar->end = VVAR_BAD_ADDR;
43+
vvar_vclock->start = VVAR_BAD_ADDR;
44+
vvar_vclock->end = VVAR_BAD_ADDR;
4245

4346
if (snprintf(buf, BUF_SZ, "/proc/%d/maps", pid) < 0) {
4447
pr_perror("snprintf() failure for path");
@@ -57,12 +60,18 @@ static int find_blobs(pid_t pid, struct vm_area *vdso, struct vm_area *vvar)
5760

5861
if (strstr(buf, "[vvar]") && parse_vm_area(buf, vvar))
5962
goto err;
63+
if (strstr(buf, "[vvar_vclock]") &&
64+
parse_vm_area(buf, vvar_vclock))
65+
goto err;
6066
}
6167

6268
if (vdso->start != VDSO_BAD_ADDR)
6369
test_msg("[vdso] %lx-%lx\n", vdso->start, vdso->end);
6470
if (vvar->start != VVAR_BAD_ADDR)
6571
test_msg("[vvar] %lx-%lx\n", vvar->start, vvar->end);
72+
if (vvar_vclock->start != VVAR_BAD_ADDR)
73+
test_msg("[vvar_vclock] %lx-%lx\n",
74+
vvar_vclock->start, vvar_vclock->end);
6675
ret = 0;
6776
err:
6877
fclose(maps);
@@ -143,10 +152,10 @@ void sys_exit(int status)
143152

144153
static int unmap_blobs(void)
145154
{
146-
struct vm_area vdso, vvar;
155+
struct vm_area vdso, vvar, vvar_vclock;
147156
int ret;
148157

149-
if (find_blobs(getpid(), &vdso, &vvar))
158+
if (find_blobs(getpid(), &vdso, &vvar, &vvar_vclock))
150159
return -1;
151160

152161
if (vdso.start != VDSO_BAD_ADDR) {
@@ -159,13 +168,19 @@ static int unmap_blobs(void)
159168
if (ret)
160169
return ret;
161170
}
171+
if (vvar_vclock.start != VVAR_BAD_ADDR) {
172+
ret = sys_munmap((void *)vvar_vclock.start,
173+
vvar_vclock.end - vvar_vclock.start);
174+
if (ret)
175+
return ret;
176+
}
162177

163178
return 0;
164179
}
165180

166181
int main(int argc, char *argv[])
167182
{
168-
struct vm_area vdso, vvar;
183+
struct vm_area vdso, vvar, vvar_vclock;
169184
pid_t child;
170185
int status, ret = -1;
171186

@@ -201,17 +216,19 @@ int main(int argc, char *argv[])
201216
goto out_kill;
202217
}
203218

204-
if (find_blobs(child, &vdso, &vvar))
219+
if (find_blobs(child, &vdso, &vvar, &vvar_vclock))
205220
goto out_kill;
206-
if (vdso.start != VDSO_BAD_ADDR || vvar.start != VVAR_BAD_ADDR) {
221+
if (vdso.start != VDSO_BAD_ADDR ||
222+
vvar.start != VVAR_BAD_ADDR ||
223+
vvar_vclock.start != VVAR_BAD_ADDR) {
207224
pr_err("Found vvar or vdso blob(s) in child, which should have unmapped them\n");
208225
goto out_kill;
209226
}
210227

211228
test_daemon();
212229
test_waitsig();
213230

214-
if (find_blobs(child, &vdso, &vvar))
231+
if (find_blobs(child, &vdso, &vvar, &vvar_vclock))
215232
goto out_kill;
216233
if (vdso.start != VDSO_BAD_ADDR || vvar.start != VVAR_BAD_ADDR) {
217234
pr_err("Child without vdso got it after C/R\n");

0 commit comments

Comments
 (0)