Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 246310 Details for
Bug 335492
LVM tools on hardened kernel caused mlock error
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
reduced testcase
testcase.c (text/plain), 1.72 KB, created by
Diego Elio Pettenò (RETIRED)
on 2010-09-06 21:48:39 UTC
(
hide
)
Description:
reduced testcase
Filename:
MIME Type:
Creator:
Diego Elio Pettenò (RETIRED)
Created:
2010-09-06 21:48:39 UTC
Size:
1.72 KB
patch
obsolete
>#define _GNU_SOURCE > >#include <limits.h> >#include <fcntl.h> >#include <unistd.h> >#include <sys/mman.h> >#include <sys/time.h> >#include <sys/resource.h> >#include <stdio.h> >#include <string.h> > >/* list of maps, that are unconditionaly ignored */ >static const char * const _ignore_maps[] = { > "[vdso]", > "[vsyscall]", > "locale/locale-archive", > "gconv/gconv-modules.cache", >}; > >/* > * mlock/munlock memory areas from /proc/self/maps > * format described in kernel/Documentation/filesystem/proc.txt > */ >static void _maps_line(const char* line) >{ > const struct config_node *cn; > struct config_value *cv; > long from, to; > int pos, i; > char fr, fw, fx, fp; > size_t sz; > > if (sscanf(line, "%lx-%lx %c%c%c%c%n", > &from, &to, &fr, &fw, &fx, &fp, &pos) != 6) { > fprintf(stderr, "Failed to parse maps line: %s\n", line); > return; > } > > if (fr != 'r') { > fprintf(stderr, "mlock area unreadable %s : Skipping.\n", > line); > return; > } > > for (i = 0; i < sizeof(_ignore_maps) / sizeof(_ignore_maps[0]); ++i) > if (strstr(line + pos, _ignore_maps[i])) { > fprintf(stderr, "mlock ignore filter '%s' matches '%s': Skipping.\n", > _ignore_maps[i], line); > return; > } > > sz = to - from; > > fprintf(stderr, "mlock %10ldKiB %12lx - %12lx %c%c%c%c%s\n", > ((long)sz + 1023) / 1024, from, to, fr, fw, fx, fp, line + pos); > > if (mlock((const void*)from, sz) < 0) { > perror("mlock"); > return; > } > > return; >} > >int main() >{ > FILE *_mapsh; > ssize_t n; > size_t len; > char *line = NULL; > > if ( !(_mapsh = fopen("/proc/self/maps", "r")) ) > return -1; > > while ((n = getline(&line, &len, _mapsh)) != -1) { > line[n > 0 ? n - 1 : 0] = '\0'; /* remove \n */ > _maps_line(line); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 335492
: 246310