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 9E278AC0CB6 for ; Wed, 20 Sep 2023 09:17:52 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=xXmyH25S6OaM3LrrjWf01Ufd7NDPdT+NmV6By/4aKfs=; 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=1695201471; v=1; b=iA6Bf71EzSZD/Zoih1vCgNZj2Go2/E3XLwbFrTBbI48pv8l/SvBFLYlqbeM+J6l+v0R07Hk9 NLWaBH7Yi4U1K4nhZ8JZFIELrBQh80HDlyxtCW5mVgz+Ex4KWzVhH+3vqk4TrZHHuI22WMk5gBb cC/DUnSlUEJB3fdlibK+QWug= X-Received: by 127.0.0.2 with SMTP id dxs5YY7687511xbBM5J0XnQA; Wed, 20 Sep 2023 02:17:51 -0700 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.59]) by mx.groups.io with SMTP id smtpd.web11.33396.1695201470619529293 for ; Wed, 20 Sep 2023 02:17:50 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CPGhDDMnqlPqTQEnInQBxRm/zdm1s+ZDs6Kd9jtrpaJ8wz8uI6nHLRrUY7ZfHKb/ASyS+4Y3yto0BPMXwEfTt8RQuuBfXP8JfCEX7vm34o87ddBEfV2HFE9gmvBhOkimN2l4R8x/aqPt4ZA7vZMZn/k4zP19a2x6h7pwyN4hqAbIeg4By0WfArSzIy1vSxS0qKF65aZNpFxdrdbLz0q3X5FhIhh4rV2fVrHXXvorXj8t5l2jbNz8EsI5XvwKy1jRLIvuFhoRyhi8fT5by/Zz1yHNggPXtCnYNOD8C1MPw9KhxZ3ABWZqfyjunPqHwF1XJTkDJO+n3qg3/KaLt5ey0g== 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=gejVdmTSAvGGBM9SBC7qPmA9RtCsOcdwsTk0981QUnw=; b=MhIbEKRVob/eu/uYX5LsUo2HGH1GeE4TlOe/dsZMcYH5EiblzGcG2moJS1aoOxjEQ51bDMyuXpKc77ptg0ay9oHSFjUTaw4e+xXcO8V6N77Rzb/jHOP+shGh2g/4bwhOwc2skR0Rd99jTdEFC8nstP85GAnh3x9zCJBAxhqsknJh9MP/hx9Ze8wHz2YOeQXwbcVYjEjkEE1iQArU7u0mLChn9Vu/mUy+dnAttLXV3qO2ZrmFbEno9v0owX6KNPRVMlP5sUQONMX+eHZxXX76Il9YiDP5r7ZRbL5lsZJ1zS0h5J5M9Yb4J63LP3+X0ON2WQnAvVaVe4UxXnuiPpGMZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none X-Received: from MW4PR12MB7031.namprd12.prod.outlook.com (2603:10b6:303:1ef::6) by PH7PR12MB5830.namprd12.prod.outlook.com (2603:10b6:510:1d5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.36; Wed, 20 Sep 2023 09:17:46 +0000 X-Received: from MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::f345:babc:2bc5:bfae]) by MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::f345:babc:2bc5:bfae%4]) with mapi id 15.20.6813.018; Wed, 20 Sep 2023 09:17:46 +0000 From: "Nickle Wang via groups.io" To: Igor Kulchytskyy , "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/sgrAglszQgALYWaA= Date: Wed, 20 Sep 2023 09:17:46 +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: MW4PR12MB7031:EE_|PH7PR12MB5830:EE_ x-ms-office365-filtering-correlation-id: faaf2665-9ae9-4fc4-7bf2-08dbb9ba741c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: lG4GRHMoKlYbfBYOndDefORBsMjTAmnX2LdsfHQq7X6l6jCHgmJFaUP8hNixqzT0xvVHRjMd3EBJKLyU0zU8sMEOs9zTD10WDwp/wQ+7JvQDoFhuzYJCOwx3tKCKHJ1t9FnhZKOH0Wf7qnNqFL9yUQuw8CPazyppZELYXW6JsH77l7ZJyZfHvGTlAul1daTZaXhrSp6oWIpEGPWEMR6PUdeOzgUwuLayxR31we6q1JgJ4zPUwIloXgn3YFNfJq68yu4s8Sw6+Rk7dUNDlheVtGYPuHv+8aYsUw/96NwtRd++9kKldOJqUhgaTC5QsqM8sMdrH4oT7daMlosXAzPz20DENrJSstlrMbYDQvG56bxiwMYJ7rWVogQd2WAqN/Nilqgxhak8Uyxv/NMqBFbsK9yodWOX6IO1mALiBALtRfqUElqXqEaHr8g5ayCmR1m7a0NftAgeTUvY4gds4FcBQnxbmEMnh2V52t16Eqys/oMciaDBSvV3KOWKLYmPHgPVGiVi4lITzE49bNj5ZxcNyw1GKxa/atj5RJkcVwgvVrtKRJ0fhw+yJkgkwWF77qy25JjtJjRCmWJ7/SwQ5lEunwSyUKYs20pLSfjm2p/WjuogiOSQGXUQ+MXkx9t+sCAt x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?cidUI6fSI98Qt8oNO1LEEPe9c2E7o0FprX1rCo8lX98M2orLdmhLurrQ2C60?= =?us-ascii?Q?TfpIdCg1mvrZ8A9hMlzp1hs1ybqvD08mwgz4QwxMgnRLQDQ2yxIUsWXT7hxn?= =?us-ascii?Q?T5G6o7T1bY21FOdiNdx6o6jNZoNI29snt3fwtUmjuXTSTzuIcsCq02hafuaH?= =?us-ascii?Q?VBFBnIp+xM0IJOBPC8Q6k08v2EoackxzUlf143o3wKR4I9Ic/lRnevf0KR7Z?= =?us-ascii?Q?eqh7/+KpUfMTQ3YjlPeXptfpHXBmjTZVYN4zyJmx/3nQe4LanNXvUs48nF79?= =?us-ascii?Q?Jw6xF5+gogXtfwGTxvJ7dauk05kkQ1KYtVV3YH8nE1HP2DuJyoRi5TMqz5MR?= =?us-ascii?Q?d2ggQ4ekJIm4elDsWVTsHAxt3tl2O1cCrj8F0mmqajzFHzAkcruAUB40X86i?= =?us-ascii?Q?dnUm6Gs+hq9DzHtXdMSLzOBz3RVpBkwqm8PMilQO/FQ61NcbDaet1hrmi5Pd?= =?us-ascii?Q?NX3etVHdtPXsmoXR1sOdjVKzfk3Ju0CkMJJ75qCqyGVgXyRjoDPU1YmKWecz?= =?us-ascii?Q?Y4Td4Q2SoIRJlZSQjrGl5a4HuTJVTW2pYEN4hKiwddAaA5dg5dHvHBAZaPOq?= =?us-ascii?Q?V8SiX25cUAqrFRDk/qbX6RFMLu87C1X713wpyHn76LVQ44XzA4He4rKpt8Gq?= =?us-ascii?Q?2MoiOmndQj5aNX1+RDNTmhagE+XiOZl/x+k/iW9I6wzVH2Op0zV9bScFfzO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3D?= MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR12MB7031.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: faaf2665-9ae9-4fc4-7bf2-08dbb9ba741c X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Sep 2023 09:17:46.5614 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: qhlwDXM95JxIvZmMRnfQ5LU77bvQTbU+cv17QHmVcSs/mmBd7PVRznaUHMfddKKU/ZQUvSMaamrokTE8eD9oxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5830 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,nicklew@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: BlbiKiKCfArtJq96YOfEazCux7686176AA= 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=iA6Bf71E; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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 >=20 > External email: Use caution opening links or attachments >=20 >=20 > 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 >=20 > -----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 >=20 >=20 > **CAUTION: The e-mail below is from an external source. Please exercise > caution before opening attachments, clicking links, or following guidance= .** >=20 > 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. >=20 > 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(+) >=20 > 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 >=20 > # > # 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 @@ >=20 > #include "jansson.h" >=20 > +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 >=20 > -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. -=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 (#108904): https://edk2.groups.io/g/devel/message/108904 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-