... just use copy_from_user().  We copy only SZ_SG_IO_HDR bytes, so that
would, strictly speaking, loosen the check.  However, for call chains via
->write() the caller has actually checked the entire range and SG_IO passes
exactly SZ_SG_IO_HDR for count.  So no visible behaviour changes happen if
we check only what we really need for copyin.
Link: https://lore.kernel.org/r/20191017193925.25539-5-viro@ZenIV.linux.org.uk
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
 
        if (count < SZ_SG_IO_HDR)
                return -EINVAL;
-       if (!access_ok(buf, count))
-               return -EFAULT; /* protects following copy_from_user()s + get_user()s */
 
        sfp->cmd_q = 1; /* when sg_io_hdr seen, set command queuing on */
        if (!(srp = sg_add_request(sfp))) {
        }
        srp->sg_io_owned = sg_io_owned;
        hp = &srp->header;
-       if (__copy_from_user(hp, buf, SZ_SG_IO_HDR)) {
+       if (copy_from_user(hp, buf, SZ_SG_IO_HDR)) {
                sg_remove_request(sfp, srp);
                return -EFAULT;
        }