lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Fri, 26 Jun 2009 16:40:57 +0800
From:	zhou sf <sxzzsf@...il.com>
To:	linux-kernel@...r.kernel.org
Subject: SG_DXFER_TO_FROM_DEV does not copy user buffer to driver buffer in 
	linux 2.6.28 and later?

Test with the following program, and dump the data buf at queuecommand
of the driver, found the data is something like:
"00 00 00 00 ff 53 4d 42 2e 00 00 00 00 80 01 c0 00 00 00 00 00 00 00
00 00 00 00 00 02 20 4a ..."
While before 2.6.28, it is "ec ec ec ec ..." as expected.


#include <string.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <scsi/sg.h>

int main(int argc, char* argv[])
{
       int fd;
       sg_io_hdr_t io_hdr;
       int ret;

       unsigned char sensebuf[32], cdb[16], outbuf[256];

       if ((argc!=2) || (fd = open(argv[1], O_RDWR)) < 0) {
               return -1;
       }

       memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
       memset(cdb, 0, sizeof(cdb));
       memset(outbuf, 0xec, sizeof(outbuf));
       memset(sensebuf, 0xec, sizeof(sensebuf));

       io_hdr.interface_id = 'S';

       io_hdr.cmdp = cdb;
       io_hdr.cmd_len = sizeof(cdb);

       io_hdr.sbp = sensebuf;
       io_hdr.mx_sb_len = sizeof(sensebuf);

       io_hdr.dxferp = outbuf;
       io_hdr.dxfer_len = sizeof(outbuf);
       io_hdr.dxfer_direction = SG_DXFER_TO_FROM_DEV;

       io_hdr.timeout = 20000;

       ret = ioctl(fd, SG_IO, &io_hdr);
       return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ