Page MenuHomeFreeBSD

uiomove: Use size_t for the length argument
Needs ReviewPublic

Authored by des on Fri, Sep 4, 6:44 PM.

Details

Summary

In many if not most cases, the caller has a size_t or off_t. Passing it
as an int may result in overflow.

PR: 298159

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 76523
Build 73406: arc lint + arc unit

Event Timeline

des requested review of this revision.Fri, Sep 4, 6:44 PM

Did you inspected all callers to ensure that they do not pass negative n/len and rely on n < 0 checks?

sys/amd64/amd64/uio_machdep.c
78

since you are changing the lines anyway

sys/powerpc/powerpc/uio_machdep.c
104

I think the change should add asserts that iov_len >= cnt, uio_resid >= cnt. and most importantly len >= cnt.

sys/amd64/amd64/uio_machdep.c
78

Please use != 0 in preference to > 0 for unsigned values. (Same for occurrences below.)