Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2047404imm; Mon, 16 Jul 2018 00:52:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdLj74RxAmf4umjn92+NtDqu3kmYKNUqnZF1WnvWeBSVxitRxzuNHAZU1g9cUv05nMYcqyR X-Received: by 2002:a63:115e:: with SMTP id 30-v6mr14712518pgr.53.1531727551140; Mon, 16 Jul 2018 00:52:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531727551; cv=none; d=google.com; s=arc-20160816; b=PXYggjVwLTPDFaUO/UOVKydnz3ZsG2346apuvoJnhmtDf2PDZLGw78lrDFm0TM3MWL JRaWBza0HruHWNYOPpOLNX2iCjmzhWRj5vSmNbaLg5K/tChRoPGPgZejDO+8LXwysfqP ufW9rlq6QoA6+On2LB7ovjX3OfnLFOu6D826UPShbFw9PooH5hj58k+gQ63awbPL7i5q oBBkKjCMAhB/Lk0S1PqdrnFD0UjlcTCN/92V7gqr8pEuDBVCQvA64Kf0jINHlxI76Jh7 u+U8b6pREWMAHo1dAk9LqGSASGWm3EKCwQPA5Nwd9l/kEVh1ekirrZqZRozroe8okQ6i aEDg== 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=QwN11gwESvAdzjaYCv+qqvztG8+TvssLoebJfG5EYsI=; b=dergQZh62twc4cvgSrGfsPAdWRAUt5TcuAC2WZ1VAFU4p0fsERuBrFE66Y3rrkOjR3 jOD3zC/i0xnAtidyzgvgoauwfSR6oorscoj82gGmpXKf6mC9dFI0A0BiTum9yzJi8Xcm 9X3ZzTRzjT9I1ALnH0DNiZvrwuxbuRJ3ssMP7yd2ovMmxVyYWyY68LFuYklhR8pFmLw2 EwB8L7Wxw9kP7goqtBBFCFgm2rt3rBSlESp4NOwhnr6rcamo6XIo8IqpkmE8uMwEqd7h tFIPT3+7B5bqokJCvxDIc+EakqWrd1oKSPH9o/8odiSIoAset3t4Vag4a1ZOj2VPetEE WnUg== 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 k15-v6si9469093pls.463.2018.07.16.00.52.16; Mon, 16 Jul 2018 00:52:31 -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 S2388839AbeGPIIq (ORCPT + 99 others); Mon, 16 Jul 2018 04:08:46 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47840 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730161AbeGPIIp (ORCPT ); Mon, 16 Jul 2018 04:08:45 -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 B86DAC03; Mon, 16 Jul 2018 07:42:42 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Butterfield , Damien Le Moal , Tejun Heo Subject: [PATCH 4.9 07/32] ata: Fix ZBC_OUT command block check Date: Mon, 16 Jul 2018 09:36:15 +0200 Message-Id: <20180716073505.333504299@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180716073504.433996952@linuxfoundation.org> References: <20180716073504.433996952@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: Damien Le Moal commit b320a0a9f23c98f21631eb27bcbbca91c79b1c6e upstream. The block (LBA) specified must not exceed the last addressable LBA, which is dev->nr_sectors - 1. So fix the correct check is "if (block >= dev->n_sectors)" and not "if (block > dev->n_sectords)". Additionally, the asc/ascq to return for an LBA that is not a zone start LBA should be ILLEGAL REQUEST, regardless if the bad LBA is out of range. Reported-by: David Butterfield Signed-off-by: Damien Le Moal Cc: stable@vger.kernel.org Signed-off-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman --- drivers/ata/libata-scsi.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -3772,8 +3772,13 @@ static unsigned int ata_scsi_zbc_out_xla */ goto invalid_param_len; } - if (block > dev->n_sectors) - goto out_of_range; + if (block >= dev->n_sectors) { + /* + * Block must be a valid zone ID (a zone start LBA). + */ + fp = 2; + goto invalid_fld; + } all = cdb[14] & 0x1; @@ -3804,10 +3809,6 @@ static unsigned int ata_scsi_zbc_out_xla invalid_fld: ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff); return 1; - out_of_range: - /* "Logical Block Address out of range" */ - ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x21, 0x00); - return 1; invalid_param_len: /* "Parameter list length error" */ ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0);