[PATCH] increase the upper limit of sg_io64.dxfer_len to make "sg_logs -p=0x0f /dev/sgN" happy

Woody Zhou zhouwoody at yahoo.com
Fri Jun 4 12:38:08 EST 2004


Hello all,

  Following is a patch to remedy an "invalid argument" error while
executing "sg_logs -p=0x0f /dev/sgN". I submit it here for your
review. At this place /dev/sgN should be mapped to a SCSI device
which support page 0x0f(Application client), such as IBM
IC35L036UCDY10-0 disks.

Index: 2.4.21-15.EL/arch/ppc64/kernel/ioctl32.c
===================================================================
--- arch/ppc64/kernel/ioctl32.c.orig    2004-05-25
15:18:46.000000000 +0800
+++ arch/ppc64/kernel/ioctl32.c 2004-05-25 15:20:33.000000000 +0800
@@ -1301,7 +1301,7 @@
                        goto out;
                }
        } else {
-               if (sg_io64.dxfer_len > 4*PAGE_SIZE) {
+               if (sg_io64.dxfer_len > 8*PAGE_SIZE) {
                        err = -EINVAL;
                        goto out;
                }
===================================================================

  As follow is a short explanation for this. In the conversion code
between 32bit and 64bit native ioctl(arch/ppc64/kernel/ioctl32.c),
sg_ioctl_trans limit the sg_io64.dxfer_len to 4 pages, maybe to
stop users from performing denial of service attack by asking the
kernel to kmalloc an unreasonable amount of memory. However the
size limit seems to be too small, since SCSI LOG SENSE page 0x0f
always ask for 4*PAGE_SIZE+4. So I made a change to this:
increasing it to 8*PAGE_SIZE.

   This patch is suggested by Matin Schwenke at OZlab. So thanks for
your guidance, Martin! It is made against Redhat's 2.4.21-15.EL,
and should also apply to other 2.4 kernel.

Thanks and Best Regards
---------------------------------------------
Wu Zhou
LTC and pLinux Testing, China Software Development Lab, Beijing
TEL: (8610)82782244-2830   FAX: (8610)82782244-2887   E-mail: zhouwu at cn.ibm.com

** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc64-dev mailing list