]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
[PATCH] compat ifconf: fix limits
authorRandy Dunlap <rdunlap@xenotime.net>
Thu, 9 Mar 2006 01:43:17 +0000 (17:43 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 28 Mar 2006 07:00:22 +0000 (23:00 -0800)
A recent change to compat. dev_ifconf() in fs/compat_ioctl.c
causes ifconf data to be truncated 1 entry too early when copying it
to userspace.  The correct amount of data (length) is returned,
but the final entry is empty (zero, not filled in).
The for-loop 'i' check should use <= to allow the final struct
ifreq32 to be copied.  I also used the ifconf-corruption program
in kernel bugzilla #4746 to make sure that this change does not
re-introduce the corruption.

Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/compat_ioctl.c

index 43a2508ac69670d972516a0f5d2ad96f8e7bfa02..8b19b33b40715219c128d60e5816ac6a97339d70 100644 (file)
@@ -687,7 +687,7 @@ static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg)
        ifr = ifc.ifc_req;
        ifr32 = compat_ptr(ifc32.ifcbuf);
        for (i = 0, j = 0;
-             i + sizeof (struct ifreq32) < ifc32.ifc_len && j < ifc.ifc_len;
+             i + sizeof (struct ifreq32) <= ifc32.ifc_len && j < ifc.ifc_len;
             i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) {
                if (copy_in_user(ifr32, ifr, sizeof (struct ifreq32)))
                        return -EFAULT;