From patchwork Tue Jul 11 21:46:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 701781 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8772CEB64DC for ; Tue, 11 Jul 2023 21:47:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231582AbjGKVro (ORCPT ); Tue, 11 Jul 2023 17:47:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231696AbjGKVr2 (ORCPT ); Tue, 11 Jul 2023 17:47:28 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96EE41718 for ; Tue, 11 Jul 2023 14:47:27 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BID3wW015528; Tue, 11 Jul 2023 21:47:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=1wTSjMfIy8QXCpDXFE2/96aYobB9wTXcbqpkkz2w1BM=; b=aBofaUXc+RaQqVR8mX+AXYV2QXLNLoB+H5NfKgf24PylqRb0q/IVJ6xZt+2wby+TPADo wrMVcZg/sfsZ8OqMsQms0wHFI2MHwWIutwqPz5SanG7+kaBMMPeAdqo0dkCCNXSOJWlF cX4NXPvf7zkIAGAxGWVf6HhjZtf1sxe+lcdQ8sQylGcrqS285mHgrWhwtWTF7S4NCy3p AltiH2WZnEyyEY4+JbOI9ztmzS7ftOWvNTVo71Tw8GVUgj2nmW58ZGX1PzhqRNG9wCjg cbpdDmrx9VSu9E+SFzzWtJrNl2/kMAKvmowkFEGAxCWgm5851SSVaVry0F0hWdSDAKfk +A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rr8xumf27-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 21:47:13 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36BLQOu4007166; Tue, 11 Jul 2023 21:47:13 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rpx85h1jw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 21:47:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OzT8aaJUHqROrP5HRyxRi9HWSc7oQ+XZEzMgTWbgHJrk0OJk7PX/oJAGYq2psWkXQj++i3w+WnTupEXoTklb8WZuUnxH9kV5ezHkDC+CgAwhHJV0yqpe3gQClaFfsqAri5rB/sujvpr19Rbj17SDznyrPEpjZD8v8Pean2KP54tVhgo6qYWgGHzLF7ZOvgWAGGFh6+JilXHI3fIkSTr/M02PWHZdOT4rg9h5u4MX5vey2IwqTfo28X/+2Fer5M9Mcf4nmUA2QDU9zfcqo1jcTmzoxkGCWbRHjxMlUwZkLAJPWJpaca03K0UUOZWXNcFt1Qymb5z2637MulKY7X9pyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1wTSjMfIy8QXCpDXFE2/96aYobB9wTXcbqpkkz2w1BM=; b=dGeEoYiVMUxDuv3ZVDLArQAJC7C/gCaGv5dqIBqlwkRnzDLGH7XKknbbe/bCTl9Ljo2MRTGz27JCiyu8aO9QpX1ZH056a3WpWhHdINGWc0mr6hv9iNbIZOwWsnqqd5eWvleEMYOzOMtumeUzIWcjMbR+/ErYm+5mAM+TunM5oojQaxIsw0saWNbt9thhcqQSHAFbvYnNl3lSnVByBDux/LNM7ra1+50GOfiRsuC40o6LfxNYYEI+BzM8RWXsTbosSCvM8fE5t4/5a6NDgBunft3HplxqW9lCOiDL4KMk8lXovplRY+10EX8NdA91Qgu5ehRvc25v2Yc3//cZXUFwCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1wTSjMfIy8QXCpDXFE2/96aYobB9wTXcbqpkkz2w1BM=; b=JPa4qxayEoLDthq8dcvsd3s+fjLPwfAR7YSagOJ0yXWmgz1hqs/BB0V1iR8P8T1SrMEejl1jtazOm2iWABWEpYqv4Uy8NuIUgkpVi00Mrv8kGFQ4UkjsZlETvrVuFVIoI8A4foA+PL59a1pTMuKeM0WIMS9RKv8k3OyrZBWRLCw= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH3PR10MB7436.namprd10.prod.outlook.com (2603:10b6:610:158::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.32; Tue, 11 Jul 2023 21:47:10 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::f5ac:d576:d989:34fa%4]) with mapi id 15.20.6565.028; Tue, 11 Jul 2023 21:47:10 +0000 From: Mike Christie To: john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v9 22/33] scsi: sd: Fix scsi_mode_sense caller's sshdr use Date: Tue, 11 Jul 2023 16:46:09 -0500 Message-Id: <20230711214620.87232-23-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230711214620.87232-1-michael.christie@oracle.com> References: <20230711214620.87232-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR02CA0087.namprd02.prod.outlook.com (2603:10b6:5:1f4::28) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH3PR10MB7436:EE_ X-MS-Office365-Filtering-Correlation-Id: 398c2840-f50d-4b89-c6a0-08db82586061 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k9D515+OBOuTw/1YXwE34E+Bw7G6itmsSYWpSKPOyV3nbgQLMn2Dsamj6ghjwwderCd78a568mKh8GOwiMHDWq/QnGUpDLXU8EW3KSeiyxkI5fBQ24lrnVNCMbRXqyitKHO0/Yju01yQ93+ejxrTwx4ZT/Ydt3BSrIrK/SHJGFKZdKW43r9Cqxy79RXJhu7OhpDDivMxy4BXPq1xr/C1/uHse4eI0hK/4RBANmwfzULWj+GnnAmuM/0fYQFVQBQnjiYVgiVUYBUjeBWaI25bU0wVPHJhHiq/JhvAWjKga/EvihsHlqdLpZK2dNG9obEwU6OPxDoM+raqTTODTjVEFH88fi2VpPOFxhTUNsTcsfA1ioaTXf4aQpHG3tVBjeNfmAzrVq8C2c+oikKfWlQgosOHLZiOC0vBrUhIivNIVWkpvsQY8tdoXOTh1qNcF+2WDn3miOI+cM9GX5S9WjdNZ5bp2614uwystfiY/9jEtEv7IaPNV2dH/7Z3gjGB0kul5vXg/QylNrZEXjv9Z/HWNjsJqc6Gkg15176Ge0mnsAW9ZGWGwTcJPJPN/MZVTQTv X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CY8PR10MB7243.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(39860400002)(396003)(376002)(366004)(136003)(346002)(451199021)(83380400001)(41300700001)(2616005)(8936002)(107886003)(4326008)(5660300002)(66476007)(66556008)(8676002)(316002)(1076003)(6506007)(38100700002)(26005)(6512007)(478600001)(6486002)(66946007)(86362001)(186003)(36756003)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4zY/K4GEmDt1NXA+yL233bAMvAJsnPBbOvtY2k06i7R79hjcTQ5DSKxFEWbIO8tgpNmaGhrDg6AnTyEfWIX1OWJbxx0ef0Vioh955FnU6OdNZyA6wNWNkJqzjX8xcgIIk6/kA2QIvpA2GRqkZ68dsYX/G98+au2S9eX0e3hZVDxEf/R84t9oHhJmtwDbQrf+snbzam/NU0UyW6+TjgmwzyYhDe7SeWM0gYQ/cuhIP09tuJmuhC9cOaxTbnhFwE7/qFzYj47TWHkffy3BbOrBtFwduKUGgkoqFbMQFChjIGVVDxDU73nEbbJmxSeEnzz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JUXqEQKXFe9ZhvzwVvZLbot/FOcNTaLgBug53hAAQcV8iycMJy1VoOiJ+GwOCQMARsb/1P0zi9v4dbXyQwYPRrCZPNSF0hC9d0KQ+3m0C7dPNSEmmiAssROY7BMlFT3DF3 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 398c2840-f50d-4b89-c6a0-08db82586061 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2023 21:47:10.0729 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: usJw6cBV6+X1Q2CkCIFKgPDleWfKgR+vGv0iByFQpOy95S6xQAqMMVbWR0gyhM29JgMHyWrjno2Zo4YeEYMyrY3Fxy/1K2N01tNC6JTtAIQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7436 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_12,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 phishscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110198 X-Proofpoint-GUID: j0Fm_F_Ko7QPMpyZmk5kut_54FNU5rlI X-Proofpoint-ORIG-GUID: j0Fm_F_Ko7QPMpyZmk5kut_54FNU5rlI Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The sshdr passed into scsi_execute_cmd is only initialized if scsi_execute_cmd returns >= 0, and scsi_mode_sense will convert all non good statuses like check conditions to -EIO. This has scsi_mode_sense callers that were possibly accessing an uninitialized sshdrs to only access it if we got -EIO. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/scsi/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index ab0d6b1835be..48b727b2bf1d 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2967,7 +2967,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) } bad_sense: - if (scsi_sense_valid(&sshdr) && + if (res == -EIO && scsi_sense_valid(&sshdr) && sshdr.sense_key == ILLEGAL_REQUEST && sshdr.asc == 0x24 && sshdr.ascq == 0x0) /* Invalid field in CDB */ @@ -3015,7 +3015,7 @@ static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer) sd_first_printk(KERN_WARNING, sdkp, "getting Control mode page failed, assume no ATO\n"); - if (scsi_sense_valid(&sshdr)) + if (res == -EIO && scsi_sense_valid(&sshdr)) sd_print_sense_hdr(sdkp, &sshdr); return;