From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 675EDA0C4C for ; Thu, 14 Oct 2021 19:55:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5D3A8410EA; Thu, 14 Oct 2021 19:55:56 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id AF8A44003C; Thu, 14 Oct 2021 19:55:53 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10137"; a="207866098" X-IronPort-AV: E=Sophos;i="5.85,373,1624345200"; d="scan'208";a="207866098" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2021 10:47:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,373,1624345200"; d="scan'208";a="442214230" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by orsmga006.jf.intel.com with ESMTP; 14 Oct 2021 10:47:42 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Thu, 14 Oct 2021 10:47:41 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Thu, 14 Oct 2021 10:47:41 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Thu, 14 Oct 2021 10:47:41 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.170) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Thu, 14 Oct 2021 10:47:40 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lypVk3a0Fzi9eFHAA1W8fjrQHOEgYC8RisZrc/t1zgA2dR9mAUdeJMDQvbYUFRRQln1V7F03PFf/EPqbkHPTA7gERMR4eX3Ww6A2ZlC+Eydc1B1/FyvG6gKy1W8p0H7ypOwD/LzjrGYlhPopQLmUkCEtAMMUNafa+uX8unLY3JMNgpGBWxqpj2UWHPEBwObtGFwA1py+3cH49+QuVQCBRp/wktdIoqHeaRNJIzAbKpyiIBGIwPVZi71You6mT+l+1WLsR3MO2dKUmEaqfUSgA6Hr7vC0Y7DLG6L2dZl0ikOFq7yx4v1Hdar2fIychcU9giY6YqZ1ibhhKbVY0+1owg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+hPBvB34SG2uy1iLVEOw6knbOAS5618+1SJQ25VzWCA=; b=DgpQpGh+Ct2aeslfcfNk2cXFCbjL6SV3+mM0LcwVESIlqkeIOsurxV7tPWoCQyT6E6yTAEaRcDC/ll37MILI6V/yoGHaOy/4wY9X2POpXOa+PE+QWItyZUOV8Vtu9GlmqnocvMbegn2+4QuT46wEMtmPabIEEQnn9DOI/U4bMz4U30KzAHlUTW6z/QPJaNAYBcZOjaxf8YbILfb46KHEKV9i4iirVz+OQZ/fQNoPJdNV793CpbDBo3EcThnJ4nlrzEkNh32RINPIzXsTOZrLoo4daoN3oMHz2IfYuZ/MOT/6SwTySH7ZAgJJIbcOpgFNew9HPs1MIiVOqG/90mo/Og== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+hPBvB34SG2uy1iLVEOw6knbOAS5618+1SJQ25VzWCA=; b=BM054G7c+iNscVVDE2rWCDrMpxdBl9p1J8BTi9xL2UmEVhL1AWJv3cND6xyJd5DcdN5olZt6KU8GyM28bTsKqYPlzG8o0NWe6kuEzBxqRN1PPBx/s1NVWuPtImwsqbzsk/0Q5M9UPuDtw13/SlnY5IHNHNImTXKses6bDmeMPvg= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5013.namprd11.prod.outlook.com (2603:10b6:510:30::21) by PH0PR11MB4966.namprd11.prod.outlook.com (2603:10b6:510:42::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.19; Thu, 14 Oct 2021 17:47:37 +0000 Received: from PH0PR11MB5013.namprd11.prod.outlook.com ([fe80::4c6a:b2b:c561:4c85]) by PH0PR11MB5013.namprd11.prod.outlook.com ([fe80::4c6a:b2b:c561:4c85%8]) with mapi id 15.20.4587.026; Thu, 14 Oct 2021 17:47:37 +0000 To: David Marchand CC: dev , "Wang, Yipeng1" , "Gobriel, Sameh" , Bruce Richardson , dpdk stable References: <1633728526-197782-1-git-send-email-vladimir.medvedkin@intel.com> <1634153265-193315-1-git-send-email-vladimir.medvedkin@intel.com> From: "Medvedkin, Vladimir" Message-ID: <52ef214b-a140-4815-3301-7c91da93570f@intel.com> Date: Thu, 14 Oct 2021 19:47:31 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.14.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: DB6PR0501CA0032.eurprd05.prod.outlook.com (2603:10a6:4:67::18) To PH0PR11MB5013.namprd11.prod.outlook.com (2603:10b6:510:30::21) MIME-Version: 1.0 Received: from [192.198.151.52] (192.198.151.52) by DB6PR0501CA0032.eurprd05.prod.outlook.com (2603:10a6:4:67::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Thu, 14 Oct 2021 17:47:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 54c33d8d-8528-4434-139e-08d98f3ab600 X-MS-TrafficTypeDiagnostic: PH0PR11MB4966: X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XuyZlMtT0NzttRp747ypCbPlIYQe7OZMiZaXErBPu5x3FroYDi77bi4iNVYGHm9naKS8n0mPPOrYBLD3ACFbgI7MH9HXNLuMrh/+nF7fJOWSrgvn/EQbTJIxLTIrG81EqtLIVAhxFdk8q7U0e1RhyGzWJMAc40AMBTpN4DobM3gmk7jOyxoJXBmuPdVchSYhzJZxNNXTuUh7pPxiTaZsOeGVxXQy9uwGLrThf8EoPZqkRCMd8kGTXqwUELdNGapJ3I4Y2Yf/w1IezFj+F+a9uNWcFSDN5W9P171E9NTNvJN4RFV92JRgW3qSn6Dp9g6CMlU1SNzi1Olk/Q1gnyUrzhHyUBVB9Ldb7hdfLHWa98tIB0QO5vYxgkT315YhE3rQke7oDEI5+yM5z24z0MSHfkVdLJhwwn6aPPziF4bM1CUTo7EXSMJGoXyTIJT9aZ2YqISE0ePBfMdQMekQ+/XlACwGdb5Ve9KbKAdVuWEusZdbhxPcX31ByYVs2u0sbmMYQse3GifbaLgJcYf5AO91PGjxz3z9fs0QKZ3O6PLiR+l7fxto+nOv6IVfYrarLx4KVg6w5K93C7d4DqDgOnQG/PbBYMILqMVqRRs+/H3FYPdcmKJhNCuL80LizzEg+IVVyb5L3hSRn3g9EnKI9a9xEp55SqPDqJ1er3Sa8CI+WqYyYY9kYtrXvEqu228ix2Qyo7Lphbdaf0qL3wKvLN1wvyc2aupW7LpSF6pQ5teA56Sq6wkLC5JWNFh5SNpdsEcscAYntwsmYJ1Fc8YmFitzGBWytFVt8sJQpxBsbBITEUAsChPNk8WE8uK4HXn3/dMS+zKVUiyR3eTZxrcotpTOr+Zbl0d2gFzMGvLOYdUjNYI= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5013.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(6486002)(8676002)(86362001)(66476007)(6666004)(316002)(83380400001)(2906002)(5660300002)(66946007)(66556008)(8936002)(31696002)(53546011)(6916009)(186003)(4326008)(6706004)(31686004)(38100700002)(82960400001)(966005)(2616005)(54906003)(16576012)(26005)(508600001)(36756003)(956004)(3940600001)(43740500002)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bW9URUcwdUZKK3ZNSGZUcndndzBhNGVnU3Z5OGF4aXNVcXk5NGp0YUMydVQv?= =?utf-8?B?U3RJajh5NE1wZEZPRHp2MUtHNmZFM1hiQWR3bFhRSnZaWV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zNmttK2RmalFtWFpHVTRIYnh5?= =?utf-8?B?Y0lVdGdQRHMzTVFudTNWOUZtMDRnU3BheS8xNklWRXBtRGVOT3JOOElOTDlp?= =?utf-8?B?ZTFVR2hpOEtzYWM4Q1k1VWtsSEF6cW41M21maE1kVUt2VzViS3ZSK0pwU0hz?= =?utf-8?B?Z0U4Q3pXaE9hRVpnMTFkcm5ETHVxZUowVkhCSkxhTXhZbXZFeFpqUXpHakNz?= =?utf-8?B?YTN5eTE1Z2R6RFBqVWFkcTArdmVWNEliRnFQMktzZms1UFIwTm5ER2xsS0pa?= =?utf-8?B?TjNadVpXK2ZPSUw2Ym1GUG9JVXpzVU1FTjFsRGhOUlFFQndnY2JXdHBjdzdk?= =?utf-8?B?MHR6Wk15MWdlNTY2ZitzL2hpK2VVWjZkQnFYVTdLVzdXbDZndTczWStJSCti?= =?utf-8?B?aHFZUS94cmE1eGVSWVBiRUpuazBZWU90dGxoVmQvQk9lYjZxQUsxZkhPNDEv?= =?utf-8?B?Zyt1S0FyWE55S2VRbFk2SmpQWlFWU2dNRkJJdm1BNkJFMExWZXg0N0ZERUM1?= =?utf-8?B?NDFPcG5rYmd3V1NXMmZhN20vVytnVkhlVGpFY3lLaFhPcFFTTE9XY2FvMWJ0?= =?utf-8?B?dnZRL2U1cGoxR29LTmVJVjVuMTczTW5wZHpaNjhMOVZ6U0dwc2szY0xvTGtW?= =?utf-8?B?a1lvdjlGS2RicVkvVmF1bzhEQ1I5QUo2SWF0eUo0UndQRDlWSTJzVHJJMnBE?= =?utf-8?B?OEhYZTdHVElKekp5TndyWTdUZXE4eVc1V2k0d2lVVE02VzNheWl5MzVIeEFY?= =?utf-8?Q?JAQOJqnyvzh+5v9KcCALxMUPTgibY5Wtav8T2ES?= X-MS-Exchange-CrossTenant-Network-Message-Id: 54c33d8d-8528-4434-139e-08d98f3ab600 X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5013.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2021 17:47:37.5074 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SWV0YTcugKX0IBRQIt8pe9EFr6DMcKeT6LDlJfnFn1FkaRaDkd6QIZRCCDBC10dBTGtW+ujSJpYtK52vxvKxmnt4WHxtjTUOypXPkSMOYCU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB4966 X-OriginatorOrg: intel.com Subject: Re: [dpdk-stable] [PATCH v2] test/hash: fix buffer overflow X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi David, On 14/10/2021 10:34, David Marchand wrote: > On Wed, Oct 13, 2021 at 9:28 PM Vladimir Medvedkin > wrote: >> >> This patch fixes buffer overflow reported by ASAN, >> please reference https://bugs.dpdk.org/show_bug.cgi?id=818 >> >> Some tests for the rte_hash table use the rte_jhash_32b() as >> the hash function. This hash function interprets the length >> argument in units of 4 bytes. >> >> This patch divides configured key length by 4 in cases when >> rte_jhash_32b() is used. >> >> For some tests rte_jhash() is used with keys of length not >> a multiple of 4 bytes. From the rte_jhash() documentation: >> If input key is not aligned to four byte boundaries or a >> multiple of four bytes in length, the memory region just >> after may be read (but not used in the computation). >> >> This patch increases the size of the proto field of the >> flow_key struct up to uint32_t and sets the alignment to 4 bytes. >> >> Bugzilla ID: 818 >> Fixes: af75078fece3 ("first public release") >> Cc: stable@dpdk.org >> >> Signed-off-by: Vladimir Medvedkin >> --- >> app/test/test_hash.c | 10 ++++++---- >> 1 file changed, 6 insertions(+), 4 deletions(-) >> >> diff --git a/app/test/test_hash.c b/app/test/test_hash.c >> index bd4d0cb..e3f2d29 100644 >> --- a/app/test/test_hash.c >> +++ b/app/test/test_hash.c >> @@ -80,8 +80,8 @@ struct flow_key { >> uint32_t ip_dst; >> uint16_t port_src; >> uint16_t port_dst; >> - uint8_t proto; >> -} __rte_packed; >> + uint32_t proto; >> +} __rte_packed __rte_aligned(sizeof(uint32_t)); > > If in the future, we add a field not multiple of sizeof(uint32_t), > there will be some padding at the end of the structure. > I *think* holes and padding content is undefined for initialized > objects (though maybe things could be different with objects in .data > ?). > That's probably something to confirm. > If this is the case, the hash function would consider random data. > > I think growing the proto field to uint32_t like you did is the right > fix since the whole structure is now naturally uint32_t aligned. > > But I would remove the aligned attribute and prefer > RTE_BUILD_BUG(sizeof(struct flow_key) % sizeof(sizeof(uint32_t)) != > 0). > Maybe add a comment to explain we keep the packed attribute to avoid > holes with potentially undefined content in the middle of this struct. > Agree, will do in v3. > -- Regards, Vladimir