aio_mlock(2) system call

Bruce Evans brde at optusnet.com.au
Wed Jun 5 00:12:42 UTC 2013


On Tue, 4 Jun 2013, Konstantin Belousov wrote:

> On Tue, Jun 04, 2013 at 03:30:35PM +0400, Gleb Smirnoff wrote:
>>   Updated patch.
>>
> I have no further comments.
>
> You might want to make the switch of double casts to DEVOLATILE()
> in the other parts of vfs_aio.c as separate commit.

DEVOLATILE() should only be committed to /dev/null.  It masks API
bugs.  An ordinary cast is sufficiently ugly and doesn't break
detection of the bugs by -Wcast-qual.

If a variable is actually volatile, then casting away its volatile'ness
breaks it.  The breakage is larger than with casting away const.  But
I think that with aio, the bug is using the application API in the
kernel.  The buffer is volatile in userland but isn't really volatile
in the kernel (no more than any buffer that may be written to by DMA.
Others are mostly not declared volatile).

uio has sort of the opposite problem.  It is older than const and void,
so it cannot use them.  More fundamentally, it only has a single i/o
pointer so the pointer cannot be const since it is used for input.  But
when writing, the source buffer may be const or even volatile.  Its
pointer cannot be assigned to the uio pointer without casting away
qualifiers.

Bruce


More information about the freebsd-arch mailing list