From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 25BD1D80C7F for ; Wed, 20 Sep 2023 15:18:32 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=oSpEKWQi19USF2lEg2v6nnZZGfNwB+TYc6o0KZ5AxQc=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1695223110; v=1; b=h8TkjRjC6/UGg+OnZDk9h8N1DAiKWj0wTsFNo2d/8NqVCXucvRw20LtjCBouZSraEo9WN0sH BokLQ/Xgc7XlKlMUYIreoYBKX2afrklOkQt7GnnxEBlllCsWjEv3IJYW4GuyY2NhM2Yxjxu4sXd SHLXoEJTxbUmz2Mqtl9r1/Wc= X-Received: by 127.0.0.2 with SMTP id GVyFYY7687511xuajSjXnCgX; Wed, 20 Sep 2023 08:18:30 -0700 X-Received: from NAM04-DM6-obe.outbound.protection.outlook.com (NAM04-DM6-obe.outbound.protection.outlook.com [40.107.102.59]) by mx.groups.io with SMTP id smtpd.web11.42661.1695223109710211839 for ; Wed, 20 Sep 2023 08:18:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NxWLN++0Ly+8esim4QtPZ/7ZigjsR8UVCjtYrXhTlCNFZBaj86xm+PqL4xjxCmoUBEKMzZKb6f20CJxKcjZFYaIdGgOtj1KClOnhWwqP/rfKiZgLzTB2hLItiIO4+QdEXxyxOMXUphRmEd57kNWZn5IaYAR7FFIuu5nrzCuQBAxWk58aBgid0A361vzsKSrFsnXhiHf6MM+BPL1H1+FxwuelUQW3ffUjoDyGRzmBgUsOfW1B9gvEvCymKuF9OqKwySfXfqoS5gvoyOj8WFPe8NaPeqdcyJyKc2YFmKxoxH2LeP3x7DoknfI8EG/XklIU+9PLZib/q57UOq4mIyElow== 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=PRA5mI8srQjKpvdQ0W1stoDtk0e0BFmedBP43no+SQ4=; b=XAVUQ0ElN5YvK3HpGTNHYOYZn/n9tRkrD8QMSGgNLRcuICVBrrMTRjCMzvwosVQw3LbYEor7l6opejG3/K7cZEWYj1MBbw+BxzmAsnP87Lo7rKX/sp6TknfOg2Pg8edkvnYUaE3rtrbRxlhPCpegW0g58LIY1ADNlU4urj7I01qER9b/k21N1wMkqEJarNNNVSG129thmFhOziafsX2IJ145c/PYAOYUYNsqMtO8arQZUNtm0T+BFJ7xmCrKu2NmlE2UC8DibuXL4TT8z2uQceQBJ2QpeG/9tdMjdhtKlblFL+WgXfjbMNC48CP5YyG/tlykyRirIDG5X7hgOCFhDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ami.com; dmarc=pass action=none header.from=ami.com; dkim=pass header.d=ami.com; arc=none X-Received: from BLAPR10MB5185.namprd10.prod.outlook.com (2603:10b6:208:328::16) by CH0PR10MB5164.namprd10.prod.outlook.com (2603:10b6:610:da::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Wed, 20 Sep 2023 15:18:23 +0000 X-Received: from BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::dc2c:50e8:b23e:d010]) by BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::dc2c:50e8:b23e:d010%7]) with mapi id 15.20.6813.017; Wed, 20 Sep 2023 15:18:23 +0000 From: "Igor Kulchytskyy via groups.io" To: Nickle Wang , "devel@edk2.groups.io" CC: Abner Chang , Nick Ramirez Subject: Re: [edk2-devel] [PATCH] RedfishPkg/JsonLib: fix JsonObjectGetValue issue Thread-Topic: [EXTERNAL] [PATCH] RedfishPkg/JsonLib: fix JsonObjectGetValue issue Thread-Index: AQHZ6jFHjj/iUZHxa0mPmFXo0d/sgrAglszQgALYWaCAAGZzEA== Date: Wed, 20 Sep 2023 15:18:23 +0000 Message-ID: References: <20230918130838.6137-1-nicklew@nvidia.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BLAPR10MB5185:EE_|CH0PR10MB5164:EE_ x-ms-office365-filtering-correlation-id: c281f4f8-d172-4a47-8ec1-08dbb9ecd4a9 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: BILE7IhmkCf34xNcxAeFjVB1tgjsVSRfT7LTL8vJJbV3OJz7PFgKUTyJ+JuSh6l8CIX/Vzs7vaXgK5q+TG+4/CyRc8FqkkRsndEGsufUiAIwXB4+CaEhPhO40w4nCe+l20e+xBi/OJBoSJ5hRwvNwpfcJvOdc/SvcF3jB7l+udSE7rxbZNEqnxbompNBfC29A5DsSMB9RN5qv0Hwos09z69DhTOQuhM3QwmnoCnqXuRIp/rWN+bxy0xm7wTeFHsggfmpX8qfTEDLRERPhfs87l0LmayxcpgWisUR/qwJoPjqaaxDMKWCc3cY8ahapkU2HG58xoc/ZxolE1j4NKpjPkXn3QT8vPwYaPMx+sFxQgeEDAFcAHJxYfiH/HB9dmv89ASHSkGI3i1+RHAruDxP3wf3YIOusx4YSAWxPYr4zOPzAWvOAVNFAH/E14f/4sM3g7TmbjyXkv240ENcZtLXYGT4NHcg9xzdBjfy8CGsdiS4T9dtFxSUSOYZUrH2XqI5B/bURyJAkFPKDYRuj8VzcLdin6Blofl9pwJk9wCoKjHXxkUEJAuFDMEiTcIBTUTUjX9TU1p2f2Jxc0hTJoioZgPMJhEQkvLse39r2JCNqXE82S6LTFtJx0QuAAe74wZr x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?G71dPIl2Dm8QfG18ptCPhh+cuLiOZevFCtRXeWtWTid/u5UNbqRAw4bJIV7w?= =?us-ascii?Q?CeDmLo+WGguX9+6Xcj6bc6XTP52ntrgyH5ovcN5464nU2dDvkuPMIUsPSolq?= =?us-ascii?Q?o+5E2cYq8C2c5J0HkqLSKGekCwrOsPmB2dIc3GYDueyAodfS7+eNpZIOdl3i?= =?us-ascii?Q?+QVwO8FN84VAwTYWXA2raXuHIHoyS3WeGzOWUIvdgkS9/GoAftscD3X2H2wy?= =?us-ascii?Q?5keZ74fhs2vfjziX8BVQrGfxg3F9nl2qwAN1/Lhmvh6xrIILgX/7x9QjOiTT?= =?us-ascii?Q?OB/3okUqZeTMsHvTKXL7ruocA8IqsfQG0un7YZan54D/+6+edF9BjCWYximz?= =?us-ascii?Q?bzJspI6isLCOs/UFfsjqa37FkSQxUN6xlwY2BFk5qeBg/c3okxa89a2NqZts?= =?us-ascii?Q?crlKvO+JAK/kfO85iWQs80xYEi+oO9IHoEZyJg8Ab44PgyYoV5pJs0oKcmfE?= =?us-ascii?Q?bMgiNSA4rwffksHqQwafpkVo7P4W8ZXtl6bqHuUJZsfimTGmW3l+uLU1y5aq?= =?us-ascii?Q?FdUdC0VY7qvIj50nWJSrioFnqKb+V4QkAgq3qOerhF6gwdQis05Vsxki2KCJ?= =?us-ascii?Q?QZ8qR7Vz9f9FG2Hkpc6wvbLoXKb8tjRjyaie7pCpNOnRwAmkSyNlTcVJHyns?= =?us-ascii?Q?IhZdUokH2sxMGGLMBxysagP3SNE9auSJkOxSdxy2SE4gZ2AwWkBivrFQrYDC?= =?us-ascii?Q?JTiby8ixWGT6dzllglhpQF27maJ2U+Z0m7MKuKqYwnV37yB5Silm/Jyr0w5D?= =?us-ascii?Q?TojFBW6G5Xy3Stx8RLpn5/pLnZEdAwE1f1N2ygoP+U7ou4SuPvDFAZl6Xwx2?= =?us-ascii?Q?mhcejo6rH4S7i8laNjLWdcfXyIEtnpIQVyFXVr2+wbSsTaX0HGEyKv7t3OuC?= =?us-ascii?Q?e4UfL9hXQUSgmfk8AcJqSTO1UF9coD2ACyd8oIG3wgbpG33XV3GmfSy+QNZX?= =?us-ascii?Q?VJ7nNe/1qaTOHLct4hsfzQvgItdK/jWu6mxNa79DphPg1h8EndoLBLTujK7F?= =?us-ascii?Q?DbenVTfzfsSQ9uYIN66HfWbmv8Lj9th7UqTI2xiF13K3VrZ69i/+MURTKcA3?= =?us-ascii?Q?M5Eo33Wbb8k672190V+RGiSCp+xC2w+0FZbVPKtwbmhx2MLm2VqcmNs4KB7r?= =?us-ascii?Q?chM88FGtXuYPSVqvbEhYuaCt4rj8/C/rq+Pct7l8T/B/SOXge1IAldktJ49R?= =?us-ascii?Q?ZAIJ3azaD6vGnIc1VbKHl+Sj8ILlh0mNKrDiosRXafgm3EyDaVtHoYfc2vCh?= =?us-ascii?Q?S7d0vnzTZveG34rSPCt9x4kuGomY2GPDpIFaIRQD8cAbuejTZU1ztgCnI3Mu?= =?us-ascii?Q?q6BhIZfr2gZK8LKr7Lqlr16dvzFAwoS6ErW/QNL9T4dw+wlYfW/HGh0WJrzA?= =?us-ascii?Q?7w+yusI5yLa9GJ3/ly8PxJJ+EklyGNroBeOtrv0vGzKHilhNpal629vI/jaF?= =?us-ascii?Q?7o6WWYDI269NSX0ZDun9mAyeNgr8eUCNnE1fLAMjZPrZAqRjxKPr53e8bjKA?= =?us-ascii?Q?0/QzTpv2IN2GHnxbutibZuCsLuwtabJy8HlSLcfUCiauqGDwiGxp29QRYPJp?= =?us-ascii?Q?Ay9zSXdwxE+cWj1XEJg=3D?= MIME-Version: 1.0 X-OriginatorOrg: ami.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5185.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c281f4f8-d172-4a47-8ec1-08dbb9ecd4a9 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Sep 2023 15:18:23.3841 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 27e97857-e15f-486c-b58e-86c2b3040f93 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 5EK9YwNOjVfsQlqZlTFje+SvN+ZamhW4UdNgz5iEBRdY96SirrO1mP33Vx3ndvzo X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5164 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,igork@ami.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: kURYjieIonfGRtLOAXewwhkyx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=h8TkjRjC; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=none; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") Hi Nickle, Yes, I understand the mechanism of how seed works. And when I used the RedfishPkg and Jansson parser in my modules, I passed t= he seed to each driver, so, all of them used the same seed. All of them call a json_object_seed() function with the same seed. Now, there is no need to do it. Thank you, Igor -----Original Message----- From: Nickle Wang Sent: Wednesday, September 20, 2023 5:18 AM To: Igor Kulchytskyy ; devel@edk2.groups.io Cc: Abner Chang ; Nick Ramirez Subject: RE: [EXTERNAL] [PATCH] RedfishPkg/JsonLib: fix JsonObjectGetValue = issue Hi Igor, According to my understanding to jansson implementation, json_object_seed()= is only called in three places. Two of them are in test code and we don't = use them in EDK2. The only chance to call json_object_seed() is in json_obj= ect(). So, it is called when driver create new JSON object and hashtable_se= ed is not initialized yet, which means json_object_seed() will be called o= nly once per UEFI driver. json_object_seed() use current time as hash table seed, which creates issue= in EDK2 environment. In EDK2, library is built with UEFI driver together. = So, there are multiple instances of JsonLib in the system. And the hash tab= le seed is different in each driver in current implementation. As the resul= t, the JSON object created by this driver can not be used by another driver= . > Does that mean, that json_object_seed function is useless anymore with th= ose > changes? Yes, once constructor set hashtable_seed to a magic value, json_object_seed= () won't do anything. > And there is no need for other module to call json_object_seed? No, it is called when driver create JSON object and the seed is still zero.= Once the seed is set to non-zero value, json_object_seed() does nothing. Regards, Nickle > -----Original Message----- > From: Igor Kulchytskyy > Sent: Monday, September 18, 2023 9:42 PM > To: Nickle Wang ; devel@edk2.groups.io > Cc: Abner Chang ; Nick Ramirez > > Subject: RE: [EXTERNAL] [PATCH] RedfishPkg/JsonLib: fix JsonObjectGetValu= e > issue > > External email: Use caution opening links or attachments > > > Hi Nickle, > Does that mean, that json_object_seed function is useless anymore with th= ose > changes? > And there is no need for other module to call json_object_seed? > Thank you, > Igor > > -----Original Message----- > From: Nickle Wang > Sent: Monday, September 18, 2023 9:09 AM > To: devel@edk2.groups.io > Cc: Abner Chang ; Igor Kulchytskyy ; > Nick Ramirez > Subject: [EXTERNAL] [PATCH] RedfishPkg/JsonLib: fix JsonObjectGetValue is= sue > > > **CAUTION: The e-mail below is from an external source. Please exercise > caution before opening attachments, clicking links, or following guidance= .** > > JsonObjectGetValue() cannot find corresponding JSON value when the > EDKII_JSON_VALUE object is created by another UEFI driver. This is becaus= e > "hashtable_seed" is initialized by current time while JsonLib is loaded. = So, > "hashtable_seed" > will be different in each individual UEFI driver. > > Signed-off-by: Nickle Wang > Cc: Abner Chang > Cc: Igor Kulchytskyy > Cc: Nick Ramirez > --- > RedfishPkg/Library/JsonLib/JsonLib.inf | 1 + > RedfishPkg/Library/JsonLib/JsonLib.c | 34 ++++++++++++++++++++++++++ > 2 files changed, 35 insertions(+) > > diff --git a/RedfishPkg/Library/JsonLib/JsonLib.inf > b/RedfishPkg/Library/JsonLib/JsonLib.inf > index 9d52a622e13a..b0d1bcac7cb3 100644 > --- a/RedfishPkg/Library/JsonLib/JsonLib.inf > +++ b/RedfishPkg/Library/JsonLib/JsonLib.inf > @@ -15,6 +15,7 @@ > MODULE_TYPE =3D DXE_DRIVER > VERSION_STRING =3D 1.0 > LIBRARY_CLASS =3D JsonLib|DXE_DRIVER UEFI_APPLICATION > UEFI_DRIVER > + CONSTRUCTOR =3D JsonLibConstructor > > # > # VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 RISCV64 > diff --git a/RedfishPkg/Library/JsonLib/JsonLib.c > b/RedfishPkg/Library/JsonLib/JsonLib.c > index 9b758b940293..a7ec2ab217a6 100644 > --- a/RedfishPkg/Library/JsonLib/JsonLib.c > +++ b/RedfishPkg/Library/JsonLib/JsonLib.c > @@ -19,6 +19,8 @@ > > #include "jansson.h" > > +extern volatile UINT32 hashtable_seed; > + > /** > The function is used to initialize a JSON value which contains a new J= SON array, > or NULL on error. Initially, the array is empty. > @@ -1138,3 +1140,35 @@ JsonGetType ( > { > return (EDKII_JSON_TYPE)(((json_t *)JsonValue)->type); } > + > +/** > + JSON Library constructor. > + > + @param ImageHandle The image handle. > + @param SystemTable The system table. > + > + @retval EFI_SUCCESS Protocol listener is registered successfully. > + > +**/ > +EFI_STATUS > +EFIAPI > +JsonLibConstructor ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + // > + // hashtable_seed is initalized by current time while JsonLib is loade= d. > + // Due to above mechanism, hashtable_seed will be different in each > +individual > + // UEFI driver. As the result, the hash of same key in different UEFI > +driver > + // would be different. This breaks JsonObjectGetValue() because > + // JsonObjectGetValue() won't be able to find corresponding JSON > +value if > + // this EDKII_JSON_VALUE is created by another UEFI driver. > + // > + // Initial the seed to a fixed magic value for JsonLib to be working > +in all > + // UEFI drivers. > + // > + hashtable_seed =3D 0xFDAE2143; > + > + return EFI_SUCCESS; > +} > -- > 2.17.1 > > -The information contained in this message may be confidential and propri= etary > to American Megatrends (AMI). This communication is intended to be read o= nly by > the individual or entity to whom it is addressed or by their designee. If= the reader > of this message is not the intended recipient, you are on notice that any > distribution of this message, in any form, is strictly prohibited. Please= promptly > notify the sender by reply e-mail or by telephone at 770-246-8600, and th= en > delete or destroy all copies of the transmission. -The information contained in this message may be confidential and propriet= ary to American Megatrends (AMI). This communication is intended to be read= only by the individual or entity to whom it is addressed or by their desig= nee. If the reader of this message is not the intended recipient, you are o= n notice that any distribution of this message, in any form, is strictly pr= ohibited. Please promptly notify the sender by reply e-mail or by telephone= at 770-246-8600, and then delete or destroy all copies of the transmission= . -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108917): https://edk2.groups.io/g/devel/message/108917 Mute This Topic: https://groups.io/mt/101432663/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-