* [Patch 1/1] ShellPkg/Shell: Do not set end device path if already end @ 2022-12-09 15:59 Michael D Kinney 2022-12-09 17:44 ` Ard Biesheuvel 0 siblings, 1 reply; 4+ messages in thread From: Michael D Kinney @ 2022-12-09 15:59 UTC (permalink / raw) To: devel; +Cc: Ard Biesheuvel, Ray Ni, Zhichao Gao Update Shell Protocol EfiShellGetMapFromDevicePath() to not set the end if the device path if it is already an end of entire device path. This removes a write oprtation that can cause failures if the Device Path Protocol is mapped to read-only memory. In general Device Path Protocols should not be modified unless the API explicitly states that the device path is modified. Cc: Ard Biesheuvel <ardb@kernel.org> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> --- ShellPkg/Application/Shell/ShellProtocol.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index 509eb60e40f4..e6d20ab16479 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -294,7 +294,13 @@ EfiShellGetMapFromDevicePath ( *DevicePath = NextDevicePathNode (*DevicePath); } - SetDevicePathEndNode (*DevicePath); + // + // Do not call SetDevicePathEndNode() if the device path node is already the + // end of an entire device path. + // + if (!IsDevicePathEnd (*DevicePath)) { + SetDevicePathEndNode (*DevicePath); + } } /* -- 2.37.1.windows.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Patch 1/1] ShellPkg/Shell: Do not set end device path if already end 2022-12-09 15:59 [Patch 1/1] ShellPkg/Shell: Do not set end device path if already end Michael D Kinney @ 2022-12-09 17:44 ` Ard Biesheuvel 2022-12-12 7:16 ` Gao, Zhichao 0 siblings, 1 reply; 4+ messages in thread From: Ard Biesheuvel @ 2022-12-09 17:44 UTC (permalink / raw) To: Michael D Kinney; +Cc: devel, Ray Ni, Zhichao Gao On Fri, 9 Dec 2022 at 17:00, Michael D Kinney <michael.d.kinney@intel.com> wrote: > > Update Shell Protocol EfiShellGetMapFromDevicePath() to not > set the end if the device path if it is already an end of > entire device path. This removes a write oprtation that can > cause failures if the Device Path Protocol is mapped to > read-only memory. In general Device Path Protocols should not > be modified unless the API explicitly states that the device > path is modified. > > Cc: Ard Biesheuvel <ardb@kernel.org> > Cc: Ray Ni <ray.ni@intel.com> > Cc: Zhichao Gao <zhichao.gao@intel.com> > Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org> > --- > ShellPkg/Application/Shell/ShellProtocol.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c > index 509eb60e40f4..e6d20ab16479 100644 > --- a/ShellPkg/Application/Shell/ShellProtocol.c > +++ b/ShellPkg/Application/Shell/ShellProtocol.c > @@ -294,7 +294,13 @@ EfiShellGetMapFromDevicePath ( > *DevicePath = NextDevicePathNode (*DevicePath); > } > > - SetDevicePathEndNode (*DevicePath); > + // > + // Do not call SetDevicePathEndNode() if the device path node is already the > + // end of an entire device path. > + // > + if (!IsDevicePathEnd (*DevicePath)) { > + SetDevicePathEndNode (*DevicePath); > + } > } > > /* > -- > 2.37.1.windows.1 > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch 1/1] ShellPkg/Shell: Do not set end device path if already end 2022-12-09 17:44 ` Ard Biesheuvel @ 2022-12-12 7:16 ` Gao, Zhichao 2022-12-13 21:22 ` Michael D Kinney 0 siblings, 1 reply; 4+ messages in thread From: Gao, Zhichao @ 2022-12-12 7:16 UTC (permalink / raw) To: Ard Biesheuvel, Kinney, Michael D; +Cc: devel@edk2.groups.io, Ni, Ray Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Thanks, Zhichao > -----Original Message----- > From: Ard Biesheuvel <ardb@kernel.org> > Sent: Saturday, December 10, 2022 1:44 AM > To: Kinney, Michael D <michael.d.kinney@intel.com> > Cc: devel@edk2.groups.io; Ni, Ray <ray.ni@intel.com>; Gao, Zhichao > <zhichao.gao@intel.com> > Subject: Re: [Patch 1/1] ShellPkg/Shell: Do not set end device path if already > end > > On Fri, 9 Dec 2022 at 17:00, Michael D Kinney <michael.d.kinney@intel.com> > wrote: > > > > Update Shell Protocol EfiShellGetMapFromDevicePath() to not set the > > end if the device path if it is already an end of entire device path. > > This removes a write oprtation that can cause failures if the Device > > Path Protocol is mapped to read-only memory. In general Device Path > > Protocols should not be modified unless the API explicitly states that > > the device path is modified. > > > > Cc: Ard Biesheuvel <ardb@kernel.org> > > Cc: Ray Ni <ray.ni@intel.com> > > Cc: Zhichao Gao <zhichao.gao@intel.com> > > Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> > > Reviewed-by: Ard Biesheuvel <ardb@kernel.org> > > > --- > > ShellPkg/Application/Shell/ShellProtocol.c | 8 +++++++- > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > diff --git a/ShellPkg/Application/Shell/ShellProtocol.c > > b/ShellPkg/Application/Shell/ShellProtocol.c > > index 509eb60e40f4..e6d20ab16479 100644 > > --- a/ShellPkg/Application/Shell/ShellProtocol.c > > +++ b/ShellPkg/Application/Shell/ShellProtocol.c > > @@ -294,7 +294,13 @@ EfiShellGetMapFromDevicePath ( > > *DevicePath = NextDevicePathNode (*DevicePath); > > } > > > > - SetDevicePathEndNode (*DevicePath); > > + // > > + // Do not call SetDevicePathEndNode() if the device path node is > already the > > + // end of an entire device path. > > + // > > + if (!IsDevicePathEnd (*DevicePath)) { > > + SetDevicePathEndNode (*DevicePath); > > + } > > } > > > > /* > > -- > > 2.37.1.windows.1 > > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch 1/1] ShellPkg/Shell: Do not set end device path if already end 2022-12-12 7:16 ` Gao, Zhichao @ 2022-12-13 21:22 ` Michael D Kinney 0 siblings, 0 replies; 4+ messages in thread From: Michael D Kinney @ 2022-12-13 21:22 UTC (permalink / raw) To: Gao, Zhichao, Ard Biesheuvel, Kinney, Michael D Cc: devel@edk2.groups.io, Ni, Ray Merged: https://github.com/tianocore/edk2/pull/3744 Commit: https://github.com/tianocore/edk2/commit/592bf33a29360e8a447ed8b75daefe94c0888642 Mike > -----Original Message----- > From: Gao, Zhichao <zhichao.gao@intel.com> > Sent: Sunday, December 11, 2022 11:17 PM > To: Ard Biesheuvel <ardb@kernel.org>; Kinney, Michael D <michael.d.kinney@intel.com> > Cc: devel@edk2.groups.io; Ni, Ray <ray.ni@intel.com> > Subject: RE: [Patch 1/1] ShellPkg/Shell: Do not set end device path if already end > > Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> > > Thanks, > Zhichao > > > -----Original Message----- > > From: Ard Biesheuvel <ardb@kernel.org> > > Sent: Saturday, December 10, 2022 1:44 AM > > To: Kinney, Michael D <michael.d.kinney@intel.com> > > Cc: devel@edk2.groups.io; Ni, Ray <ray.ni@intel.com>; Gao, Zhichao > > <zhichao.gao@intel.com> > > Subject: Re: [Patch 1/1] ShellPkg/Shell: Do not set end device path if already > > end > > > > On Fri, 9 Dec 2022 at 17:00, Michael D Kinney <michael.d.kinney@intel.com> > > wrote: > > > > > > Update Shell Protocol EfiShellGetMapFromDevicePath() to not set the > > > end if the device path if it is already an end of entire device path. > > > This removes a write oprtation that can cause failures if the Device > > > Path Protocol is mapped to read-only memory. In general Device Path > > > Protocols should not be modified unless the API explicitly states that > > > the device path is modified. > > > > > > Cc: Ard Biesheuvel <ardb@kernel.org> > > > Cc: Ray Ni <ray.ni@intel.com> > > > Cc: Zhichao Gao <zhichao.gao@intel.com> > > > Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> > > > > Reviewed-by: Ard Biesheuvel <ardb@kernel.org> > > > > > --- > > > ShellPkg/Application/Shell/ShellProtocol.c | 8 +++++++- > > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > > > diff --git a/ShellPkg/Application/Shell/ShellProtocol.c > > > b/ShellPkg/Application/Shell/ShellProtocol.c > > > index 509eb60e40f4..e6d20ab16479 100644 > > > --- a/ShellPkg/Application/Shell/ShellProtocol.c > > > +++ b/ShellPkg/Application/Shell/ShellProtocol.c > > > @@ -294,7 +294,13 @@ EfiShellGetMapFromDevicePath ( > > > *DevicePath = NextDevicePathNode (*DevicePath); > > > } > > > > > > - SetDevicePathEndNode (*DevicePath); > > > + // > > > + // Do not call SetDevicePathEndNode() if the device path node is > > already the > > > + // end of an entire device path. > > > + // > > > + if (!IsDevicePathEnd (*DevicePath)) { > > > + SetDevicePathEndNode (*DevicePath); > > > + } > > > } > > > > > > /* > > > -- > > > 2.37.1.windows.1 > > > ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-12-13 21:22 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-12-09 15:59 [Patch 1/1] ShellPkg/Shell: Do not set end device path if already end Michael D Kinney 2022-12-09 17:44 ` Ard Biesheuvel 2022-12-12 7:16 ` Gao, Zhichao 2022-12-13 21:22 ` Michael D Kinney
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox