Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Jul 1996 15:52:34 -0400 (EDT)
From:      "Garrett A. Wollman" <wollman@khavrinen.lcs.mit.edu>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/1421: Non-bug in sosend()
Message-ID:  <199607231952.PAA02018@khavrinen.lcs.mit.edu>
Resent-Message-ID: <199607232000.NAA08189@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         1421
>Category:       kern
>Synopsis:       Non-bug in sosend()
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 23 13:00:00 PDT 1996
>Last-Modified:
>Originator:     Garrett Wollman
>Organization:
MIT Laboratory for Computer Science
>Release:        FreeBSD 2.2-CURRENT i386
>Environment:

	-current as of 7/23, although I have no reason to believe that this
	bug has not existed for a very long time indeed.

>Description:

	While in the process of re-working sosend() for TCP, I noticed
	this odd bit of code:

	if (resid < 0)
		return (EINVAL);

	This is preceded by a comment explaining why resid is signed
	in the first place.  BUT, note that this code exits
	immediately without freeing `control', which it does in all
	other error cases.  (It also doesn't free `top' but that case
	is not relevant here.)

	Having noticed this, I then attempted to demonstrate the memory
	leak.  However, I determined that it was impossible to do so,
	because all of the possible entry points where a user program
	might set up its own `iovec' check for overflow when computing
	`uio->uio_resid' and trap the error before sosend() ever sees
	it.  This is true in particular of sendmsg(2), which is the
	only system call resulting in anything in `control' to begin
	with.  So, the entire test is a logical error and should be
	eliminated (or at least hidden under #ifdef DIAGNOSTIC).

	I seem to recall a time when this test was actually necessary.

>How-To-Repeat:

	Inspect the code.

>Fix:
	
	Well, it doesn't matter much, but it would not be a bad thing
	to #ifdef out the test.
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199607231952.PAA02018>