Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2038566imm; Mon, 16 Jul 2018 00:39:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdLTg0JYun5kCbZiVKcQkjn+t1ab0IUr71Go3O1IJso8Us0aHaVSqQmdcqOvfB+EmZJZ1EB X-Received: by 2002:a17:902:22e:: with SMTP id 43-v6mr15950115plc.82.1531726749737; Mon, 16 Jul 2018 00:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531726749; cv=none; d=google.com; s=arc-20160816; b=Ap7IU26A+9Jz6krb6VURVP18C1H5lAsUHxSvgUogRNT3Jjkw/rfnCoiK12mokNJGQq h2kBfq7lmT1XheWVcOKF7nBN+SZupk0pXchU1ZQ6FazcpdeadatJSGWppV39ses0LoX5 sjFYBX44icD+kz9LbLieKydnDHmAnFXy/aqi+Db4Ty+o8dKKSolQcYH+e5R5YC0ezWVW fC67+GRjFBacej9gnTAquFEaRPzZGkVRQunltbvUCqzvls1+Iv3n2FdbV9Pb2D9UvN3d DFlFPgdFs8MuIH5r033n9TltPKVi1leqK3mSycj/cNkL8qT5rYLJrG73FDbyBtiGqfKz /mBg== 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=hNfuPH4G/Q23Tn8Z8PIGeYCySF4y2TU6f8ZVVH/+C+Y=; b=bsT5suVhrZ3Pn6E3aefEVdnuJHvlzRsSbnrUiuhau1pP09hK3CKIlK+BRAyjz7+EWf HEffEaWt76WWy383n8oZvIim+E7OVPR87IUsf1mc6yD+M5sakgkryaNhkrvID30pF6z+ M2gBAXq54BvCBYRLmSU8gGYFMXH+2lN23aBK6zOQPs91R/yqRYEYsnHxu8C42eHZnQJO 7yQapN9kiPd8qi4efsW4fFGSP5vKe42ICYnzSTf2iVcXP4UJDZO9dFxDiLUIRLfVWM0C OoyXcwXP/I+d6Y+xURZYlIUttIX4IfkWneE8g7TP89D/0YU7y+wjJs1VYCNQjwv00nki IuSg== 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 o4-v6si32956178pfh.168.2018.07.16.00.38.55; Mon, 16 Jul 2018 00:39:09 -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 S1731871AbeGPIDg (ORCPT + 99 others); Mon, 16 Jul 2018 04:03:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46734 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728460AbeGPIDg (ORCPT ); Mon, 16 Jul 2018 04:03:36 -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 D5E71CA0; Mon, 16 Jul 2018 07:37:34 +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.17 15/67] ata: Fix ZBC_OUT command block check Date: Mon, 16 Jul 2018 09:34:44 +0200 Message-Id: <20180716073445.457040404@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180716073443.294323458@linuxfoundation.org> References: <20180716073443.294323458@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.17-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 @@ -3802,8 +3802,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; @@ -3834,10 +3839,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);