Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2679606imw; Wed, 6 Jul 2022 09:55:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u4g/Vz4UFVuCG+QZM/bS64cnMqfXJ5D0riRGwonbgmunWuoov4QhyaPocFsxS7tcgAI79u X-Received: by 2002:a17:902:7d86:b0:16a:53f:4d36 with SMTP id a6-20020a1709027d8600b0016a053f4d36mr47482039plm.34.1657126550716; Wed, 06 Jul 2022 09:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657126550; cv=none; d=google.com; s=arc-20160816; b=x6kjG1qCpRfrORREPEKjA34OaoTfbRmy25JnGCaISjF35SzwD28GEqXIUqtkQh9r3p npb6TFi8mhe19DYNyZbxhb0ugTjdU6klw9Iy+BRQYxOXapKjqaE7Hfe+l4VIY1LCLv+z H+hYSesTUyHcNrJzc2ABCkaHi27kgYkIBSicNlL/5hrmVkfK8b7rxQw25FjeBBIg1neW tDhfmWtVzxa6t6MuLKmwdf7NHF80noq8XhSERcXZP0AkZcwY460mZgNG2M6RaWuoOrrS YSCIQvX9rC9FXGhjH1oO4e0OzsDG2CDFm7iOLO3ucaHoOPF9B6IC3mcrwHEjsMJmWTc1 GFSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=8A3ceW2Z9e+9Zo4QCepYi7WUw+5vlYDTDEmcLB29Wg8=; b=OU9Ye/2r0AjMzuXdfAgQEdv1wMkJ12g9KwggfSacyOJIh/aYaa5zBYMNOO2as/lDjr YCx5dikLZxtNsipqfx5EHnGcmTspPhn0Q6E4oDudTgv3gk+k9/xXj+f0iZr00o0fgzYd FvVIJ9ScoIdxgQsf0ORORnNjq6U1qfK2PfjnWhspNkksRkxSn0wNdO1GltYGfMuf/aNp vM4wIzar5ay8mGUd4nUPJ7ei3kS9FHqIvHtfMIkz5cDbpSHc9Fm6vkuOP4Ss2O/Wu765 +2YX+cXI8XaV/5IzJWGSXmaEYbRftPmvI1z4CkslBOrggU3GvnEwscKYd6xKpO/vM16e RlwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W31t8Uh5; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lp7-20020a17090b4a8700b001e3239b683fsi24881971pjb.90.2022.07.06.09.55.36; Wed, 06 Jul 2022 09:55:50 -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=@kernel.org header.s=k20201202 header.b=W31t8Uh5; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234425AbiGFQNc (ORCPT + 99 others); Wed, 6 Jul 2022 12:13:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234392AbiGFQN3 (ORCPT ); Wed, 6 Jul 2022 12:13:29 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD9521111 for ; Wed, 6 Jul 2022 09:13:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7EDC3B81A99 for ; Wed, 6 Jul 2022 16:13:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4539C3411C; Wed, 6 Jul 2022 16:13:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657124006; bh=LA1VOdK5ORMoU+ewAB2GaJidmodmb2eFm76yDvl9Yo4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=W31t8Uh5Qnw6yELg57p4gOOOxvDnB0kHkcoTzmetYEh7N0irUK2SErFHh0QgM6RoZ jnmwmDT4YuuBtyd1qMluR0dkX2VzqErJgrgJ7SUNuqiMihrkbDQ5ZVIIW5hd1KVxeA snOohjfx6i5tQMOnUDutgcFi8zUpe9rHaXWqkqnEz8V8paX4zneI3ue0dafdsrEkaT 4H0cPByYmx95x/eJvEoBdz4V/mwkS1IKzcJa2t9sQao2YY4TUgLLD7sl9ADeYFpfNg xroPQecRzIK8PvexI67SBvSi3ra+NBCa1lfkW1N12qvHSULQQ7ijuBvuO0rjdooS8H GV7o0cu9Ws3EQ== Date: Wed, 6 Jul 2022 10:13:22 -0600 From: Keith Busch To: John Garry Cc: axboe@fb.com, hch@lst.de, sagi@grimberg.me, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] nvme: Fix nvme_setup_command metadata trace event for cdw10 Message-ID: References: <1657095398-114310-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1657095398-114310-1-git-send-email-john.garry@huawei.com> X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 06, 2022 at 04:16:38PM +0800, John Garry wrote: > For x86_64 allmodconfig I get this warning: > > In function ‘fortify_memcpy_chk’, > inlined from ‘perf_trace_nvme_setup_cmd’ at drivers/nvme/host/./trace.h:47:1: > ./include/linux/fortify-string.h:352:4: error: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror] > __read_overflow2_field(q_size_field, size); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > In function ‘fortify_memcpy_chk’, > inlined from ‘trace_event_raw_event_nvme_setup_cmd’ at drivers/nvme/host/./trace.h:47:1: > ./include/linux/fortify-string.h:352:4: error: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror] > __read_overflow2_field(q_size_field, size); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > cdw10 metadata is 24 bytes, and we try to copy size of cdw10 metadata from > nvme_command.common.cdw10 into that cdw10 metadata, but > nvme_command.common.cdw10 is only 4 bytes in size. > > Fix by making the trace metadata size as 4 bytes. > > I find that this warning started first appearing from commit f68f2ff91512 > ("fortify: Detect struct member overflows in memcpy() at compile-time"). Did you test what the trace looks like afte this? We're losing valuable trace data here. The field is supposed to get CDW's 10 - 15, so that's 24 bytes. I don't know why it cares that the address of the field being read is only 4 bytes; we want everything that comes after it too.