Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8555391ybl; Thu, 16 Jan 2020 19:29:33 -0800 (PST) X-Google-Smtp-Source: APXvYqyG2MPlOZx0SDI0Vx7Onr4NB6MG9oB59XSVHpQ+CMeWrT72m2DWsme7G+gcijVyrC90cc+t X-Received: by 2002:a9d:6c52:: with SMTP id g18mr4742961otq.356.1579231773632; Thu, 16 Jan 2020 19:29:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579231773; cv=none; d=google.com; s=arc-20160816; b=jhz7hvIbKRGiIxF7LyniDWVwH6C/02YCEn/NZexbAsEAD7BYsMomt7Rtj09Ygah4XH IMEAwInIIlS3nDt4qk8f9SgReLutDbvHyw7JdOjWHI+9xUGm6vMKNVN7zE6N8eM1PHbi a6MdugIthqsyt0T+54amCxghP3rpK2XoMFqA8g45/HjRb4J2g2clyn1QBIs3hmF7UYYZ hLkEEWpOn2+iCE265hZLhiGRqTE2QBVSU3Aw1akQExDaA9gwD8LqaKjKafN5xgDhPlIo 5XC4sd0v/elin/eaixIYdvzo2FQGeRRifazOpaWd8pfVzIDeni0ptCw7F+ewMVzqSJoM bcCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KNry475OW6nuOycAcfj/R1eodCm/kaAjMlCa0ajjm3Q=; b=WyhrrLaBzzhSsOaV3wp8rGn/Sm1uuewVlluhDBpKhjbdT1NTxHVLG5+8IfIKV30OIM rONGKMP1TMx/BJKWDiCEGYud+gZJfyAZhcELuHFl09q5bSV2zeXYDC4vytgO4i/3GQPR gAbPaQMpbtpji/wDNqx+9K0SDkwulgu4TrvbqD11uJaooPwCETML5rK8ZVjpfQ2Lljg4 IBv307hq2UrPSv2dTuYhLLv7iPBkMI0sb2hPrVyzi5c85RYBXOHgr2vTUY2a7p6FhyLm Pc/dfVsP6V0sivjDhoOoyUNGlQAe/NRQqMyHjTpq4j5sxRJ6dFdCI1n1ahRLU+HIm0Gn LTqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fGgcvkZW; 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 s68si13659773oih.275.2020.01.16.19.29.22; Thu, 16 Jan 2020 19:29:33 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=fGgcvkZW; 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 S2391175AbgAPXjA (ORCPT + 99 others); Thu, 16 Jan 2020 18:39:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:33840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389996AbgAPX2s (ORCPT ); Thu, 16 Jan 2020 18:28:48 -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 61AFB20684; Thu, 16 Jan 2020 23:28:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579217327; bh=/1DJZ2OngrzS6T7AFTOajJaQs7/0OIr2Fjk95k3tHQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fGgcvkZWed9nKFFYp1STElQrFclO+9tSBZxBpT1HlZ8XXLyKM17OnL5haTb0DSqPl FeitLI8rj3D/io0YycoTFTHUm9ZYC1dHMD4+dIssnmPUD8sjK5cIGLWXcTaDGVfxlg /wMBN6vjVW+GgL2qmfOvgiZiNoPWeJvigqv1OqUM= 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 4.19 38/84] scsi: sd: Clear sdkp->protection_type if disk is reformatted without PI Date: Fri, 17 Jan 2020 00:18:12 +0100 Message-Id: <20200116231718.252209088@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200116231713.087649517@linuxfoundation.org> References: <20200116231713.087649517@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 @@ -2195,8 +2195,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 */