tags 625747 fixed-usptream
thanks

Hello Brian,

On Thu, May 5, 2011 at 6:22 PM, brian m. carlson
<sand...@crustytoothpaste.net> wrote:
> Package: manpages-dev
> Version: 3.27-1
> Severity: normal
> File: /usr/share/man/man2/mlock.2.gz
>
> The prototype for the mlock(2) function specifies the argument len as
> size_t.  POSIX and C99 mandate that size_t be unsigned.  However, one of
> the possible errors for mlock is EINVAL: len was negative.
>
> This is clearly an error.  Since len must be unsigned, it cannot be
> negative.  Because the prototype matches /usr/include/sys/mman.h, I
> presume that the error code is incorrect rather than the prototype.

In fact, the error code is correct, but it's not well explained in the
man page. See do_mlock() in mm/mlock.c in the kernel source. The point
is that 'len' can be specified as a negative value, but that is
treated as an unsigned quantity. However, with the check

       end = start + len;
        if (end < start)
                return -EINVAL;

the resulting overflow on addition effectively amounts to a
subtraction, and the condition "end < start" becomes true. For
man-pages-3.33, I applied the patch below.

Cheers,

Michael

--- a/man2/mlock.2
+++ b/man2/mlock.2
@@ -157,8 +157,11 @@ and
 Some or all of the specified address range could not be locked.
 .TP
 .B EINVAL
-.I len
-was negative.
+The result of the addition
+.IR start + len
+was less than
+.IR start
+(e.g., the addition may have resuled in an overflow).
 .TP
 .B EINVAL
 (Not on Linux)



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface"; http://man7.org/tlpi/



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to