Page MenuHomeFreeBSD

uiomove_object_page: a failed copy can still dirty the page
ClosedPublic

Authored by alc on Sat, Oct 3, 5:54 PM.
Tags
None
Referenced Files
F174817219: D60280.id.diff
Tue, Oct 6, 4:48 AM
F174817216: D60280.id188560.diff
Tue, Oct 6, 4:48 AM
F174758803: D60280.diff
Mon, Oct 5, 7:34 PM
F174753371: D60280.diff
Mon, Oct 5, 6:31 PM
Unknown Object (File)
Sun, Oct 4, 2:32 AM
Unknown Object (File)
Sun, Oct 4, 2:23 AM
Unknown Object (File)
Sun, Oct 4, 1:33 AM
Unknown Object (File)
Sun, Oct 4, 1:31 AM
Subscribers

Details

Summary

If we fail in the middle of reading from the source, the destination page may have already been dirtied. For example, the source may cross a page boundary, and the second page is inaccessible. Conservatively mark the destination page as dirty, even on errors.

Reported by: Claude (Opus 5.5)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

alc requested review of this revision.Sat, Oct 3, 5:54 PM

I've been reviewing places where we already sync the icache or might need to.

We can compare the old and new uio_resid then.

In D60280#1383380, @kib wrote:

We can compare the old and new uio_resid then.

For this to work, uiomove_phys() should also avoid crossing userspace page boundaries, not just phys page boundaries.

This revision is now accepted and ready to land.Sat, Oct 3, 11:49 PM
In D60280#1383380, @kib wrote:

We can compare the old and new uio_resid then.

Suppose that the first copyin() by uiomove_fromphys() will cross a page boundary in the source, but not in the destination. Data will be copied from the first source page to the destination page, and at the crossing in the source copyin() fails. uio_resid won't be updated. uiomove_fromphys() only updates uio_resid after at least one successful copyin().

In D60280#1383381, @kib wrote:
In D60280#1383380, @kib wrote:

We can compare the old and new uio_resid then.

For this to work, uiomove_phys() should also avoid crossing userspace page boundaries, not just phys page boundaries.

Yes, which is unlikely to be worth the trouble, unless errors become a lot more common.

sys/kern/uipc_shm.c
253–254

I'm going to drop the second sentence from this comment. I don't think that it really adds much.