From patchwork Wed Jun 20 10:45:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10476903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 42C62604D3 for ; Wed, 20 Jun 2018 10:45:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34DE428DD5 for ; Wed, 20 Jun 2018 10:45:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2934228E19; Wed, 20 Jun 2018 10:45:18 +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 D213C28DD5 for ; Wed, 20 Jun 2018 10:45:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753893AbeFTKpQ (ORCPT ); Wed, 20 Jun 2018 06:45:16 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:33356 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753594AbeFTKpP (ORCPT ); Wed, 20 Jun 2018 06:45:15 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5KAiE0n193970; Wed, 20 Jun 2018 10:45:14 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-2017-10-26; bh=2UE0sm++QMr2OBfhDZBtThL9z4aqwL9WPbryWFBxYDU=; b=PbNSTWRi5iy/9w+Q03JLI4INGglTAABP5eNJchihzKNn/BtKiC5nPgIvfjS3fr6sxusG KDJNgs1jA+NWRBZ0hAOPkVPnsy2NRb+aOzxKp/OyGSPCiWuyYfiX+YwmwVPL8NZv6FMW dJ+2pyaNoi0LV8jneiESAoFrw64TRuKUSlG7uYkDEAlr+m/w/Ov5A/HwJCwBTNAC2HFc WNOhh3TSg6woSo+iP82d7WO2AJwi/tFEM3Od4CXWwsCvAu7VscH2UFy6HRaqgjMmSONK OTUAxii805gOXBtMjVfvYD/nR1H0NqRxdzY+dM+9KUadVND54SZs+Lk2csGFdVk9p2he 2A== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2jmtgwuw4n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Jun 2018 10:45:14 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w5KAjD3D027507 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Jun 2018 10:45:14 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w5KAjDAX014993; Wed, 20 Jun 2018 10:45:13 GMT Received: from kili.mountain (/197.157.34.185) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 20 Jun 2018 03:45:12 -0700 Date: Wed, 20 Jun 2018 13:45:05 +0300 From: Dan Carpenter To: Jens Axboe , Bart Van Assche Cc: linux-block@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] blk-mq-debugfs: Off by one in blk_mq_rq_state_name() Message-ID: <20180620104503.nrwlfak3gyxjg7s2@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=8929 signatures=668702 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=813 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806200123 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If rq_state == ARRAY_SIZE() then we read one element beyond the end of the blk_mq_rq_state_name_array[] array. Fixes: ec6dcf63c55c ("blk-mq-debugfs: Show more request state information") Signed-off-by: Dan Carpenter Reviewed-by: Bart Van Assche diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index ffa622366922..1c4532e92938 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -356,7 +356,7 @@ static const char *const blk_mq_rq_state_name_array[] = { static const char *blk_mq_rq_state_name(enum mq_rq_state rq_state) { - if (WARN_ON_ONCE((unsigned int)rq_state > + if (WARN_ON_ONCE((unsigned int)rq_state >= ARRAY_SIZE(blk_mq_rq_state_name_array))) return "(?)"; return blk_mq_rq_state_name_array[rq_state];