Message ID | 20231128122958.2235-1-nj.shetty@samsung.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp87088vqn; Tue, 28 Nov 2023 19:03:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHvqLUUpmyuuhR+yD5S6ymZex1er/P8nZ9HKC72ZPVAmvpVVZXjoR35V6iBt0B1tBBnwHO X-Received: by 2002:a05:6830:b8e:b0:6d8:1239:3cb8 with SMTP id a14-20020a0568300b8e00b006d812393cb8mr13461421otv.30.1701227033565; Tue, 28 Nov 2023 19:03:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701227033; cv=none; d=google.com; s=arc-20160816; b=XUs4A/P6sgqomfBdLkL+u1/BiL9kvADp9Pk/YvhnAN+ssLeaHR9H/E2uFsDT30MDqB rGW2u0WpsNA7F1+fzG8gppKZgThJl+vT+vup4qDaHEQykTai7h6Jkz0zq7m0mQo059W/ GyXaJfHHoqnd65X3t9gRh+38lMIdvzolczcBUPFSd/di+4NPOkyJU276qaHh0dwrSYbt gpUe8wPdOzBDSJrfphSbPukxrxZJp9xlXzWjk0+fmjNjv3QDA7KbgihjBmvbwtl1VT03 UXueRjIEEKY2i+gMWVZUuxnMFUT7SRojlJo5ag7fRSB4XDYuoqPnFgkj3eCDUYjlYWuw 1hwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature:dkim-filter; bh=PDEk9kY3nrmL8GjXi/hdUYFbHIowAUw4NK0dmP325t4=; fh=eqB4vt6MWNHj4rshyZATJPfI6+c/hdITvrIvZ22YvBM=; b=DxksawvtA7JGQ+REIVqEa9Tdw8xXgImWWDs8E+fYF3sxR5ke3+iHWwgBc+2I7aoO1V 5vr+61Db+IMzjFFlYip+EBFl6XPfR/sLTraa53XfFzZM9eKTGq3csWNdcJSgWt5FAQnv 6o92e98+tx883+fJfhp2tTm4lMULxr8B7Y4qiybLDQ7YUmXD/mf14cF0URKVFj6Jhm7h 4wPBTXlhu2OqV8sXcIYLO1I+0ejLaIWQVG1clHvyEu/BUiXPbqfIt7pSmjdxbtYWVyRh ybFeLlfly+CIlGXtJ528+39kkcgB3hxXEDjyjC96slbRKL7KpDOTfefOtuUVCaGeSbQg rzKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=f4U9WICS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id e17-20020a656891000000b005bdbcf7c446si13980023pgt.171.2023.11.28.19.03.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 19:03:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=f4U9WICS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 9E9B780557E0; Tue, 28 Nov 2023 19:03:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376837AbjK2DDf (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Tue, 28 Nov 2023 22:03:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376791AbjK2DDe (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 28 Nov 2023 22:03:34 -0500 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03AEE19A4 for <linux-kernel@vger.kernel.org>; Tue, 28 Nov 2023 19:03:38 -0800 (PST) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20231129030335epoutp042dbf4665807f51eda3abe6dea2c9404d~b_PUVRqHN2826628266epoutp04F for <linux-kernel@vger.kernel.org>; Wed, 29 Nov 2023 03:03:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20231129030335epoutp042dbf4665807f51eda3abe6dea2c9404d~b_PUVRqHN2826628266epoutp04F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1701227015; bh=PDEk9kY3nrmL8GjXi/hdUYFbHIowAUw4NK0dmP325t4=; h=From:To:Cc:Subject:Date:References:From; b=f4U9WICSyY1uFy92+OLvw/SKGUyfAE1/+PpFTYGpB9cvyreE1r9/u53XqbC8l49Zy xg0rdigKUBi8yE86aTPRv3Du3M9nG9dQfp92e4NMAuMcsFa/i+wiwXX+eljS9ivuYX CYmkr7Kv8L+bwQ7tjKNRlwBXTIH7vs95lowDYUl8= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20231129030335epcas5p4a4d1fe85dbbe937c8f36546094ffba78~b_PTu1kpj0805908059epcas5p4Y; Wed, 29 Nov 2023 03:03:35 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.182]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4Sg4055tFTz4x9Pv; Wed, 29 Nov 2023 03:03:33 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 4E.C2.10009.50AA6656; Wed, 29 Nov 2023 12:03:33 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20231128123622epcas5p4940679fbbafdf0da802deea3e531f850~byaI4M4UY1906519065epcas5p4P; Tue, 28 Nov 2023 12:36:22 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20231128123622epsmtrp11d28128d4f35c3ff4c3aa4592c5ac963~byaI3cksl0249402494epsmtrp1t; Tue, 28 Nov 2023 12:36:22 +0000 (GMT) X-AuditID: b6c32a4a-ff1ff70000002719-c3-6566aa056cc9 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 30.E7.18939.6CED5656; Tue, 28 Nov 2023 21:36:22 +0900 (KST) Received: from green245.sa.corp.samsungelectronics.net (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20231128123621epsmtip1f39a9cdfbd0f70a2893b5e390ab4c438~byaHL45kA0175001750epsmtip1V; Tue, 28 Nov 2023 12:36:20 +0000 (GMT) From: Nitesh Shetty <nj.shetty@samsung.com> To: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>, James Smart <james.smart@broadcom.com>, Chaitanya Kulkarni <kch@nvidia.com> Cc: error27@gmail.com, gost.dev@samsung.com, nitheshshetty@gmail.com, Nitesh Shetty <nj.shetty@samsung.com>, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] nvme: Update type from size_t to u16 for opts->queue_size Date: Tue, 28 Nov 2023 17:59:56 +0530 Message-Id: <20231128122958.2235-1-nj.shetty@samsung.com> X-Mailer: git-send-email 2.35.1.500.gb896f729e2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMJsWRmVeSWpSXmKPExsWy7bCmui7rqrRUg+N/FC1W3+1ns3i0zM/i 5oGdTBYrVx9lsti98COTxaRD1xgtnl6dxWRxedccNov5y56yW+x40shose33fGaLda/fszjw eMy6f5bNY+esu+we5+9tZPG4fLbUY9OqTjaPzUvqPXbfbGDz6G1+x+bRt2UVo8fnTXIBXFHZ NhmpiSmpRQqpecn5KZl56bZK3sHxzvGmZgaGuoaWFuZKCnmJuam2Si4+AbpumTlAVysplCXm lAKFAhKLi5X07WyK8ktLUhUy8otLbJVSC1JyCkwK9IoTc4tL89L18lJLrAwNDIxMgQoTsjP6 unewFbRLVSw7sIi9gfGuaBcjJ4eEgInE1ekH2bsYuTiEBHYzSkw8/JUVwvnEKPHo3F8WOOf2 1V9MMC3fXqyASuxklFg76RIbhNPKJHGr8xBQFQcHm4C2xOn/HCBxEYErjBKzHz4FK2IWWMso ce31YXaQUcICARJnV3SxgjSwCKhKfFseBhLmFbCU2PRjNlhYQkBfov++IERYUOLkzCcsIDaz gLxE89bZzCAjJQSmckhMuryLEeI6F4nV25qgbGGJV8e3sEPYUhIv+9ug7HKJlVNWsEE0tzBK zLo+C6rBXqL1VD8zyGJmAU2J9bv0IcKyElNPrWOCWMwn0fv7CTQkeCV2zIOxlSXWrF/ABmFL Slz73ghle0jc/3oRrEZIIFZi1oafTBMY5Wch+WcWkn9mIWxewMi8ilEytaA4Nz212LTAKC+1 HB6zyfm5mxjBqVfLawfjwwcf9A4xMnEwHmKU4GBWEuHV+5icKsSbklhZlVqUH19UmpNafIjR FBjEE5mlRJPzgck/ryTe0MTSwMTMzMzE0tjMUEmc93Xr3BQhgfTEktTs1NSC1CKYPiYOTqkG JvkAp/I18x44JK7dW3n6vNNkQ9Z2VsGT4q8k9Q6mnPqVI2E8h092H+/q5BxTdumdh+SbOKeV /Nx1IrlRTdnh/7f1LJaTfCTn71tr8ovnVnG95OUvHSz/tzYpx7t686wsmv680Ssx/dW9yzP+ 7RTV+Pyo4rhuxa+lv/l3q228cfDNy7ssJ4pv6639cPEvF1/7hvs/H939mnroXtybm7Ovlh/X K857qDrJoW2u7oX67XGmTk87GjVj4x7xlC57uKj43uYl54wz//hN6DfoPXXjgYruzI6mIvOe t23iRy/yrG8/+0fymKPR4imXY11T0+dPKr8/gW+J2C1drVtZ9/c++7dx5bftNRttda7WvxDk 2DxFiaU4I9FQi7moOBEATPe1tEYEAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrBLMWRmVeSWpSXmKPExsWy7bCSnO6xe6mpBs+WaVusvtvPZvFomZ/F zQM7mSxWrj7KZLF74Ucmi0mHrjFaPL06i8ni8q45bBbzlz1lt9jxpJHRYtvv+cwW616/Z3Hg 8Zh1/yybx85Zd9k9zt/byOJx+Wypx6ZVnWwem5fUe+y+2cDm0dv8js2jb8sqRo/Pm+QCuKK4 bFJSczLLUov07RK4Mvq6d7AVtEtVLDuwiL2B8a5oFyMnh4SAicS3FytYuhi5OIQEtjNKrD77 lBkiISmx7O8RKFtYYuW/5+wgtpBAM5NE43T+LkYODjYBbYnT/zlAekUEbjFKPN++gBnEYRbY zCgx7ckmsAZhAT+JbQ8+MoI0sAioSnxbHgYS5hWwlNj0YzYrSFhCQF+i/74gRFhQ4uTMJywg NrOAvETz1tnMExj5ZiFJzUKSWsDItIpRNLWgODc9N7nAUK84Mbe4NC9dLzk/dxMjOPC1gnYw Llv/V+8QIxMH4yFGCQ5mJRFevY/JqUK8KYmVValF+fFFpTmpxYcYpTlYlMR5lXM6U4QE0hNL UrNTUwtSi2CyTBycUg1MxVV2llosDXZbLiiGH1JbFdrU7XeXQ2fv1on/zYx0/LIra1Rs4/ev /M2YP+cZd8ikINEVOVbN2znmy1atZzHNMTbZ5xHXW1VXtqy8XrGy5/uTesHzBfN2nX2cbsC8 b3PR+wOvClbrmDM4d062mPbesujz9imLrrg/fX3uzZm86pm2p7Rf/08JX3LFh3/9qTMPDTa2 iDO5zlb8O39j5M0pC97/fL39asbeepMmvuV+PxZuezijfxvft/y3PQ7OW37dv1Amk8P1R8h3 14Q/k1ew84UnVHUbdKoUvzLY+lRXPuvHhs83TplJf7A1y1FTc1rKfGgdQ115/epY37+/b882 ENv0cOIT+btnKvbJmbR9U2Ipzkg01GIuKk4EAN1hxXbrAgAA X-CMS-MailID: 20231128123622epcas5p4940679fbbafdf0da802deea3e531f850 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20231128123622epcas5p4940679fbbafdf0da802deea3e531f850 References: <CGME20231128123622epcas5p4940679fbbafdf0da802deea3e531f850@epcas5p4.samsung.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 28 Nov 2023 19:03:50 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783865837961901454 X-GMAIL-MSGID: 1783865837961901454 |
Series |
[1/2] nvme: Update type from size_t to u16 for opts->queue_size
|
|
Commit Message
Nitesh Shetty
Nov. 28, 2023, 12:29 p.m. UTC
This fixes the smatch warning, "nvme_loop_create_ctrl() warn:
'opts->queue_size - 1' 18446744073709551615 can't fit into 65535
'ctrl->ctrl.sqsize'"
We don't need size_t for queue_size, u16 should serve the purpose,
as max size is limited to NVMF_DEF_QUEUE_SIZE(1024).
Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com>
---
drivers/nvme/host/fabrics.h | 2 +-
drivers/nvme/host/fc.c | 2 +-
drivers/nvme/host/rdma.c | 2 +-
drivers/nvme/host/tcp.c | 2 +-
drivers/nvme/target/loop.c | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
base-commit: da59b416ba80e43afb2b642e0cee73739f4c6079
Comments
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
On Tue, Nov 28, 2023 at 05:59:56PM +0530, Nitesh Shetty wrote: > This fixes the smatch warning, "nvme_loop_create_ctrl() warn: > 'opts->queue_size - 1' 18446744073709551615 can't fit into 65535 > 'ctrl->ctrl.sqsize'" > We don't need size_t for queue_size, u16 should serve the purpose, > as max size is limited to NVMF_DEF_QUEUE_SIZE(1024). > > Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com> Huh... I'm sorry I wasn't necessarily aware that I had published this Smatch warning. I feel like it has a high rate of false positives. Generally with Smatch warnings, I'm not going to try silence every false positive. And I had one complaint recently that I was too focused on silencing false positives instead of discovering new bugs... The other thing about static analysis is that static checker developers want 0% false positives and kernel developers want 100% false positives. I'm a kernel developer so in code that I have looked at the rate of false positives is very close to 100%. Only new code has valid warnings. Here is what this code looks like: drivers/nvme/target/loop.c 573 if (opts->queue_size > ctrl->ctrl.maxcmd) { 574 /* warn if maxcmd is lower than queue_size */ 575 dev_warn(ctrl->ctrl.device, 576 "queue_size %zu > ctrl maxcmd %u, clamping down\n", 577 opts->queue_size, ctrl->ctrl.maxcmd); 578 opts->queue_size = ctrl->ctrl.maxcmd; 579 } 580 ctrl->ctrl.sqsize = opts->queue_size - 1; Smatch thinks that opts->queue_size is a value that comes from the user in the 16-47 range. But the bug is that Smatch thinks that ctrl->ctrl.maxcmd is zero. 16 is greater than zero so we do the opts->queue_size = ctrl->ctrl.maxcmd; assignment. Then zero minus one is ULONG_MAX so that's a very high number. Smatch is just wrong in this case. Let me try figure out what went wrong. The ctrl->ctrl.maxcmd = 0 comes from: ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); It's supposed to get set to unknown in nvme_loop_configure_admin_queue(). The database has the correct data. $ smdb.py return_states nvme_loop_configure_admin_queue | grep maxcmd drivers/nvme/target/loop.c | nvme_loop_configure_admin_queue | 229 | 0| PARAM_SET | 0 | $->ctrl.maxcmd | 0-u16max | drivers/nvme/target/loop.c | nvme_loop_configure_admin_queue | 231 | s32min-(-1),1-s32max| PARAM_ADD | 0 | $->ctrl.maxcmd | 0-u16max | But the issue is that Smatch thinks that nvme_loop_configure_admin_queue() always fails with -12. The reason for that is because Smatch thinks that ctrl->ctrl.ops is NULL but the function can only succeed when it's non-NULL. The ctrl->ops assignment happens in nvme_init_ctrl() and it should have been easy to track. I am not sure what went wrong there. I'll take a look at that and fix it. regards, dan carpenter
On 29/11/23 12:26PM, Dan Carpenter wrote: >On Tue, Nov 28, 2023 at 05:59:56PM +0530, Nitesh Shetty wrote: >> This fixes the smatch warning, "nvme_loop_create_ctrl() warn: >> 'opts->queue_size - 1' 18446744073709551615 can't fit into 65535 >> 'ctrl->ctrl.sqsize'" >> We don't need size_t for queue_size, u16 should serve the purpose, >> as max size is limited to NVMF_DEF_QUEUE_SIZE(1024). >> >> Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com> > >Huh... I'm sorry I wasn't necessarily aware that I had published this >Smatch warning. I feel like it has a high rate of false positives. > >Generally with Smatch warnings, I'm not going to try silence every >false positive. And I had one complaint recently that I was too focused >on silencing false positives instead of discovering new bugs... > >The other thing about static analysis is that static checker developers >want 0% false positives and kernel developers want 100% false positives. >I'm a kernel developer so in code that I have looked at the rate of >false positives is very close to 100%. Only new code has valid >warnings. > >Here is what this code looks like: > >drivers/nvme/target/loop.c > 573 if (opts->queue_size > ctrl->ctrl.maxcmd) { > 574 /* warn if maxcmd is lower than queue_size */ > 575 dev_warn(ctrl->ctrl.device, > 576 "queue_size %zu > ctrl maxcmd %u, clamping down\n", > 577 opts->queue_size, ctrl->ctrl.maxcmd); > 578 opts->queue_size = ctrl->ctrl.maxcmd; > 579 } > 580 ctrl->ctrl.sqsize = opts->queue_size - 1; > >Smatch thinks that opts->queue_size is a value that comes from the user >in the 16-47 range. But the bug is that Smatch thinks that >ctrl->ctrl.maxcmd is zero. 16 is greater than zero so we do the >opts->queue_size = ctrl->ctrl.maxcmd; assignment. Then zero minus one >is ULONG_MAX so that's a very high number. > >Smatch is just wrong in this case. Let me try figure out what went >wrong. The ctrl->ctrl.maxcmd = 0 comes from: > > ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); > >It's supposed to get set to unknown in nvme_loop_configure_admin_queue(). >The database has the correct data. > >$ smdb.py return_states nvme_loop_configure_admin_queue | grep maxcmd >drivers/nvme/target/loop.c | nvme_loop_configure_admin_queue | 229 | 0| PARAM_SET | 0 | $->ctrl.maxcmd | 0-u16max | >drivers/nvme/target/loop.c | nvme_loop_configure_admin_queue | 231 | s32min-(-1),1-s32max| PARAM_ADD | 0 | $->ctrl.maxcmd | 0-u16max | > >But the issue is that Smatch thinks that nvme_loop_configure_admin_queue() >always fails with -12. The reason for that is because Smatch thinks >that ctrl->ctrl.ops is NULL but the function can only succeed when it's >non-NULL. > >The ctrl->ops assignment happens in nvme_init_ctrl() and it should have >been easy to track. I am not sure what went wrong there. I'll take a >look at that and fix it. Thank you for this insight. I ran smatch on complete kernel using smatch's test_kernel.sh I was unaware of this smbd.py option. I will explore this. Meanwhile I feel this patch is still relevant, as it aligns opts queue_size with size of ctrl queue_size. Regards, Nitesh Shetty
On Wed, Nov 29, 2023 at 12:26:24PM +0300, Dan Carpenter wrote: > The ctrl->ops assignment happens in nvme_init_ctrl() and it should have > been easy to track. I am not sure what went wrong there. I'll take a > look at that and fix it. I suspect on your system you don't have the cross function DB built so it's not aware what happens in nvme_init_ctrl() or the other function I mentioned. On my system there is too much data so it isn't parsed. 1) When there is too much data it should just mark ctrl->ops as unknown 2) I should try to consolidate the data. I should just mark all of ctrl->ctrl_device as unknown instead of recording any of the struct members individually. There might also be stuff that isn't used like ctrl->namespaces_rwsem internals. 3) On my system, I have 2187 bogus entries that say we removed an item from a list. Probably any of these fixes would silence the false positive but it would be better to do all three. If you don't have the cross function database though, you're probably out of luck. There are always going to be more false positives if you don't have the cross function information. regards, dan carpenter
On Wed, Nov 29, 2023 at 04:18:37PM +0530, Nitesh Shetty wrote: > Thank you for this insight. > I ran smatch on complete kernel using smatch's test_kernel.sh > I was unaware of this smbd.py option. I will explore this. The ./smatch_scripts/build_kernel_data.sh command creates the cross function db. It takes a while though. And it's probably better to run it a few times because every time you run it the call tree chains get one call longer. I run it every night against the latest linux-next. > Meanwhile I feel this patch is still relevant, as it aligns opts > queue_size with size of ctrl queue_size. I don't have an opinion on this. regards, dan carpenter
On 30/11/23 10:07AM, Dan Carpenter wrote: >On Wed, Nov 29, 2023 at 04:18:37PM +0530, Nitesh Shetty wrote: >> Thank you for this insight. >> I ran smatch on complete kernel using smatch's test_kernel.sh >> I was unaware of this smbd.py option. I will explore this. > >The ./smatch_scripts/build_kernel_data.sh command creates the cross >function db. It takes a while though. And it's probably better to >run it a few times because every time you run it the call tree chains >get one call longer. I run it every night against the latest >linux-next. > I was not aware of repeated runs and chaining, will use repeat runs next time. Thank you, Nitesh Shetty
diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h index fbaee5a7be19..0b2e45faa3b9 100644 --- a/drivers/nvme/host/fabrics.h +++ b/drivers/nvme/host/fabrics.h @@ -125,7 +125,7 @@ struct nvmf_ctrl_options { char *trsvcid; char *host_traddr; char *host_iface; - size_t queue_size; + u16 queue_size; unsigned int nr_io_queues; unsigned int reconnect_delay; bool discovery_nqn; diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index 9f9a3b35dc64..7f680443b3cf 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -3159,7 +3159,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl) if (opts->queue_size > ctrl->ctrl.maxcmd) { /* warn if maxcmd is lower than queue_size */ dev_warn(ctrl->ctrl.device, - "queue_size %zu > ctrl maxcmd %u, reducing " + "queue_size %u > ctrl maxcmd %u, reducing " "to maxcmd\n", opts->queue_size, ctrl->ctrl.maxcmd); opts->queue_size = ctrl->ctrl.maxcmd; diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 6d178d555920..d0b7543f753e 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -1025,7 +1025,7 @@ static int nvme_rdma_setup_ctrl(struct nvme_rdma_ctrl *ctrl, bool new) if (ctrl->ctrl.opts->queue_size > ctrl->ctrl.sqsize + 1) { dev_warn(ctrl->ctrl.device, - "queue_size %zu > ctrl sqsize %u, clamping down\n", + "queue_size %u > ctrl sqsize %u, clamping down\n", ctrl->ctrl.opts->queue_size, ctrl->ctrl.sqsize + 1); } diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index d79811cfa0ce..d03f5921d344 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -2193,7 +2193,7 @@ static int nvme_tcp_setup_ctrl(struct nvme_ctrl *ctrl, bool new) if (opts->queue_size > ctrl->sqsize + 1) dev_warn(ctrl->device, - "queue_size %zu > ctrl sqsize %u, clamping down\n", + "queue_size %u > ctrl sqsize %u, clamping down\n", opts->queue_size, ctrl->sqsize + 1); if (ctrl->sqsize + 1 > ctrl->maxcmd) { diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c index 9cb434c58075..0416f41fad19 100644 --- a/drivers/nvme/target/loop.c +++ b/drivers/nvme/target/loop.c @@ -573,7 +573,7 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev, if (opts->queue_size > ctrl->ctrl.maxcmd) { /* warn if maxcmd is lower than queue_size */ dev_warn(ctrl->ctrl.device, - "queue_size %zu > ctrl maxcmd %u, clamping down\n", + "queue_size %u > ctrl maxcmd %u, clamping down\n", opts->queue_size, ctrl->ctrl.maxcmd); opts->queue_size = ctrl->ctrl.maxcmd; }