|
|
Log in / Subscribe / Register

Trinity and memory management testing

By Jonathan Corbet
March 26, 2014

2014 LSFMM Summit
The Trinity tool is a system call fuzz-testing utility for the Linux kernel. By supplying random data to the kernel in a focused way, Trinity has managed to expose a large number of bugs over the years. Trinity maintainer Dave Jones addressed the memory management track at the 2014 Linux Storage, Filesystem, and Memory Management Summit to talk about how he is using the tool to turn up memory management bugs in particular.

He started by describing an idea he heard from Al Viro: create a memory range with mmap(), unmap a single page in the middle of that range, then pass the result to various system calls and see what happens. As he described it, "all hell broke loose." Large numbers of bugs have been turned up, followed by "heroic efforts" in the memory management community to fix them. As a result of those efforts, he said, he is now unable to find any problems in the 3.14-rc7 kernel's memory management code, which is a good thing.

On the other hand, Sasha Levin has been using Trinity to find bugs in the linux-next tree, where they are rather more plentiful. Those bugs often move into the mainline during the merge window. Bringing more stability to the code in linux-next before it is merged would be a worthwhile thing to do.

In general, Dave said, Trinity is good at finding bugs in the dark corners of the kernel that nobody makes much use of. So areas like huge pages, page migration, and the mbind() system call have been fertile ground. In the case of mbind(), it turned out that all callers were going through a user-space library. That library did argument checking, so, naturally, the system call itself did not. The result was a predictable pile of bugs which have now been fixed.

Lots of parts of the memory management subsystem are, he said, simply not getting adequate testing now. Trinity helps in this area, but its memory management testing is still on the rudimentary side. He wants to develop it further; he plans to work on memory management fuzzing for much of the rest of the year. But, even now, Trinity is finding more bugs in the memory management code than can be dealt with.

Huge pages generate lots of bug reports from Fedora users; they also are the source of lots of problems found by Trinity. Reproducing those bugs in any more standard setting is hard, though; many of them involve applications, like the Java runtime, that Dave is unfamiliar with and uninterested in learning more about. So, for now, transparent huge pages are simply turned off for his Trinity runs.

Reproduction of crashes provoked by Trinity is an ongoing problem in general. The tool can log everything that it does, but the logging is, itself, an expensive operation that can change timings to the point that a lot of problems simply go away. Many crashes are also the result of corrupted internal state in the kernel; the sequence that causes the corruption may happen a long time before that corruption causes the kernel to crash. So establishing the cause of crashes can be difficult.

Dave had a couple of requests for memory management developers. One was for anybody adding new flags to existing system calls; when that happens, he would like to get a note so that he can start testing calls with that flag. He'll often notice them in the patch stream anyway, but an explicit notification is more reliable. The other thing he would like is to see more developers running Trinity on their systems. It is trivial to set up, he said; so there is no real reason not to make use of it.

[Your editor would like to thank the Linux Foundation for supporting his travel to the Summit.]

Index entries for this article
KernelDevelopment tools/Trinity
ConferenceStorage, Filesystem, and Memory-Management Summit/2014


to post comments

Trinity and memory management testing

Posted Mar 27, 2014 1:38 UTC (Thu) by mathstuf (subscriber, #69389) [Link] (3 responses)

> The tool can log everything that it does, but the logging is, itself, an expensive operation that can change timings to the point that a lot of problems simply go away.

Is it possible to log what it is *planning* to do rather than logging in situ?

Trinity and memory management testing

Posted Mar 27, 2014 5:50 UTC (Thu) by dlang (guest, #313) [Link]

even that can distort timing and memory use.

Trinity and memory management testing

Posted Mar 27, 2014 14:19 UTC (Thu) by fuhchee (guest, #40059) [Link] (1 responses)

That could consist of logging the random number generator seed.

Trinity and memory management testing

Posted Mar 27, 2014 17:51 UTC (Thu) by dlang (guest, #313) [Link]

only as long as nothing that Trinity does involves multiple threads/processes, and as long as nothing that it does depends on the response that it gets back from the system that could possibly change from run to run (or kernel to kernel)

Trinity and memory management testing

Posted Mar 29, 2014 16:56 UTC (Sat) by sashal (✭ supporter ✭, #81842) [Link]

IMO it's the kernel, not Trinity, that should be improving it's logging mechanism.

Think of Trinity as a random black box userspace app. Heck, think of it as some random DB server that has wacky coders. You don't solve kernel crashes by asking userspace apps to add debug information, you add those debug facilities in the kernel.

Trinity and memory management testing

Posted Apr 7, 2014 12:26 UTC (Mon) by metan (subscriber, #74107) [Link]

> Dave had a couple of requests for memory management developers. One was for anybody adding new flags to existing system calls; when that happens, he would like to get a note so that he can start testing calls with that flag.

I would love to have authoritative list of newly added kernel interfaces as well. There were cases where I found out about new syscall flags/values more or less by chance and I had to write tests and update the manual pages as well. It would be far more easier if we had such list so that we can easily check that that newly added interfaces are properly documented and tested.


Copyright © 2014, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds