This is related to this bug: http://bugme.osdl.org/show_bug.cgi?id=2995 The kernel currently only checks that the memory is file-backed if MADV_WILLNEED is set. It's not entirely clear from the manpage at least that *all* non-file-backed madvise() calls should fail. The attached patch returns -EBADF for all non-file-backed madvise() calls. I'm not suggesting that this is the absolutely right behavior, but it certainly does what the bug submitter wants. Comments? -- Dave