Received: by 10.213.65.68 with SMTP id h4csp1724854imn; Mon, 19 Mar 2018 11:30:33 -0700 (PDT) X-Google-Smtp-Source: AG47ELtJD8sL/txI82Dh15IztKH1xat4pKUdhWLbg3+y6/JqcmTueuG90t2meF7W2HXgJmfc8Qtu X-Received: by 10.101.82.12 with SMTP id o12mr9790222pgp.126.1521484233178; Mon, 19 Mar 2018 11:30:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521484233; cv=none; d=google.com; s=arc-20160816; b=W+py2fn0iifyWrCQWOJiI6GgQjeUUREtTG/ba2YiNSn87Fdp26WHwclYpL5pruMlgs NgAo2D5l9Rek0ppRoYtOuEw59Nfyq/aL+sDDzpx773uaPSQMxypBogaQjZaUiuIHkL9n mMzoLd+Q/w7PTykaXYwDD6sMHQgJV8qaSmmydl1RalUxtR/KdQ7i2fMWCbnO8r1YF8JF 1THcZfDrt6F48qHHyMxWB9M9LTfF2yI0tCJWXgRKMQzsBTm57A1oVZb13hKW1mCX544g XUD6AZNanPmfc5LnmjpJRKBEg+8q2FTIQ1apYP0MYU7JDZ2UkzenXkw20NfoLwxA2ZgO hQuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=QrzEXNaQtossO61sGsX94C5kRi1LUR8iq4zbynGCKXg=; b=P/8RB4rxPFbGkiRtSh2OvENVy3Sg4Xcy3hYgM9ON/ILKNOFBpCNHp9FLF8ca/4MfeO KNs0kt9BANyTqYRx1mEbaP4GrancJPALyEEdlQnuGYTF3A60eoGvfKQ7+uEMhkCtd92k i+l9W/IEx+prWC/GbRAI2gj2/77XxW1QrXj/EsX/NX76qLmM8Qz6GptnfnBM4aa/WSdj W+J8mXt+ZOPoSDm3f50mF/Nvq4wcNs/nqeWtdEt7NytDnc6pmS6dV5SzHaltxK17Z3ZS 3DJDhKOGwgkokBuhoQRuCOPNW2Me45fO0DwJTZpBzVozw8Bg0jFHPRN2mkKqfKq9nvnd TRMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i33-v6si429804pld.627.2018.03.19.11.30.19; Mon, 19 Mar 2018 11:30:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S970137AbeCSS22 (ORCPT + 99 others); Mon, 19 Mar 2018 14:28:28 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51590 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970121AbeCSS2W (ORCPT ); Mon, 19 Mar 2018 14:28:22 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5370F12B1; Mon, 19 Mar 2018 18:28:21 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , Chris Clayton , Douglas Gilbert , Hannes Reinecke , "Martin K. Petersen" , Cristian Crinteanu Subject: [PATCH 4.9 233/241] scsi: sg: fix SG_DXFER_FROM_DEV transfers Date: Mon, 19 Mar 2018 19:08:18 +0100 Message-Id: <20180319180800.827102310@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johannes Thumshirn commit 68c59fcea1f2c6a54c62aa896cc623c1b5bc9b47 upstream. SG_DXFER_FROM_DEV transfers do not necessarily have a dxferp as we set it to NULL for the old sg_io read/write interface, but must have a length bigger than 0. This fixes a regression introduced by commit 28676d869bbb ("scsi: sg: check for valid direction before starting the request") Signed-off-by: Johannes Thumshirn Fixes: 28676d869bbb ("scsi: sg: check for valid direction before starting the request") Reported-by: Chris Clayton Tested-by: Chris Clayton Cc: Douglas Gilbert Reviewed-by: Hannes Reinecke Tested-by: Chris Clayton Acked-by: Douglas Gilbert Signed-off-by: Martin K. Petersen Cc: Cristian Crinteanu Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/sg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -758,8 +758,11 @@ static bool sg_is_valid_dxfer(sg_io_hdr_ if (hp->dxferp || hp->dxfer_len > 0) return false; return true; - case SG_DXFER_TO_DEV: case SG_DXFER_FROM_DEV: + if (hp->dxfer_len < 0) + return false; + return true; + case SG_DXFER_TO_DEV: case SG_DXFER_TO_FROM_DEV: if (!hp->dxferp || hp->dxfer_len == 0) return false;