Received: by 10.213.65.68 with SMTP id h4csp39469imn; Mon, 19 Mar 2018 18:50:27 -0700 (PDT) X-Google-Smtp-Source: AG47ELutTcQvfP75PhZe+EsztxOf5E6VQJfBKxbIkESvB6XHILOp5VSZgTwE48I5hqTxY7AY3TeV X-Received: by 10.99.94.197 with SMTP id s188mr10508442pgb.363.1521510626960; Mon, 19 Mar 2018 18:50:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521510626; cv=none; d=google.com; s=arc-20160816; b=V3JJKumMZyOPcvWOczKcSXbJbqlWWCFt9ORVQ9wm75lEf1K7mnWKLQ3dVFb0LOVBPj L6YuM+aKc2BGenmGOXQpXH/SGKPeK55Gv6kUY4jm2TGULRUq3WqbaCE5HUYkgtWgYTnr /YasMQ+e4hibpdyMoE5ndu03r+h/ycpQKvFmnWUXoYoiiUqQojz76soG74LzK8KUkA+U Y/jT9Jeoq195IKB14k5FZcBVG8Rz1coZ/EfZxhMRk5Ubb6R2eDtzKoBlBKI3JHLJ1r92 wv5RFM6OVBL+fjFHOlxDsVKf0ot0ZZPNkT/RsUU4ZJKPQT3Xgd3Sk+KK4pMyI5qgorxN i2RA== 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=Npt6m+JKsF0LUAPB3UFb3oMUZp+PP6+1XBnjHrDIDNE=; b=XBDBDe0BsCVRTBpoXRPbOQfSZS6pb8qf9pOhcOlz3WM37LEoS71k9lnVaNiku4ajJh fvQjbqiw1e6LhXPOqOyNFg2M93fOL1tfNvdN067vxqplgOXV7Pm33JjL6/Pc6UF+HqdS XezvUg2Md2Dz85FqG9YkhfnCwceckZadCW2wqDOjC9EP8OEH4EC98zaMohVCkueT3pF8 fZbrDyF3v9kt3u0J6PgOXwVAr4DxZSp+z4JJkx+l6Fm8Ia0Mu+lpddAClw6Bdx5XAPsd oWW97SUc28NPzbl935KjoyKrrRS940ZgjFXojV9UqtsIzXKXGjNvCJNKo6dxNDqMdrjR o8+A== 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 a6si426322pfi.123.2018.03.19.18.50.13; Mon, 19 Mar 2018 18:50:26 -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 S971072AbeCSUHn (ORCPT + 99 others); Mon, 19 Mar 2018 16:07:43 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45496 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S969097AbeCSSRV (ORCPT ); Mon, 19 Mar 2018 14:17:21 -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 343F2123F; Mon, 19 Mar 2018 18:17: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.4 126/134] scsi: sg: fix SG_DXFER_FROM_DEV transfers Date: Mon, 19 Mar 2018 19:06:49 +0100 Message-Id: <20180319171907.481030335@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319171849.024066323@linuxfoundation.org> References: <20180319171849.024066323@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.4-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 @@ -769,8 +769,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;