Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4645350ybl; Wed, 22 Jan 2020 01:58:13 -0800 (PST) X-Google-Smtp-Source: APXvYqyGAMfirkmAXYPaGZYv//7LIxiUdC00kvq8isgtEfsgJZrcB9juZR9vLjPSF37YPRj97cDc X-Received: by 2002:a9d:7f12:: with SMTP id j18mr7015705otq.17.1579687093601; Wed, 22 Jan 2020 01:58:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579687093; cv=none; d=google.com; s=arc-20160816; b=HyTX2ePsptqrZsWx3WOjGuWsiJL7ESk6YWNPZm0J3Z6eyX5gqLZ9T0h3BVAD0JyUY7 9Nw8vZEr7xOVX4D13wr5IfWcSSnsqEJJoDAUtfZrtRkZDJT4matrvob4bq61eu2keHbZ j+eiYtasWZzDz/xBg5GEeGKcwTQiEj+O3gOCerjceLAW0P2tRc5n+z1jAlOw2KCNxZBq wQkmqfrREbDG/DdreF9/pxkfoN3fIuGQfpZibFjyKHt3PaAjXa7GbBwWO1ZCoOb6L+ps ExECxGazGoC/Hl0p86daeoYSJE8CXqn//2MwnQ1B/HAGuqjtkyn3QYbzjvPRUDU7A2GL NWaQ== 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=NWpRK2F8ThvMqVgm+PU/kTQSoFLREGV3IeCn/Szgy28=; b=cBFRVFJv3g3y1FnKyBiKTb1AHcenDGTOXtzSg9zBJTvaII/J3xaevTDec07J5xJcT1 NWHuUm8aeM/8IPGQBHzT3MeA5IGMvOXJ1e/DteWNNFqHym/Q07p3WSAur9G59ndmFmTx Bt/eSD1LX8FhPQ8B08KKinOuRgB052dBz67xVTKUNhNfmRPbkVywhRgp7tUc7it6Qae9 B3KfRx/bmk0IK0ZfWu3n0x6uYwahhu48qD3V8S//hzzPm4KahxqVQxLPVKYZ/7Qa0HsX Q7AcCIc7nos92LqRlX+C+MTmozxOfPDCX+LuBDEi3bDV5yu+EylkmKFTQsKzLyigAf+M jX3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hNtLZ8AV; 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 l131si19378369oig.120.2020.01.22.01.58.01; Wed, 22 Jan 2020 01:58:13 -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=hNtLZ8AV; 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 S1729566AbgAVJbL (ORCPT + 99 others); Wed, 22 Jan 2020 04:31:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:42950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729527AbgAVJbH (ORCPT ); Wed, 22 Jan 2020 04:31:07 -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 ADA7E24673; Wed, 22 Jan 2020 09:31:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579685466; bh=6BnNUWJF6aYZydoM8RpxRCigJKk8/js3efYHnlbHI4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hNtLZ8AVc0XhFHMz2sk4SOHcmofHzPcMsf0JKZkFEaNppa45kkw1beErkem2GmM30 Y1JvbDgCK6iWENMVDjahPb1NoYRw+jeqv5OZe8HyKtPYhRxuxuRHO5W9sk0MXVvzBk 313gn1pl5YyBodd21czFKnxfUSfY4vPKxgpDndlc= 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.4 25/76] scsi: sd: Clear sdkp->protection_type if disk is reformatted without PI Date: Wed, 22 Jan 2020 10:28:41 +0100 Message-Id: <20200122092754.326792715@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092751.587775548@linuxfoundation.org> References: <20200122092751.587775548@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 @@ -1998,8 +1998,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 */