Message ID | 20221022174635.15643-1-namcaov@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1302304wrr; Sat, 22 Oct 2022 10:54:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Fm7yiazsjrnHDPsf0WwkWsmqiVVlO0v66I3fNpnu95r9z95b4jLp7GycZR28cKcZo84cL X-Received: by 2002:a17:907:a047:b0:78d:b8ac:765d with SMTP id gz7-20020a170907a04700b0078db8ac765dmr20575689ejc.631.1666461277485; Sat, 22 Oct 2022 10:54:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666461277; cv=none; d=google.com; s=arc-20160816; b=jSrvAkbjvZCo00G4/IL29xX+0JHZzKGqxoW6tYn8FNP1VI4jWJVDhGv7TJOq/NOxZO v/qBt7mcMLTEnGDvI73dxvdCLRKcUl3zXwOrP/vjsCKbEw2dlL2p2iMPQVKmv3Xb3o1J iYoCoWkLSibvDRCFK7oa2bcvqqwo2kZ3zUgGIHNNonuSJJZVKmB9UhJRi+jVSupDsR8c QCDUnAVlUCypMUvJtCkVTzX/6ed5QhE7d0EXhxESm1EWEQ2/f7kleNq3eu8BQmQ4wQpH q2YYK5n5IhMs99/P7a+8pxeLVPLCZIt+El+KY6tUA7RfK9e7ZF5vllMufkTsRnOid+XR y+gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=kA1RUYYc/4X5sRFnjwWDavrb0+igVW51vZRNo+KLENo=; b=K4k8Uyrnh5jK5T8Pdr/oOdwpmBa0SnZ7MAy2ryBtpjjjd1NfMllzIs6Li4wZW++9/v 5wFrYbiLeQlLPA/fM+hyGmnkANFRNIt2TOzpKJ1Gc0KzX8LjHZBktE6Yz287JA8tiUaS aYoBCKML1ceTq+Xn846RfjDgoX6rgWMH0H4Zwp2hG0W/knrKm1XNCeLIDG+dkWZopFA2 Z/+qiJ74x1nvTth032qyIJR/cJRTXz4TEYUTTeHSGI6eGuyzHLOy0WeQMNI3JGlteHtm Rz2UYjfuNhSk0DsAL0qRooiUthUBRobs01BmB06WWWoJILVBEssM/drA09nmq3sl2nU1 GeZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pk1JPaO1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg30-20020a170907971e00b0078da5f6ed9esi25577602ejc.779.2022.10.22.10.54.11; Sat, 22 Oct 2022 10:54:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pk1JPaO1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229864AbiJVRsU (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Sat, 22 Oct 2022 13:48:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229587AbiJVRsR (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 22 Oct 2022 13:48:17 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 183AAB2 for <linux-kernel@vger.kernel.org>; Sat, 22 Oct 2022 10:48:17 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id q19so17010207edd.10 for <linux-kernel@vger.kernel.org>; Sat, 22 Oct 2022 10:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=kA1RUYYc/4X5sRFnjwWDavrb0+igVW51vZRNo+KLENo=; b=pk1JPaO124kD9FUXsMNgIuLUnQeM7DtqHs1KwuFroXIGt6EGsnRBXLTXcE0liY6YNM QR9Z3txWC80+cz19T4MJOkXDvE2bf8gO4lrGGFyaq4hPGBH3/ZA4Hj6mNzhuvdnaEAea dtcwslJnx/X2Fl80CsqK1QTxyCuGNyA3KmtpcMeXJhpDADzfdLIj1scB6BS9ixy4uQKj jIQxALXTWuEBXMZloxPF861qOIXYfsdtiJbJF9ipavXB/43RBhmxXatbjtONQEXEgRgG W0Z6i7wt7n+9KtVHRCfuqUrjxY2+gxsWUWE5BgwueYwNvGUZEnGO05kr+8ao873HagD2 8lPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kA1RUYYc/4X5sRFnjwWDavrb0+igVW51vZRNo+KLENo=; b=hL/26eqRjkZ4aj6GsSwRrWE4XYxfvbcm5DySo/r0ztpxJ1cyul3ZNqIs02HqKxnDYF 0Xcen95shEuOTbYBw8pSpG2xvdYUteggEiXFcQXkLXB7xvr6+WEihkSojcmh8AtaFBXz XaZwBsEmoTMNsiJHWEcfh4zPrnXaaYTNlt2K5ZXn5upiKHUTDu2eXRMqqXURWeSH1AfW 2/yg1f4v8C1zkU4HCLENVH92AqUkS7N0JZpARLUnNb5zuNGWdO3bvJ0QkYiAqd8angBe RagWYhRXk03cCTzF1sytyTqrUJsOkvejpXRfkgQ87UbjZZv9VCSLOyXrDIwn199shueq rGHw== X-Gm-Message-State: ACrzQf0oE9t4OJmuXLjJehN9uZpGezcpeFtSiH0mqeMuNVA29iE1aUX6 8wqt1qbnnOv57Uvy2o+IvLE= X-Received: by 2002:a05:6402:520f:b0:45f:b7a0:a31 with SMTP id s15-20020a056402520f00b0045fb7a00a31mr15742960edd.379.1666460895540; Sat, 22 Oct 2022 10:48:15 -0700 (PDT) Received: from localhost.localdomain (ip-217-105-46-178.ip.prioritytelecom.net. [217.105.46.178]) by smtp.gmail.com with ESMTPSA id r17-20020a170906351100b0078d4962a46bsm13054235eja.190.2022.10.22.10.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Oct 2022 10:48:15 -0700 (PDT) From: Nam Cao <namcaov@gmail.com> To: kbusch@kernel.org, axboe@fb.com, hch@lst.de, sagi@grimberg.me Cc: namcaov@gmail.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] nvme-tcp: replace sg_init_marker() with sg_init_table() Date: Sat, 22 Oct 2022 19:46:36 +0200 Message-Id: <20221022174635.15643-1-namcaov@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747411300631249116?= X-GMAIL-MSGID: =?utf-8?q?1747411300631249116?= |
Series |
nvme-tcp: replace sg_init_marker() with sg_init_table()
|
|
Commit Message
Nam Cao
Oct. 22, 2022, 5:46 p.m. UTC
In nvme_tcp_ddgst_update(), sg_init_marker() is called with an
uninitialized scatterlist. This is probably fine, but gcc complains:
CC [M] drivers/nvme/host/tcp.o
In file included from ./include/linux/dma-mapping.h:10,
from ./include/linux/skbuff.h:31,
from ./include/net/net_namespace.h:43,
from ./include/linux/netdevice.h:38,
from ./include/net/sock.h:46,
from drivers/nvme/host/tcp.c:12:
In function ‘sg_mark_end’,
inlined from ‘sg_init_marker’ at ./include/linux/scatterlist.h:356:2,
inlined from ‘nvme_tcp_ddgst_update’ at drivers/nvme/host/tcp.c:390:2:
./include/linux/scatterlist.h:234:11: error: ‘sg.page_link’ is used uninitialized [-Werror=uninitialized]
234 | sg->page_link |= SG_END;
| ~~^~~~~~~~~~~
drivers/nvme/host/tcp.c: In function ‘nvme_tcp_ddgst_update’:
drivers/nvme/host/tcp.c:388:28: note: ‘sg’ declared here
388 | struct scatterlist sg;
| ^~
cc1: all warnings being treated as errors
Use sg_init_table() instead, which basically memset the scatterlist to
zero first before calling sg_init_marker().
Signed-off-by: Nam Cao <namcaov@gmail.com>
---
drivers/nvme/host/tcp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
On 10/22/22 10:46, Nam Cao wrote: > In nvme_tcp_ddgst_update(), sg_init_marker() is called with an > uninitialized scatterlist. This is probably fine, but gcc complains: > > CC [M] drivers/nvme/host/tcp.o > In file included from ./include/linux/dma-mapping.h:10, > from ./include/linux/skbuff.h:31, > from ./include/net/net_namespace.h:43, > from ./include/linux/netdevice.h:38, > from ./include/net/sock.h:46, > from drivers/nvme/host/tcp.c:12: > In function ‘sg_mark_end’, > inlined from ‘sg_init_marker’ at ./include/linux/scatterlist.h:356:2, > inlined from ‘nvme_tcp_ddgst_update’ at drivers/nvme/host/tcp.c:390:2: > ./include/linux/scatterlist.h:234:11: error: ‘sg.page_link’ is used uninitialized [-Werror=uninitialized] > 234 | sg->page_link |= SG_END; > | ~~^~~~~~~~~~~ > drivers/nvme/host/tcp.c: In function ‘nvme_tcp_ddgst_update’: > drivers/nvme/host/tcp.c:388:28: note: ‘sg’ declared here > 388 | struct scatterlist sg; > | ^~ > cc1: all warnings being treated as errors > > Use sg_init_table() instead, which basically memset the scatterlist to > zero first before calling sg_init_marker(). > > Signed-off-by: Nam Cao <namcaov@gmail.com> Looks good to me, can you please share what version if gcc you are using ? my test setup did not catch this error and I'd like to update with the one that can catch these errors. Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> -ck
On Tue, Oct 25, 2022 at 12:58:41AM +0000, Chaitanya Kulkarni wrote: > On 10/22/22 10:46, Nam Cao wrote: > > In nvme_tcp_ddgst_update(), sg_init_marker() is called with an > > uninitialized scatterlist. This is probably fine, but gcc complains: > > > > CC [M] drivers/nvme/host/tcp.o > > In file included from ./include/linux/dma-mapping.h:10, > > from ./include/linux/skbuff.h:31, > > from ./include/net/net_namespace.h:43, > > from ./include/linux/netdevice.h:38, > > from ./include/net/sock.h:46, > > from drivers/nvme/host/tcp.c:12: > > In function ‘sg_mark_end’, > > inlined from ‘sg_init_marker’ at ./include/linux/scatterlist.h:356:2, > > inlined from ‘nvme_tcp_ddgst_update’ at drivers/nvme/host/tcp.c:390:2: > > ./include/linux/scatterlist.h:234:11: error: ‘sg.page_link’ is used uninitialized [-Werror=uninitialized] > > 234 | sg->page_link |= SG_END; > > | ~~^~~~~~~~~~~ > > drivers/nvme/host/tcp.c: In function ‘nvme_tcp_ddgst_update’: > > drivers/nvme/host/tcp.c:388:28: note: ‘sg’ declared here > > 388 | struct scatterlist sg; > > | ^~ > > cc1: all warnings being treated as errors > > > > Use sg_init_table() instead, which basically memset the scatterlist to > > zero first before calling sg_init_marker(). > > > > Signed-off-by: Nam Cao <namcaov@gmail.com> > > Looks good to me, can you please share what version if gcc you are > using ? my test setup did not catch this error and I'd like to update > with the one that can catch these errors. It was just gcc12. But strange enough I cannot trigger this error again. I was doing randconfig test build. Probably only a specific combination of configs that can allow gcc to detect this... And sorry but I was just start doing randconfig test and didn't think about saving that .config file. Best regards, Nam
Thanks, applied to nvme-6.1.
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 1eed0fc26b3a..dc2def86076d 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -387,7 +387,7 @@ static inline void nvme_tcp_ddgst_update(struct ahash_request *hash, { struct scatterlist sg; - sg_init_marker(&sg, 1); + sg_init_table(&sg, 1); sg_set_page(&sg, page, len, off); ahash_request_set_crypt(hash, &sg, NULL, len); crypto_ahash_update(hash);