From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web10.5813.1683680053875255181 for ; Tue, 09 May 2023 17:54:13 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=bazu0tuG; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: zhichao.gao@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683680053; x=1715216053; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=uMf8PqWszF8KPvVaYXbHF3LaDi3Wo8CqzIbKjOXtZuI=; b=bazu0tuGT+5MwruCEdsSEtqxkz9FOKiGoPbNg1pZjGsdougJJGng4MdQ qsl7U0zXLYZYbGsJSN3rwukfv2ixxuTKlVKq6jDsGXsd4aM/vNYt8d90U P20+zXQMOonXHlb8NspHDeBh+mvP2SQz1yVx7Y46NhrVT885s1O/9G5Cy MkVyEMNSX6f9bLHUGimpWo5hD3ewa3iaDGQS6z7DskhzzPoL/Z8FBy9Nr pZpgboKqfVELLCkunQ7O63RT1+s5kFwnjmfipJgN5jAYK8TBj8BnH/Goy YoVzdxqugYF02pHzp+bcb490S2R9K+cXsxmyqpYvuX34SNoGpA0t8orPI g==; X-IronPort-AV: E=McAfee;i="6600,9927,10705"; a="330459480" X-IronPort-AV: E=Sophos;i="5.99,263,1677571200"; d="scan'208";a="330459480" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 17:54:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10705"; a="676661918" X-IronPort-AV: E=Sophos;i="5.99,263,1677571200"; d="scan'208";a="676661918" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga006.jf.intel.com with ESMTP; 09 May 2023 17:54:12 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 9 May 2023 17:54:12 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Tue, 9 May 2023 17:54:12 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.171) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Tue, 9 May 2023 17:54:12 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ElPN/dwnp6Vw1tuH2+LXU5rYLy9Rbr5LgmYG+FuT4ApOPGhJU44NTm0LiUhWRXnLWWd109dwaCF9/QMW3CdkCXHS+iAhGNlm0qQrc0+qcG3Y0V2GZBiPYcGzTupizMwNV5m4hQp8DaSNAv0Gft1tpUjP3oR6GklEweL76r36bcnVlyJrYEj3Kntjuu15pN6ZxNeEwemUhxIhcPSs2GxZ4dDOocPTC8M1OEwRq1ttY/5k9VWts2nVRyP5I+oi3ShKoSeogxkFvJrwtrEOzn5RZr0TZOT07QoPQTmaHwkW8mscdXT2mAeqDk37XzvGqmI4cQkQx2McZOPWIN64RiF8ug== 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=HhddDDEAJY2t4h6c4nZo6No+WoxRIdNKN4TMVWLaM2s=; b=NYQuK5ZflDP9T7JxAL7Cd0tg1EoCY8Ta6YnlTBF6H2jyE75Y/JnYvHGF1bEZJiZovH5CQQN3dbz/nMjKRs402OkDdhZP5Jyt5LXWt2xrRxap6jT60Dzj2eY/vtOrvErMjxuj7TYqJuX8VWuXRqR9FA3VzKF+/W7Om3NI6RWsARRhWC7sedCEvVACJ0M2RKcxnXNC1ahn1LqB+bP+5041ntj7cFav5nq0npiaVbDLnYf8jwrdYqrQCQzwuZO3JcZpqcrf7KTQtPHcg0Wa9Y4NPNkBDkBpWt9JHV1EbuWWQE1768TblxZA1PpOD8lnXbT/ju3UXDmm3qazDW61Y8GX8w== 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 Received: from PH7PR11MB6377.namprd11.prod.outlook.com (2603:10b6:510:1fb::13) by CH0PR11MB8168.namprd11.prod.outlook.com (2603:10b6:610:186::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Wed, 10 May 2023 00:54:10 +0000 Received: from PH7PR11MB6377.namprd11.prod.outlook.com ([fe80::c785:1a9a:411b:50f1]) by PH7PR11MB6377.namprd11.prod.outlook.com ([fe80::c785:1a9a:411b:50f1%6]) with mapi id 15.20.6363.032; Wed, 10 May 2023 00:54:09 +0000 From: "Gao, Zhichao" To: Gerd Hoffmann , "devel@edk2.groups.io" CC: "Ni, Ray" , Pawel Polawski , Oliver Steffen Subject: Re: [PATCH 1/1] ShellPkgDisconnect: zero-initialize handles Thread-Topic: [PATCH 1/1] ShellPkgDisconnect: zero-initialize handles Thread-Index: AQHZfnBkZWjwvg/O80G2xydxCDB5bK9StnSQ Date: Wed, 10 May 2023 00:54:09 +0000 Message-ID: References: <20230426113927.287438-1-kraxel@redhat.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH7PR11MB6377:EE_|CH0PR11MB8168:EE_ x-ms-office365-filtering-correlation-id: 73b00103-6be1-42f5-cbb0-08db50f11063 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: jb0vj6A8dWe1rNV5KfvdgXWOSYBrF+1cve91dqyFlqUpsP/nNADlFUA5qM4ELo768zEBiu0JxXnCbUHnpoSOCFcZLtet6meU6/lQjlhH5OJ+ksoEeHrDAfMuNq9WWZe+WddhxUZ6lQJBbgtxU+id4tH1WWfpYBQ+i7AHhv1pn6C83iQ+ipnnZq9iSrc3XF68fFIYSQFxLcPNxiKkQGUHBQyomd6YNRvKcfzzPk0sqp2pSZiI83CMor0t50xdi25iiO+eBDNDS+IwzvEQAx5QhwXrKPpXuHsEk5gXdRl1wi6uoCqhoSWtjFlsAnrRbHgPd/6AzL3FLq/0OYuE0abG85mIz/kvp3fcjnDUI+wEKBQPIuhqTyHrZUNvkrfc7CmkzRdzq0z75n2Gna3xej2TuCadmBan5udoiPW/e/t/8ONP0wYkfNbvbLLQl+qfagk48jgYqTOtKQLkDgjyY7Dkgt0LOGc4QS7FKmdjGGbmYl6ySen3pI7hYvQFz+uUXlkseftg3nGZEpuzguZyvsQCdhM/hElWgGWTuEr37ATLOv36/5C13xP2kw2EIg4PybuzM6Nl+DoMsecLGvqcT4Dok/K9psAEXkqJC3eAsA26UM9bltYtQif9iHKlNH6EwEPA x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR11MB6377.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(396003)(376002)(366004)(136003)(451199021)(9686003)(122000001)(6506007)(38100700002)(82960400001)(76116006)(66556008)(19627235002)(66946007)(86362001)(55016003)(33656002)(2906002)(4326008)(8676002)(53546011)(316002)(52536014)(66476007)(54906003)(5660300002)(8936002)(64756008)(110136005)(66446008)(41300700001)(478600001)(83380400001)(38070700005)(7696005)(71200400001)(186003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?wwpn9dCpO9HVA+SnEthtB/UXu5OYz8ipROQkUYkaEunpypFqUQ+sj+Lmbl+5?= =?us-ascii?Q?7ddUtn2gJ1Is60y4tZ1Rr38jR3/POqyH7QVCdX/x+V/pG7XJg0OWfV9RBOfj?= =?us-ascii?Q?OIIjCQqqDkZPcYPshgVktOgs/rUTU+q6XHRI/w/mnHSHD9tjjzLwiijqQs89?= =?us-ascii?Q?HFCTChw0qFIcoLolyR5dfkUF1B3BObs6fM5GzbtdcMhiIH1GEN2zO3zp0xZ5?= =?us-ascii?Q?t7TUu7PS47RKCZvvMjDairI01bfLJmfrfS2SvWHlLJn7Gn0xwjw+rX3AaWW1?= =?us-ascii?Q?SYWFS1djv37RCz4TMDm+GHPEdplb7j4NXePWQ+k6zTxbFqZ2o2wdr3fkxeBv?= =?us-ascii?Q?fW/uyD1OSWivgW1HaFwrT8Ik0sR8FQnZO4MKPSVy55BTaWtcaouRuyGWxLqS?= =?us-ascii?Q?uo+LHq0zCKWT2vu//8d/TI19u/AHsrklyIhsNUR2awccyTlnIql6KFKFsjU8?= =?us-ascii?Q?SfyisvDfBfpb84C1BwFmRr52ceRqC63H7lWv4Sy/I6/W5xQjT05Xh+B1wDyi?= =?us-ascii?Q?UoiFXcVWIsUHCgFN+aSxfK4bU+XOGxFhN3GUOWfuDY3DSlHnxL91ZWQtCjZ9?= =?us-ascii?Q?qp3H6z5y7oJIIVnyzNYviwBmA3S2/HPzJqevBXPRo6zAJRvn6VP9YMiLM8Sy?= =?us-ascii?Q?3h2M5RjAQtcazLQk6vzdXRbOyeabvnINifq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gFtx5DMOyb4mpOus=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH7PR11MB6377.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73b00103-6be1-42f5-cbb0-08db50f11063 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 May 2023 00:54:09.5142 (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: gJWi0R780A+veV2Tvrliua3xcHQaI6Sncv9iQDG2LBT1y3kJDgTISwo7nxSUY3rmKEqVM9Qk33e1XxIIePq9MA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR11MB8168 Return-Path: zhichao.gao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Zhichao Gao Thanks, Zhichao > -----Original Message----- > From: Gerd Hoffmann > Sent: Thursday, May 4, 2023 6:08 PM > To: devel@edk2.groups.io > Cc: Ni, Ray ; Pawel Polawski ; > Oliver Steffen ; Gao, Zhichao > > Subject: Re: [PATCH 1/1] ShellPkgDisconnect: zero-initialize handles >=20 > Ping. > Any comments on this? >=20 > On Wed, Apr 26, 2023 at 01:39:27PM +0200, Gerd Hoffmann wrote: > > In case ShellConvertStringToUint64() fails the Handles are left > > uninitialized. That can for example happen for Handle2 and Handle3 in > > case only one parameter was specified on the command line. Which can > > trigger the ASSERT() in line 185. > > > > Reproducer: boot ovmf to efi shell in qemu, using q35 machine type, > > then try disconnect the sata controller in efi shell. > > > > Fix that by explicitly setting them to NULL in that case. While being > > at it also simplify the logic and avoid pointlessly calling > > ShellConvertStringToUint64() in case ParamN is NULL. > > > > Signed-off-by: Gerd Hoffmann > > --- > > .../UefiShellDriver1CommandsLib/Disconnect.c | 19 > > +++++++++++++------ > > 1 file changed, 13 insertions(+), 6 deletions(-) > > > > diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c > > b/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c > > index fd49d1f7ceb4..fac6463e3c28 100644 > > --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c > > +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c > > @@ -160,16 +160,23 @@ ShellCommandRunDisconnect ( > > Param1 =3D ShellCommandLineGetRawValue (Package, 1); > > Param2 =3D ShellCommandLineGetRawValue (Package, 2); > > Param3 =3D ShellCommandLineGetRawValue (Package, 3); > > - if (!EFI_ERROR (ShellConvertStringToUint64 (Param1, &Intermedi= ate1, > TRUE, FALSE))) { > > - Handle1 =3D Param1 !=3D NULL ? ConvertHandleIndexToHandle > ((UINTN)Intermediate1) : NULL; > > + > > + if (Param1 && !EFI_ERROR (ShellConvertStringToUint64 (Param1, > &Intermediate1, TRUE, FALSE))) { > > + Handle1 =3D ConvertHandleIndexToHandle ((UINTN)Intermediate1= ); > > + } else { > > + Handle1 =3D NULL; > > } > > > > - if (!EFI_ERROR (ShellConvertStringToUint64 (Param2, &Intermedi= ate2, > TRUE, FALSE))) { > > - Handle2 =3D Param2 !=3D NULL ? ConvertHandleIndexToHandle > ((UINTN)Intermediate2) : NULL; > > + if (Param2 && !EFI_ERROR (ShellConvertStringToUint64 (Param2, > &Intermediate2, TRUE, FALSE))) { > > + Handle2 =3D ConvertHandleIndexToHandle ((UINTN)Intermediate2= ); > > + } else { > > + Handle2 =3D NULL; > > } > > > > - if (!EFI_ERROR (ShellConvertStringToUint64 (Param3, &Intermedi= ate3, > TRUE, FALSE))) { > > - Handle3 =3D Param3 !=3D NULL ? ConvertHandleIndexToHandle > ((UINTN)Intermediate3) : NULL; > > + if (Param3 && !EFI_ERROR (ShellConvertStringToUint64 (Param3, > &Intermediate3, TRUE, FALSE))) { > > + Handle3 =3D ConvertHandleIndexToHandle ((UINTN)Intermediate3= ); > > + } else { > > + Handle3 =3D NULL; > > } > > > > if ((Param1 !=3D NULL) && (Handle1 =3D=3D NULL)) { > > -- > > 2.40.0 > > >=20 > --