public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ardb@kernel.org>
To: "Kinney, Michael D" <michael.d.kinney@intel.com>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Ni, Ray" <ray.ni@intel.com>,
	 "Gao, Zhichao" <zhichao.gao@intel.com>
Subject: Re: [edk2-devel] [PATCH] ShellPkg: Avoid corrupting installed device path protocols
Date: Thu, 8 Dec 2022 23:37:22 +0100	[thread overview]
Message-ID: <CAMj1kXEPahV7-+v3-7oT9C=n0ZggZZ9-VJf3+dS34d6iUXRhRA@mail.gmail.com> (raw)
In-Reply-To: <CAMj1kXGciheWNiz60WVhqiT1pcBr5d2mYYF+4L3vvph=8zLfBA@mail.gmail.com>

On Thu, 8 Dec 2022 at 23:35, Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Thu, 8 Dec 2022 at 22:57, Kinney, Michael D
> <michael.d.kinney@intel.com> wrote:
> >
> > Ard,
> >
> > Thank you for the correction.
> >
> > If we add that CONST, then the ShellPkg build breaks with an error
> >
> > c:\work\github\tianocore\edk2\ShellPkg\Application\Shell\ShellProtocol.c(297): error C2220: the following warning is treated as an error
> > c:\work\github\tianocore\edk2\ShellPkg\Application\Shell\ShellProtocol.c(297): warning C4090: 'function': different 'const' qualifiers
> >
> > Which is exactly the line we want to remove to prevent the destructive behavior.
> >
> >     SetDevicePathEndNode (*DevicePath);
> >
> > If I comment out that line, the ShellPkg build completes with no errors.
> >
>
> I'm surprised that this is the only offending line, and I suppose that
> is good news.
>
> But as you said, the shell protocol is used much more widely, and
> existing callers may rely on the destructive behavior.
>
> At the very least, we should only perform the SetDevicePathEndNode()
> call if the node in question is not already an
> end-of-entire-devicepath node, as the update is pointless in that
> case, but will still trigger a fault if the memory is read-only.
>
> But it really depends on whether any callers might exist that expect a
> multi-instance devicepath to be split up.
>
> > I agree that it would be better to update the prototype and get help
> > from the compiler to find incorrect implementations.  Even though
> > CONST is not in the prototype, from reading the description of the API
> > it does not state that the contents are modified, so I think the
> > intent was no modifications.
> >
>
> Agreed.
> > Your suggested change is safe, but it is incomplete because there
> > are additional calls through the protocol that are not covered
> > by your patch.  We also do not know how many places this API
> > is used in downstream projects.  This side effect of a write to
> > a read-only page and potential corruption of a multi-instance
> > device path looks like a bug to me and we should fix the root
> > cause and not fix just some of the callers.
> >
>
> OK, so what is the way forward here?
>

I sent this before I noticed your other reply.

So let's go with your fix to preserve the existing behavior without
triggering the fault.

      reply	other threads:[~2022-12-08 22:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 16:12 [PATCH] ShellPkg: Avoid corrupting installed device path protocols Ard Biesheuvel
2022-12-08 16:51 ` [edk2-devel] " Michael D Kinney
2022-12-08 17:22   ` Ard Biesheuvel
2022-12-08 18:28     ` Michael D Kinney
2022-12-08 18:44       ` Ard Biesheuvel
2022-12-08 19:19         ` Michael D Kinney
2022-12-08 20:12           ` Ard Biesheuvel
2022-12-08 21:15             ` Michael D Kinney
2022-12-08 21:39               ` Ard Biesheuvel
2022-12-08 21:57                 ` Michael D Kinney
2022-12-08 22:18                   ` Michael D Kinney
2022-12-08 22:35                   ` Ard Biesheuvel
2022-12-08 22:37                     ` Ard Biesheuvel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMj1kXEPahV7-+v3-7oT9C=n0ZggZZ9-VJf3+dS34d6iUXRhRA@mail.gmail.com' \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox