Bug 99356 - man page of sendmsg(2) does not include EINVAL
Summary: man page of sendmsg(2) does not include EINVAL
Status: Open
Alias: None
Product: Documentation
Classification: Unclassified
Component: Manual Pages (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: easy, needs-patch
Depends on:
Blocks:
 
Reported: 2006-06-23 11:00 UTC by valerio.daelli
Modified: 2023-10-07 18:26 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description valerio.daelli freebsd_committer freebsd_triage 2006-06-23 11:00:34 UTC
        The man page of sendmsg(2) does not include EINVAL as possible
        error value. EINVAL is a possible error value as it appears 
        in then sendit() function in /usr/src/sys/kern/uipc_syscalls.c

How-To-Repeat:         man sendmsg
Comment 1 ru freebsd_committer freebsd_triage 2006-10-12 19:40:19 UTC
Responsible Changed
From-To: freebsd-doc->rwatson

Robert, can you please look into this?  POSIX says that EINVAL 
may be returned if "the sum of the iov_len values overflows an 
ssize_t".  I see a similar code in FreeBSD: 

for (i = 0; i < mp->msg_iovlen; i++, iov++) { 
if ((auio.uio_resid += iov->iov_len) < 0) { 
error = EINVAL; 
goto bad; 
} 
} 

except the type of uio_resid in FreeBSD is "int".  (On NetBSD, 
it's size_t.)
Comment 2 Robert Watson freebsd_committer freebsd_triage 2008-01-13 19:26:50 UTC
On Thu, 12 Oct 2006, Ruslan Ermilov wrote:

> Synopsis: man page of sendmsg(2) does not include EINVAL
>
> Responsible-Changed-From-To: freebsd-doc->rwatson
> Responsible-Changed-By: ru
> Responsible-Changed-When: Thu Oct 12 18:40:19 UTC 2006
> Responsible-Changed-Why:
> Robert, can you please look into this?  POSIX says that EINVAL
> may be returned if "the sum of the iov_len values overflows an
> ssize_t".  I see a similar code in FreeBSD:
>
>        for (i = 0; i < mp->msg_iovlen; i++, iov++) {
>                if ((auio.uio_resid += iov->iov_len) < 0) {
>                        error = EINVAL;
>                        goto bad;
>                }
>        }
>
> except the type of uio_resid in FreeBSD is "int".  (On NetBSD,
> it's size_t.)

We can also return EINVAL if msg_controllen is less than the minimum size of a 
valid cmesg (which must include a struct cmsghdr).

Robert N M Watson
Computer Laboratory
University of Cambridge
Comment 3 Robert Watson freebsd_committer freebsd_triage 2008-01-13 19:28:16 UTC
State Changed
From-To: open->analyzed

Follow-up e-mail with analysis forthcoming.  The man page does need to 
be updated to take into account this and other EINVAL cases.  There 
are also some cases in specific protocols where EINVAL can be returned.
Comment 4 Robert Watson freebsd_committer freebsd_triage 2008-01-13 19:33:04 UTC
Responsible Changed
From-To: rwatson->ru

Assign back to Ruslan now he's had my incredibly tardy response.
Comment 5 Philip Withnall 2012-12-19 21:19:39 UTC
> We can also return EINVAL if msg_controllen is less than the minimum
> size of a valid cmesg (which must include a struct cmsghdr).


As a corollary, EINVAL will be returned if (msg_control != NULL) when
(msg_controllen == 0).

For this reason, I think the man page should stress that if youâre
constructing a message with no ancillary data, itâs not enough to just
set msg_controllen to 0 â you must also set msg_control to NULL.

(Stumbled over this because some software Iâm porting has a single
function which handles all sendmsg() invocations for the software. This
function unconditionally sets the iovec fields, and conditionally sets
the control fields â except it was actually unconditionally setting
msg_control to some buffer, and conditionally setting msg_controllen
based on whether the buffer was meaningful. That works on Linux, but not
FreeBSD.)

Philip
Comment 6 Eitan Adler freebsd_committer freebsd_triage 2018-01-08 04:14:49 UTC
For the following conditions
Product: Base System, Documentation Status: New, Open, In Progress, UNCONFIRMED 
Assignee: Former FreeBSD committer 

Reset to default assignee. Reset status to "Open".