From patchwork Thu Jan 16 23:16:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 233827 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15EEEC33CAF for ; Thu, 16 Jan 2020 23:23:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D68CF206D9 for ; Thu, 16 Jan 2020 23:23:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579216991; bh=9yg2XFAEugW75gx4rtI3GuDpK2t+9yooFbQKApOyZy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=2wCA3hAd3NDNf7AOA4GJ0yh5FuRY1ex1BWL911Vnwgyk5uhbYh8dJpuHLunZnViw8 nS9nYRPQRkUKoFzlHbfuyQoyAdLHmo2dOCTuIK8pEJJtxEi8SO1qiPwBnqPIGKU1GG DU5KTyGB779tTHRm+Pgb6T0zD2+Jce8UjYGdb3ko= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731586AbgAPXXK (ORCPT ); Thu, 16 Jan 2020 18:23:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:51244 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733288AbgAPXXJ (ORCPT ); Thu, 16 Jan 2020 18:23:09 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4E94A206D9; Thu, 16 Jan 2020 23:23:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579216988; bh=9yg2XFAEugW75gx4rtI3GuDpK2t+9yooFbQKApOyZy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FnyU69FTWagzpcS+cdD3EAquad9YAFBvH3ZzXTK/4TiEEbD3GaQ+qda/u6LE5lpdt ZjEPYsSego4LsAA0IydezaWnvCXUYOorDsDQfV4XlHTis8PHCcM3N5IOcwFotMyTfX eZ2dZiAY1QPvJIZDO9rO7nZOmg6NdFghmpHB/RiQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiang Chen , "Martin K. Petersen" Subject: [PATCH 5.4 086/203] scsi: sd: Clear sdkp->protection_type if disk is reformatted without PI Date: Fri, 17 Jan 2020 00:16:43 +0100 Message-Id: <20200116231753.019415714@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200116231745.218684830@linuxfoundation.org> References: <20200116231745.218684830@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Xiang Chen commit 465f4edaecc6c37f81349233e84d46246bcac11a upstream. If an attached disk with protection information enabled is reformatted to Type 0 the revalidation code does not clear the original protection type and subsequent accesses will keep setting RDPROTECT/WRPROTECT. Set the protection type to 0 if the disk reports PROT_EN=0 in READ CAPACITY(16). [mkp: commit desc] Fixes: fe542396da73 ("[SCSI] sd: Ensure we correctly disable devices with unknown protection type") Link: https://lore.kernel.org/r/1578532344-101668-1-git-send-email-chenxiang66@hisilicon.com Signed-off-by: Xiang Chen Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/sd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2192,8 +2192,10 @@ static int sd_read_protection_type(struc u8 type; int ret = 0; - if (scsi_device_protection(sdp) == 0 || (buffer[12] & 1) == 0) + if (scsi_device_protection(sdp) == 0 || (buffer[12] & 1) == 0) { + sdkp->protection_type = 0; return ret; + } type = ((buffer[12] >> 1) & 7) + 1; /* P_TYPE 0 = Type 1 */