From patchwork Sat Sep 8 08:42:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10592915 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6034014DB for ; Sat, 8 Sep 2018 08:42:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3ADA72AABB for ; Sat, 8 Sep 2018 08:42:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CBC52AAD0; Sat, 8 Sep 2018 08:42:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0E982AABB for ; Sat, 8 Sep 2018 08:42:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726397AbeIHN1m (ORCPT ); Sat, 8 Sep 2018 09:27:42 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:44282 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726291AbeIHN1m (ORCPT ); Sat, 8 Sep 2018 09:27:42 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w888Y2q0075009; Sat, 8 Sep 2018 08:42:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2018-07-02; bh=+dVyvRJEeTmafQA0r3kBsoVYwNJc3bAAo52QEvCpJP0=; b=fUO8b1JonNkn+eRXsMge/3ta8S5gWMhSssUYW5cYvvsWqOR5htXTaY+oANsZSOomKHfO chM3iTUhAcz8jQbC5p7TYZK9ZirHSN847M37izDLmwcqpsk/xBcjQy8CsKYuzqlqKtzh Rra+QGPKSOQm9/50mAzNAG2xmmbkY37bfTqi9sKf9L6W4rfnDOJT/P1KiMeyvb+Lt7h2 q/IzPpcHVgcZWm92dUxQmQq2j/ttgb3nk0uO42YHYl7Z0nFZXpdjPKxvJ2UqcHMNkKAx qFWSLj3aTQDlQqm8VtoQHRYQdD8vE7EdOE28ocIZf5FcdltvZ3YafsugfMCDD3xMO1z0 Qg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2mc5ut0g03-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 08 Sep 2018 08:42:36 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w888gaBc001093 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 8 Sep 2018 08:42:36 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w888gYsw029589; Sat, 8 Sep 2018 08:42:35 GMT Received: from kili.mountain (/197.232.248.111) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 08 Sep 2018 08:42:34 +0000 Date: Sat, 8 Sep 2018 11:42:27 +0300 From: Dan Carpenter To: qla2xxx-upstream@qlogic.com, Quinn Tran Cc: "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, Himanshu Madhani , kernel-janitors@vger.kernel.org Subject: [PATCH] scsi: qla2xxx: Fix an endian bug in fcpcmd_is_corrupted() Message-ID: <20180908084227.xo4g5aekndokopus@kili.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170113 (1.7.2) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9009 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809080094 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We should first do the le16_to_cpu endian conversion and then apply the FCP_CMD_LENGTH_MASK mask. Fixes: 5f35509db179 ("qla2xxx: Terminate exchange if corrupted") Signed-off-by: Dan Carpenter Acked-By: Himanshu Madhani --- I just happened to spot this when I was reviewing something unrelated. I don't have the hardware to test it, so please review carefully. diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h index fecf96f0225c..199d3ba1916d 100644 --- a/drivers/scsi/qla2xxx/qla_target.h +++ b/drivers/scsi/qla2xxx/qla_target.h @@ -374,8 +374,8 @@ struct atio_from_isp { static inline int fcpcmd_is_corrupted(struct atio *atio) { if (atio->entry_type == ATIO_TYPE7 && - (le16_to_cpu(atio->attr_n_length & FCP_CMD_LENGTH_MASK) < - FCP_CMD_LENGTH_MIN)) + ((le16_to_cpu(atio->attr_n_length) & FCP_CMD_LENGTH_MASK) < + FCP_CMD_LENGTH_MIN)) return 1; else return 0;