/* wait 200ms for FUSE-request to be active */
usleep(200000);
/* unmount mapping before sealing to avoid i_mmap_writable failures */
munmap(global_p, mfd_def_size);
/* Try sealing the global file; expect EBUSY or success. Current *kernelswillneversucceed,butinthefuture,kernelsmight *implementpage-replacementsorotherfancywaystoavoidracing
* writes. */
r = mfd_busy_add_seals(global_mfd, F_SEAL_WRITE); if (r >= 0) {
printf("HURRAY! This kernel fixed GUP races!\n");
} else { /* wait 1s more so the FUSE-request is done */
sleep(1);
/* try sealing the global file again */
mfd_assert_add_seals(global_mfd, F_SEAL_WRITE);
}
/* mmap memfd-object for writing */
p = mfd_assert_mmap_shared(mfd);
/* pass mfd+mapping to a separate sealing-thread which tries to seal
* the memfd objects with SEAL_WRITE while we write into it */
global_mfd = mfd;
global_p = p;
pid = spawn_sealing_thread();
/* Use read() on the FUSE file to read into our memory-mapped memfd *object.Thisracestheotherthreadwhichtriestosealthe *memfd-object. *If@fdisonthememfd-fake-FUSE-FS,theread()isdelayedby1s. *Thisguaranteesthatthereceive-bufferispinnedfor1suntilthe *dataiswrittenintoit.TheracingADD_SEALSshouldthusfailas
* the pages are still pinned. */
r = read(fd, p, mfd_def_size); if (r < 0) {
printf("read() failed: %m\n");
abort();
} elseif (!r) {
printf("unexpected EOF on read()\n");
abort();
}
/* Wait for sealing-thread to finish and verify that it
* successfully sealed the file after the second try. */
join_sealing_thread(pid);
mfd_assert_has_seals(mfd, F_SEAL_WRITE);
/* *IF* the memfd-object was sealed at the time our read() returned, *thenthekerneldidapage-replacementorcanceledtheread()(or *whatevermagicitdid..).Inthatcase,thememfdobjectisstill *allzero. *Incasethememfd-objectwas*not*sealed,theread()wassuccessful *andthememfdobjectmust*not*beallzero. *Notethatinrealscenarios,theremightbeamixtureofboth,but *inthistest-cases,wehaveexplicit200msdelayswhichshouldbe
* enough to avoid any in-flight writes. */
p = mfd_assert_mmap_private(mfd); if (was_sealed && memcmp(p, zero, mfd_def_size)) {
printf("memfd sealed during read() but data not discarded\n");
abort();
} elseif (!was_sealed && !memcmp(p, zero, mfd_def_size)) {
printf("memfd sealed after read() but data discarded\n");
abort();
}
close(mfd);
close(fd);
printf("fuse: DONE\n");
free(zero);
return0;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-10-12)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.