<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/drivers/firmware/efi/capsule-loader.c, branch linux-6.5.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-6.5.y</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-6.5.y'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2022-09-07T16:23:56Z</updated>
<entry>
<title>efi: capsule-loader: Fix use-after-free in efi_capsule_write</title>
<updated>2022-09-07T16:23:56Z</updated>
<author>
<name>Hyunwoo Kim</name>
<email>imv4bel@gmail.com</email>
</author>
<published>2022-09-07T16:07:14Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=9cb636b5f6a8cc6d1b50809ec8f8d33ae0c84c95'/>
<id>urn:sha1:9cb636b5f6a8cc6d1b50809ec8f8d33ae0c84c95</id>
<content type='text'>
A race condition may occur if the user calls close() on another thread
during a write() operation on the device node of the efi capsule.

This is a race condition that occurs between the efi_capsule_write() and
efi_capsule_flush() functions of efi_capsule_fops, which ultimately
results in UAF.

So, the page freeing process is modified to be done in
efi_capsule_release() instead of efi_capsule_flush().

Cc: &lt;stable@vger.kernel.org&gt; # v4.9+
Signed-off-by: Hyunwoo Kim &lt;imv4bel@gmail.com&gt;
Link: https://lore.kernel.org/all/20220907102920.GA88602@ubuntu/
Signed-off-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
</content>
</entry>
<entry>
<title>efi/capsule-loader: Drop superfluous assignment</title>
<updated>2020-02-23T20:58:31Z</updated>
<author>
<name>Heinrich Schuchardt</name>
<email>xypron.glpk@gmx.de</email>
</author>
<published>2020-02-23T20:54:35Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=e0dc26c781fb69248add2b33549461cd780165b8'/>
<id>urn:sha1:e0dc26c781fb69248add2b33549461cd780165b8</id>
<content type='text'>
In efi_capsule_write() the value 0 assigned to ret is never used.

Identified with cppcheck.

Signed-off-by: Heinrich Schuchardt &lt;xypron.glpk@gmx.de&gt;
Link: https://lore.kernel.org/r/20200223205435.114915-1-xypron.glpk@gmx.de
Signed-off-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
</content>
</entry>
<entry>
<title>efi/capsule-loader: Explicitly include linux/io.h for page_to_phys()</title>
<updated>2019-12-10T09:15:48Z</updated>
<author>
<name>Sean Christopherson</name>
<email>sean.j.christopherson@intel.com</email>
</author>
<published>2019-11-26T16:54:11Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=c6625a314cb81149718390c6be01a9294a016966'/>
<id>urn:sha1:c6625a314cb81149718390c6be01a9294a016966</id>
<content type='text'>
Through a labyrinthian sequence of includes, usage of page_to_phys() is
dependent on the include of asm/io.h in x86's asm/realmode.h, which is
included in x86's asm/acpi.h and thus by linux/acpi.h.  Explicitly
include linux/io.h to break the dependency on realmode.h so that a
future patch can remove the realmode.h include from acpi.h without
breaking the build.

Signed-off-by: Sean Christopherson &lt;sean.j.christopherson@intel.com&gt;
Link: https://lkml.kernel.org/r/20191126165417.22423-7-sean.j.christopherson@intel.com
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</content>
</entry>
<entry>
<title>efi: Replace GPL license boilerplate with SPDX headers</title>
<updated>2019-02-04T07:27:25Z</updated>
<author>
<name>Ard Biesheuvel</name>
<email>ard.biesheuvel@linaro.org</email>
</author>
<published>2019-02-02T09:41:15Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=4febfb8dd08b6f8bafc19f3f9e382a477425b578'/>
<id>urn:sha1:4febfb8dd08b6f8bafc19f3f9e382a477425b578</id>
<content type='text'>
Replace all GPL license blurbs with an equivalent SPDX header (most
files are GPLv2, some are GPLv2+). While at it, drop some outdated
header changelogs as well.

Signed-off-by: Ard Biesheuvel &lt;ard.biesheuvel@linaro.org&gt;
Cc: AKASHI Takahiro &lt;takahiro.akashi@linaro.org&gt;
Cc: Alexander Graf &lt;agraf@suse.de&gt;
Cc: Bjorn Andersson &lt;bjorn.andersson@linaro.org&gt;
Cc: Borislav Petkov &lt;bp@alien8.de&gt;
Cc: Heinrich Schuchardt &lt;xypron.glpk@gmx.de&gt;
Cc: Jeffrey Hugo &lt;jhugo@codeaurora.org&gt;
Cc: Lee Jones &lt;lee.jones@linaro.org&gt;
Cc: Leif Lindholm &lt;leif.lindholm@linaro.org&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Matt Fleming &lt;matt@codeblueprint.co.uk&gt;
Cc: Peter Jones &lt;pjones@redhat.com&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Sai Praneeth Prakhya &lt;sai.praneeth.prakhya@intel.com&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20190202094119.13230-7-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</content>
</entry>
<entry>
<title>efi/capsule-loader: Don't output reset log when reset flags are not set</title>
<updated>2018-05-14T06:57:49Z</updated>
<author>
<name>Shunyong Yang</name>
<email>shunyong.yang@hxt-semitech.com</email>
</author>
<published>2018-05-04T06:00:02Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=83f0a7c7b265a56d757f7e3a80622e5b0b7ebc46'/>
<id>urn:sha1:83f0a7c7b265a56d757f7e3a80622e5b0b7ebc46</id>
<content type='text'>
When reset flags in capsule header are not set, it means firmware
attempts to immediately process or launch the capsule. Moreover, reset
is not needed in this case. The current code will output log to indicate
reset.

This patch adds a branch to avoid reset log output when the flags are not
set.

[ardb: use braces in multi-line 'if', clarify comment and commit log]
Signed-off-by: Shunyong Yang &lt;shunyong.yang@hxt-semitech.com&gt;
Signed-off-by: Ard Biesheuvel &lt;ard.biesheuvel@linaro.org&gt;
Cc: Joey Zheng &lt;yu.zheng@hxt-semitech.com&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Matt Fleming &lt;matt@codeblueprint.co.uk&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20180504060003.19618-17-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</content>
</entry>
<entry>
<title>efi/capsule-loader: Fix pr_err() string to end with newline</title>
<updated>2018-01-03T13:03:48Z</updated>
<author>
<name>Arvind Yadav</name>
<email>arvind.yadav.cs@gmail.com</email>
</author>
<published>2018-01-02T18:10:38Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=76ad9dffd91be11e51b847eb115d623b713a3bdc'/>
<id>urn:sha1:76ad9dffd91be11e51b847eb115d623b713a3bdc</id>
<content type='text'>
pr_err() messages should be terminated with a newline to avoid
other messages being concatenated onto the end.

Signed-off-by: Arvind Yadav &lt;arvind.yadav.cs@gmail.com&gt;
Signed-off-by: Matt Fleming &lt;matt@codeblueprint.co.uk&gt;
Signed-off-by: Ard Biesheuvel &lt;ard.biesheuvel@linaro.org&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Stephen Boyd &lt;sboyd@codeaurora.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Tyler Baicar &lt;tbaicar@codeaurora.org&gt;
Cc: Vasyl Gomonovych &lt;gomonovych@gmail.com&gt;
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20180102181042.19074-2-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</content>
</entry>
<entry>
<title>efi/capsule-loader: Reinstate virtual capsule mapping</title>
<updated>2018-01-03T12:54:31Z</updated>
<author>
<name>Ard Biesheuvel</name>
<email>ard.biesheuvel@linaro.org</email>
</author>
<published>2018-01-02T17:21:10Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=f24c4d478013d82bd1b943df566fff3561d52864'/>
<id>urn:sha1:f24c4d478013d82bd1b943df566fff3561d52864</id>
<content type='text'>
Commit:

  82c3768b8d68 ("efi/capsule-loader: Use a cached copy of the capsule header")

... refactored the capsule loading code that maps the capsule header,
to avoid having to map it several times.

However, as it turns out, the vmap() call we ended up removing did not
just map the header, but the entire capsule image, and dropping this
virtual mapping breaks capsules that are processed by the firmware
immediately (i.e., without a reboot).

Unfortunately, that change was part of a larger refactor that allowed
a quirk to be implemented for Quark, which has a non-standard memory
layout for capsules, and we have slightly painted ourselves into a
corner by allowing quirk code to mangle the capsule header and memory
layout.

So we need to fix this without breaking Quark. Fortunately, Quark does
not appear to care about the virtual mapping, and so we can simply
do a partial revert of commit:

  2a457fb31df6 ("efi/capsule-loader: Use page addresses rather than struct page pointers")

... and create a vmap() mapping of the entire capsule (including header)
based on the reinstated struct page array, unless running on Quark, in
which case we pass the capsule header copy as before.

Reported-by: Ge Song &lt;ge.song@hxt-semitech.com&gt;
Tested-by: Bryan O'Donoghue &lt;pure.logic@nexus-software.ie&gt;
Tested-by: Ge Song &lt;ge.song@hxt-semitech.com&gt;
Signed-off-by: Ard Biesheuvel &lt;ard.biesheuvel@linaro.org&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Cc: Dave Young &lt;dyoung@redhat.com&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Matt Fleming &lt;matt@codeblueprint.co.uk&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: linux-efi@vger.kernel.org
Fixes: 82c3768b8d68 ("efi/capsule-loader: Use a cached copy of the capsule header")
Link: http://lkml.kernel.org/r/20180102172110.17018-3-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</content>
</entry>
<entry>
<title>efi/capsule-loader: Use page addresses rather than struct page pointers</title>
<updated>2017-06-05T15:50:41Z</updated>
<author>
<name>Ard Biesheuvel</name>
<email>ard.biesheuvel@linaro.org</email>
</author>
<published>2017-06-02T13:52:03Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=2a457fb31df62c6b482f78e4f74aaed99271f44d'/>
<id>urn:sha1:2a457fb31df62c6b482f78e4f74aaed99271f44d</id>
<content type='text'>
To give some leeway to code that handles non-standard capsule headers,
let's keep an array of page addresses rather than struct page pointers.

This gives special implementations of efi_capsule_setup_info() the
opportunity to mangle the payload a bit before it is presented to the
firmware, without putting any knowledge of the nature of such quirks
into the generic code.

Tested-by: Bryan O'Donoghue &lt;pure.logic@nexus-software.ie&gt;
Signed-off-by: Ard Biesheuvel &lt;ard.biesheuvel@linaro.org&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Matt Fleming &lt;matt@codeblueprint.co.uk&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170602135207.21708-10-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</content>
</entry>
<entry>
<title>efi/capsule-loader: Redirect calls to efi_capsule_setup_info() via weak alias</title>
<updated>2017-06-05T15:50:41Z</updated>
<author>
<name>Ard Biesheuvel</name>
<email>ard.biesheuvel@linaro.org</email>
</author>
<published>2017-06-02T13:52:02Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=3fabd628d5ea24b02ddb1230ffca1df0f779f84e'/>
<id>urn:sha1:3fabd628d5ea24b02ddb1230ffca1df0f779f84e</id>
<content type='text'>
To allow platform specific code to hook into the capsule loading
routines, indirect calls to efi_capsule_setup_info() via a weak alias
of __efi_capsule_setup_info(), allowing platforms to redefine the former
but still use the latter.

Tested-by: Bryan O'Donoghue &lt;pure.logic@nexus-software.ie&gt;
Signed-off-by: Ard Biesheuvel &lt;ard.biesheuvel@linaro.org&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Matt Fleming &lt;matt@codeblueprint.co.uk&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170602135207.21708-9-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</content>
</entry>
<entry>
<title>efi/capsule: Remove NULL test on kmap()</title>
<updated>2017-06-05T15:50:40Z</updated>
<author>
<name>Fabian Frederick</name>
<email>fabf@skynet.be</email>
</author>
<published>2017-06-02T13:52:01Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=171fd0222957abe28e6d78de667f457376f45cf1'/>
<id>urn:sha1:171fd0222957abe28e6d78de667f457376f45cf1</id>
<content type='text'>
kmap() can't fail.

Signed-off-by: Fabian Frederick &lt;fabf@skynet.be&gt;
Signed-off-by: Matt Fleming &lt;matt@codeblueprint.co.uk&gt;
Signed-off-by: Ard Biesheuvel &lt;ard.biesheuvel@linaro.org&gt;
Cc: Kweh Hock Leong &lt;hock.leong.kweh@intel.com&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170602135207.21708-8-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</content>
</entry>
</feed>
