Page MenuHomeFreeBSD

net: Validate interface group names in ioctl handlers
ClosedPublic

Authored by markj on Fri, Oct 24, 8:34 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 14, 10:28 PM
Unknown Object (File)
Sat, Nov 8, 6:32 PM
Unknown Object (File)
Thu, Nov 6, 7:13 PM
Unknown Object (File)
Thu, Nov 6, 12:49 AM
Unknown Object (File)
Tue, Nov 4, 6:58 PM
Unknown Object (File)
Sat, Nov 1, 9:11 PM
Unknown Object (File)
Thu, Oct 30, 10:34 PM
Unknown Object (File)
Thu, Oct 30, 10:01 PM

Details

Diff Detail

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

Event Timeline

markj requested review of this revision.Fri, Oct 24, 8:34 PM
zlei added a subscriber: zlei.
zlei added inline comments.
sys/net/if.c
2853

What about the error ENAMETOOLONG ? I think that is more precise what's wrong. Just like error of the renaming of interface,

# ifconfig epair0a name aabbccddaabbccdd
ifconfig: ioctl SIOCSIFNAME (set name): File name too long
This revision is now accepted and ready to land.Sat, Oct 25, 3:36 AM
ivy added inline comments.
sys/net/if.c
2853

ENAMETOOLONG does not seem appropriate, even if it's used elsewhere:

63 ENAMETOOLONG File name too long. A component of a path name exceeded
    {NAME_MAX} characters, or an entire path name exceeded {PATH_MAX}
    characters.  See also the description of _PC_NO_TRUNC in pathconf(2).

however, wouldn't this be an ideal place to use exterr?

sys/net/if.c
2853

IMHO, ENAMETOOLONG is better than EINVAL, although mentions a file. Of course a proper exterrorizing is better. But if there is no extra time to work on that, I would prefer ENAMETOOLONG.

sys/net/if.c
2853

The fact is that we have limited errors to use, and some, EINVAL e.g., are too generic to hint what's wrong behind.

So if we can use a more precise error, and do not lead to much confusion, then that is appropriate.

Fo example, use error ENAMETOOLONG instead of EINVAL in this context, that rename interfaces or adding / removing a group, although the error ENAMETOOLONG is from the filesystem domain, but it should not cause confusion in the network domain, hence IMO it is an appropriate usage.

sys/net/if.c
2853

The error is because the group name buffer is not nul-terminated, not because the name is too long. It's up to userspace to check whether the group name is too long. So I think ENAMETOOLONG is wrong.

I don't have any plan to exterrize this. The group ioctls themselves are simple and probably don't need it (most of the error paths are from if_addgroup() incorrectly using M_NOWAIT to perform allocations), though I agree that it'd be useful for some other ifnet ioctls.

sys/net/if.c
2853

I see your point. That the userland should pass in a struct ifgroupreq in good shape. Then EINVAL is proper.