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
Differential D59413
uiomove: Use size_t for the length argument Authored by des on Fri, Sep 4, 6:44 PM. Tags None Referenced Files
Details
Diff Detail
Event TimelineComment Actions Did you inspected all callers to ensure that they do not pass negative n/len and rely on n < 0 checks?
Comment Actions BTW, it should be much easier to change the n/len argument to ssize_t. I think this is a way to go. Comment Actions No, that would not fix the problem of callers passing a size_t to uiomove() without first checking for overflow. Comment Actions It would be only practical problem on 32bit kernels. And even then, if size_t overflows, the check for n < 0 catches it. Comment Actions Signed integer overflow is undefined behavior in C. I will not commit code that deliberately relies on it.
Comment Actions It is not, in kernel. We compile with -fwrap specifically to have this defined.
Comment Actions There's thousands of places where this is done, iirc the conversations when we added the flag. Comment Actions So if you still insist on using size_t for length, I have to ask again, were all callers inspected to make sure that they do not rely on the behavior for len < 0 'do nothing'? Comment Actions I'm working on it. There are over 200, so it's going to take some time. I'll add those patches to D59412. Comment Actions Claude claimed 352 calls. Also, claude generated code whose exit path leaked buffer locks, etc, so adding that to your thinking would be good, if you weren't already considering it :) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||