Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8454958ybl; Thu, 16 Jan 2020 17:11:43 -0800 (PST) X-Google-Smtp-Source: APXvYqwl0SBoO5LfMIfJ+JKWfEsPKqwscoY9rRz4HqO5ateFICcTWsp/x7T8nBSYu1p+mDRy3sm1 X-Received: by 2002:aca:388:: with SMTP id 130mr1547276oid.89.1579223503212; Thu, 16 Jan 2020 17:11:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579223503; cv=none; d=google.com; s=arc-20160816; b=aF29aXlmbwiLg+f6ftGFHzNg9m+PzZmasuAVypIpDAohWxWHSxoBIkTEWA8IwYajWg g0E73Km1s6nZ4hbwj5TLj9Gl1rStN0S6Wc+L2Czd/KEAHr2xn03Qoo2iGQawUFz7bVvv Xquaq3PS6l5zCKsFQlBymjOTlZJYe/SSATVAkBz1MGW31PLSnuwE6DDLBIKMBIXkTmrA 2mjMXks6PDhxMllcIlhpQzudMDd5AN7AyN5b47z9QDFP1oDgncfKopr/cap358X9lJ6h hT7yynIjT+NL9/sTLMAqT1JUbfSzkfl+NuFIc52bVgXb7F+a0ZCwKACOxSBt87rSRLdz X0Wg== 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=9K+hfBH3VqidWYlV0O1lrXb+OcG1szMP8LbqO9xPQb4=; b=Eo3Bntipf7Au3msctdDnotMz1gW6muHOwFhyzJbdsecmLryGvNVtgslv7JhQoOKy7z 8hqBR798ThWbjYhUIfgSFNCQai8wl8eF14DuMhQjfNUOQgtXUgIPXEDrpc79u8jWx/pq 9kAYyjBkUFgjor1LTp1Yy5AKMRQOlHCRl7ardt3mZnsYZgPEyF5gfL8qEuzXV8SuIZ0g KNIrYsZJZzXWkYcqg1gBmj1W+eCbjRVtERREZkxXr+ebref68UhHFyGNM83Oq/Gfhc7b ltgYy/BgUG+rSo+a02/SJAY0jFeb6iUhMp4PqtCvVAsRMEwi57sZ6FWje5WjiJytZW7n uYHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FnyU69FT; 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 l7si14817638oth.11.2020.01.16.17.11.31; Thu, 16 Jan 2020 17:11:43 -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=FnyU69FT; 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 S2390984AbgAPXXM (ORCPT + 99 others); Thu, 16 Jan 2020 18:23:12 -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 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 @@ -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 */