From patchwork Thu Oct 17 06:19:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Bin X-Patchwork-Id: 11194821 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8CA791575 for ; Thu, 17 Oct 2019 06:12:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7731920854 for ; Thu, 17 Oct 2019 06:12:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404729AbfJQGMj (ORCPT ); Thu, 17 Oct 2019 02:12:39 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4234 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2392543AbfJQGMi (ORCPT ); Thu, 17 Oct 2019 02:12:38 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id F27E2EBFAF4DE34A05CA; Thu, 17 Oct 2019 14:12:36 +0800 (CST) Received: from huawei.com (10.90.53.225) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Thu, 17 Oct 2019 14:12:27 +0800 From: zhengbin To: , , , CC: , Subject: [PATCH v4 1/2] sr: need to check whether sshdr is valid in sr_do_ioctl Date: Thu, 17 Oct 2019 14:19:36 +0800 Message-ID: <1571293177-117087-2-git-send-email-zhengbin13@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571293177-117087-1-git-send-email-zhengbin13@huawei.com> References: <1571293177-117087-1-git-send-email-zhengbin13@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Like other callers of scsi_execute(send_trespass_cmd, hp_sw_tur...), we need to check whether sshdr is valid. Signed-off-by: zhengbin --- drivers/scsi/sr_ioctl.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.7.4 diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index ffcf902..335cfdd 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c @@ -206,6 +206,11 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) /* Minimal error checking. Ignore cases we know about, and report the rest. */ if (driver_byte(result) != 0) { + if (!scsi_sense_valid(sshdr)) { + err = -EIO; + goto out; + } + switch (sshdr->sense_key) { case UNIT_ATTENTION: SDev->changed = 1;