From eldon@dbs.ifom-firc.it  Fri Jun 23 09:58:54 2006
Return-Path: <eldon@dbs.ifom-firc.it>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 7207316A49A
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 23 Jun 2006 09:58:54 +0000 (UTC)
	(envelope-from eldon@dbs.ifom-firc.it)
Received: from mail.ifom-firc.it (mail.ifom-firc.it [85.239.175.131])
	by mx1.FreeBSD.org (Postfix) with ESMTP id A10A843D45
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 23 Jun 2006 09:58:53 +0000 (GMT)
	(envelope-from eldon@dbs.ifom-firc.it)
Received: (qmail 6693 invoked by uid 811); 23 Jun 2006 09:59:34 -0000
Received: from 85.239.175.67 by mail.ifom-firc.it (envelope-from <eldon@dbs.ifom-firc.it>, uid 803) with qmail-scanner-1.25 
 (clamdscan: 0.88.2/1562. f-prot: 4.4.2/3.14.11. spamassassin: 3.1.3.  
 Clear:RC:1(85.239.175.67):. 
 Processed in 0.163549 secs); 23 Jun 2006 09:59:34 -0000
Received: from unknown (HELO dbs.ifom-firc.it) ([85.239.175.67])
          (envelope-sender <eldon@dbs.ifom-firc.it>)
          by smtp.ifom-firc.it (qmail-ldap-1.03) with SMTP
          for <FreeBSD-gnats-submit@freebsd.org>; 23 Jun 2006 09:59:34 -0000
Received: (from eldon@dbs.ifom-firc.it)
	by dbs.ifom-firc.it (mini_sendmail/1.3.6 29jun2005);
	Fri, 23 Jun 2006 11:58:51 CEST
	(sender eldon@dbs.ifom-firc.it)
Message-Id: <20060623095853.A10A843D45@mx1.FreeBSD.org>
Date: Fri, 23 Jun 2006 09:58:53 +0000 (GMT)
From: Valerio Daelli valerio.daelli@gmail.com
Reply-To: Valerio Daelli valerio.daelli@gmail.com
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: man page of sendmsg(2) does not include EINVAL
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         99356
>Category:       docs
>Synopsis:       man page of sendmsg(2) does not include EINVAL
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ru
>State:          analyzed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 23 10:00:34 GMT 2006
>Closed-Date:    
>Last-Modified:  Wed Dec 19 21:20:00 UTC 2012
>Originator:     Valerio Daelli
>Release:        FreeBSD 5.4-RELEASE-p12 i386
>Organization:
IFOM
>Environment:
System: FreeBSD dbs.ifom-firc.it 5.4-RELEASE-p12 FreeBSD 5.4-RELEASE-p12 #0: Thu Mar 2 15:40:11 CET 2006 root@dbs.ifom-firc.it:/usr/obj/usr/src/sys/DBS i386


	
>Description:
        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
>Fix:


>Release-Note:
>Audit-Trail:
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.) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=99356 
State-Changed-From-To: open->analyzed 
State-Changed-By: rwatson 
State-Changed-When: Sun Jan 13 19:28:16 UTC 2008 
State-Changed-Why:  
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. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=99356 

From: Robert Watson <rwatson@FreeBSD.org>
To: Ruslan Ermilov <ru@FreeBSD.org>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: docs/99356: man page of sendmsg(2) does not include EINVAL
Date: Sun, 13 Jan 2008 19:26:50 +0000 (GMT)

 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
Responsible-Changed-From-To: rwatson->ru 
Responsible-Changed-By: rwatson 
Responsible-Changed-When: Sun Jan 13 19:33:04 UTC 2008 
Responsible-Changed-Why:  
Assign back to Ruslan now he's had my incredibly tardy response. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=99356 

From: Philip Withnall <prw35@cam.ac.uk>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: docs/99356: man page of sendmsg(2) does not include EINVAL
Date: Wed, 19 Dec 2012 21:19:39 +0000

 --=-Wl3NdM3ZYrUV1YHMSIBZ
 Content-Type: text/plain; charset="UTF-8"
 Content-Transfer-Encoding: quoted-printable
 
 > 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 !=3D NULL) when
 (msg_controllen =3D=3D 0).
 
 For this reason, I think the man page should stress that if you=E2=80=99re
 constructing a message with no ancillary data, it=E2=80=99s not enough to j=
 ust
 set msg_controllen to 0 =E2=80=94 you must also set msg_control to NULL.
 
 (Stumbled over this because some software I=E2=80=99m 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 =E2=80=94 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
 
 --=-Wl3NdM3ZYrUV1YHMSIBZ
 Content-Type: application/pgp-signature; name="signature.asc"
 Content-Description: This is a digitally signed message part
 Content-Transfer-Encoding: 7bit
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.12 (GNU/Linux)
 
 iF4EABEIAAYFAlDSL2wACgkQ8JQuiUsur6D2VQD/R0bKKfaWN10lDz27OgM4kVbq
 TkLcdG22IvZ5rrIpdqQA/j7ojYEWutj/mc50crb6Vq5JAfRnyB2BxRAfCT+i26ZK
 =5ZZj
 -----END PGP SIGNATURE-----
 
 --=-Wl3NdM3ZYrUV1YHMSIBZ--
 
>Unformatted:
