Skip to content

Commit f280b98

Browse files
committed
Merge tag 'efi-urgent-for-v6.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi
Pull EFI fixes from Ard Biesheuvel: "A couple of low-priority EFI fixes: - prevent the randstruct plugin from re-ordering EFI protocol definitions - fix a use-after-free in the capsule loader - drop unused variable" * tag 'efi-urgent-for-v6.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi: efi: capsule-loader: Fix use-after-free in efi_capsule_write efi/x86: libstub: remove unused variable efi: libstub: Disable struct randomization
2 parents 0066f1b + 9cb636b commit f280b98

File tree

3 files changed

+14
-25
lines changed

3 files changed

+14
-25
lines changed

drivers/firmware/efi/capsule-loader.c

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -242,29 +242,6 @@ static ssize_t efi_capsule_write(struct file *file, const char __user *buff,
242242
return ret;
243243
}
244244

245-
/**
246-
* efi_capsule_flush - called by file close or file flush
247-
* @file: file pointer
248-
* @id: not used
249-
*
250-
* If a capsule is being partially uploaded then calling this function
251-
* will be treated as upload termination and will free those completed
252-
* buffer pages and -ECANCELED will be returned.
253-
**/
254-
static int efi_capsule_flush(struct file *file, fl_owner_t id)
255-
{
256-
int ret = 0;
257-
struct capsule_info *cap_info = file->private_data;
258-
259-
if (cap_info->index > 0) {
260-
pr_err("capsule upload not complete\n");
261-
efi_free_all_buff_pages(cap_info);
262-
ret = -ECANCELED;
263-
}
264-
265-
return ret;
266-
}
267-
268245
/**
269246
* efi_capsule_release - called by file close
270247
* @inode: not used
@@ -277,6 +254,13 @@ static int efi_capsule_release(struct inode *inode, struct file *file)
277254
{
278255
struct capsule_info *cap_info = file->private_data;
279256

257+
if (cap_info->index > 0 &&
258+
(cap_info->header.headersize == 0 ||
259+
cap_info->count < cap_info->total_size)) {
260+
pr_err("capsule upload not complete\n");
261+
efi_free_all_buff_pages(cap_info);
262+
}
263+
280264
kfree(cap_info->pages);
281265
kfree(cap_info->phys);
282266
kfree(file->private_data);
@@ -324,7 +308,6 @@ static const struct file_operations efi_capsule_fops = {
324308
.owner = THIS_MODULE,
325309
.open = efi_capsule_open,
326310
.write = efi_capsule_write,
327-
.flush = efi_capsule_flush,
328311
.release = efi_capsule_release,
329312
.llseek = no_llseek,
330313
};

drivers/firmware/efi/libstub/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ KBUILD_CFLAGS := $(cflags-y) -Os -DDISABLE_BRANCH_PROFILING \
3737
$(call cc-option,-fno-addrsig) \
3838
-D__DISABLE_EXPORTS
3939

40+
#
41+
# struct randomization only makes sense for Linux internal types, which the EFI
42+
# stub code never touches, so let's turn off struct randomization for the stub
43+
# altogether
44+
#
45+
KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS), $(KBUILD_CFLAGS))
46+
4047
# remove SCS flags from all objects in this directory
4148
KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS))
4249
# disable LTO

drivers/firmware/efi/libstub/x86-stub.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ adjust_memory_range_protection(unsigned long start, unsigned long size)
220220
unsigned long end, next;
221221
unsigned long rounded_start, rounded_end;
222222
unsigned long unprotect_start, unprotect_size;
223-
int has_system_memory = 0;
224223

225224
if (efi_dxe_table == NULL)
226225
return;

0 commit comments

Comments
 (0)