OSDN Git Service

android-x86/external-efivar.git
5 years agoGive linux-*'s ->parse() functions the unmodified device link as well
Peter Jones [Wed, 20 Jun 2018 18:37:14 +0000 (14:37 -0400)]
Give linux-*'s ->parse() functions the unmodified device link as well

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoImprove ACPI device path formatting
Peter Jones [Wed, 20 Jun 2018 18:27:11 +0000 (14:27 -0400)]
Improve ACPI device path formatting

This factors a bunch of the duplication out to another function, which
also does a better job of it.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoFix a makeguids building problem with generics.h.
Peter Jones [Wed, 20 Jun 2018 18:12:42 +0000 (14:12 -0400)]
Fix a makeguids building problem with generics.h.

Guard generics.h with EFIVAR_BUILD_ENVIRONMENT to keep it from
interfering with the makeguids build if libefivar.so isn't around
already.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMake path-helpers.c also import fix_coverity.h
Peter Jones [Thu, 14 Jun 2018 16:15:03 +0000 (12:15 -0400)]
Make path-helpers.c also import fix_coverity.h

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMake efidp_make_file() have even more, better input constraints.
Peter Jones [Wed, 13 Jun 2018 13:25:58 +0000 (09:25 -0400)]
Make efidp_make_file() have even more, better input constraints.

This is all in the effort to convince coverity that it doesn't
dereference buf when size==0, which it already doesn't.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoTry to convince covscan that sysfs_read_file() doesn't leak on error.
Peter Jones [Wed, 13 Jun 2018 13:15:17 +0000 (09:15 -0400)]
Try to convince covscan that sysfs_read_file() doesn't leak on error.

Basically, covscan gets confused about some of our return paths and
doesn't  think the error condition correlates with not having allocated
(or having freed) the ram we're using to pass the file data back.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoPromote _make_hd_dn() to make_hd_dn() and get rid of the wrapper.
Peter Jones [Tue, 12 Jun 2018 18:36:20 +0000 (14:36 -0400)]
Promote _make_hd_dn() to make_hd_dn() and get rid of the wrapper.

The wrapper is just hiding what the code's doing, and all the other code
around where we use it does the same thing anyway.  This hopefully
convinces coverity we're not really dereferencing "buf" there unless
it's nonzero.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoefivar: Fix some types in -L behavior to pacify coverity.
Peter Jones [Tue, 12 Jun 2018 18:36:20 +0000 (14:36 -0400)]
efivar: Fix some types in -L behavior to pacify coverity.

Coverity doesn't realize that efi_well_known_guids is /actually/ an
array, because we didn't tell it so.  So fix the declaration so we've
told it so.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoPacify some coverity nits.
Peter Jones [Tue, 12 Jun 2018 18:36:20 +0000 (14:36 -0400)]
Pacify some coverity nits.

Coverity has trouble tracking data flow sometimes, and believes that
sysfs_readlink() and read_sysfs_file() will sometimes return >= 0 when
the buffer has not been filled out.  This changes the check to also test
for a NULL pointer, hopefully pacifying it.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMove verbosity headers to be public
Peter Jones [Tue, 12 Jun 2018 18:36:20 +0000 (14:36 -0400)]
Move verbosity headers to be public

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMove the syntastic file I use out of the repo
Peter Jones [Tue, 12 Jun 2018 18:36:20 +0000 (14:36 -0400)]
Move the syntastic file I use out of the repo

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoBump version to 36
Peter Jones [Fri, 8 Jun 2018 19:14:27 +0000 (15:14 -0400)]
Bump version to 36

- Add NVDIMM support
- Re-written linux interface parser to handle how devices are
  partitioned better, and for cleaner code, with one file per device
  type.
- lots of verbosity updates
- better CI
- analysis with clang's analyzer as well as coverity
- Better handling of immutable bits in sysfs
- LIBEFIVAR_OPS=help
- lots of code cleanups.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMake ccc-analyzer get clang cflags
Peter Jones [Fri, 8 Jun 2018 19:04:45 +0000 (15:04 -0400)]
Make ccc-analyzer get clang cflags

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoFix some errors scan-build found.
Peter Jones [Fri, 8 Jun 2018 18:44:24 +0000 (14:44 -0400)]
Fix some errors scan-build found.

This fixes a couple of failures to check for NULL in string parsing, and
one failure to free a value in an error path.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agonvdimm: Use the namespace guid, not just the device guid
Peter Jones [Fri, 8 Jun 2018 17:44:37 +0000 (13:44 -0400)]
nvdimm: Use the namespace guid, not just the device guid

This makes long-form device paths for nvdimm be:

NVDIMM(pmem-namespace-guid)/NVDIMM(pmem-label-guid)/HD(...)/File(...)

It also conditionally removes our UUID swizzling, because nobody can
figure out what the correct encoding is, and only byteswaps if
LIBEFIBOOT_SWIZZLE_PMEM_UUID is set (to any value) in the environment.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoFix an edge case in finding the sysfs driver link
Peter Jones [Fri, 8 Jun 2018 18:06:28 +0000 (14:06 -0400)]
Fix an edge case in finding the sysfs driver link

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoUse the pci node's driver link to detect ATA in some cases
Peter Jones [Thu, 7 Jun 2018 20:19:22 +0000 (16:19 -0400)]
Use the pci node's driver link to detect ATA in some cases

6 years agoefivarfs: fix some minor immutability bugs
Peter Jones [Thu, 7 Jun 2018 20:18:09 +0000 (16:18 -0400)]
efivarfs: fix some minor immutability bugs

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoExpand tabs on the rest of linux.c
Peter Jones [Thu, 7 Jun 2018 17:47:43 +0000 (13:47 -0400)]
Expand tabs on the rest of linux.c

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoAlways build the .so.1 local symlink
Peter Jones [Thu, 7 Jun 2018 16:45:00 +0000 (12:45 -0400)]
Always build the .so.1 local symlink

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoaudit efi_error() for wrong newlines.
Peter Jones [Thu, 7 Jun 2018 16:43:51 +0000 (12:43 -0400)]
audit efi_error() for wrong newlines.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoUpdate our abixml files for new ABI bits and minor changes.
Peter Jones [Wed, 6 Jun 2018 21:52:53 +0000 (17:52 -0400)]
Update our abixml files for new ABI bits and minor changes.

Currently abidiff notices the following:

abidiff \
--suppr abignore \
--headers-dir2 /home/pjones/devel/github.com/efivar/master/src/include/efivar/ \
libefivar.abixml \
libefivar.so
Functions changes summary: 0 Removed, 1 Changed, 3 Added functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

3 Added functions:

  'function FILE* efi_get_logfile()'    {efi_get_logfile@@LIBEFIVAR_1.36}
  'function int efi_get_verbose()'    {efi_get_verbose@@LIBEFIVAR_1.36}
  'function void efi_set_verbose(int, FILE*)'    {efi_set_verbose@@LIBEFIVAR_1.36}

1 function with some indirect sub-type change:

  [C]'function ssize_t efidp_make_acpi_hid_ex(uint8_t*, ssize_t, uint32_t, uint32_t, uint32_t, char*, char*, char*)' at <built-in>:263:1 has some indirect sub-type changes:
    parameter 6 of type 'char*' changed:
      in pointed to type 'char':
        entity changed from 'char' to 'const char'
        type size hasn't changed
    parameter 7 of type 'char*' changed:
      in pointed to type 'char':
        entity changed from 'char' to 'const char'
        type size hasn't changed
    parameter 8 of type 'char*' changed:
      in pointed to type 'char':
        entity changed from 'char' to 'const char'
        type size hasn't changed

The 3 added functions are as they should be.  The
efidp_make_acpi_hid_ex() changes are all from making arguments "const"
that weren't before, and that's fine as well.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoAdd a make target to rebuild our abidw .abixml files
Peter Jones [Wed, 6 Jun 2018 21:37:03 +0000 (17:37 -0400)]
Add a make target to rebuild our abidw .abixml files

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoRebuild efivar-35's abixml files with newer abidw.
Peter Jones [Wed, 6 Jun 2018 21:27:13 +0000 (17:27 -0400)]
Rebuild efivar-35's abixml files with newer abidw.

abidiff is not that good at recognizing its own format changes, so if we
just do the normal abicheck we get a lot of:

  [C]'function ssize_t efidp_make_atapi(uint8_t*, ssize_t, uint16_t, uint16_t, uint16_t)' has some indirect sub-type changes:
    parameter 6 of type 'uint8_t*' was added
    parameter 7 of type 'typedef ssize_t' was added
    parameter 8 of type 'typedef uint16_t' was added
    parameter 9 of type 'typedef uint16_t' was added
    parameter 10 of type 'typedef uint16_t' was added

Which is obviously just plain wrong (efidp_make_atapi()'s arguments have
not changed at all, and it still has only 5 of them.)

So the answer is to re-build efivar-35's .abixml files with newer abidw,
and *then* do abicheck.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agolibefiboot: make everything use "struct device" and kill "struct disk_info"
Peter Jones [Wed, 6 Jun 2018 21:18:31 +0000 (17:18 -0400)]
libefiboot: make everything use "struct device" and kill "struct disk_info"

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agolinux.h: Make some decls HIDDEN as they should be
Peter Jones [Wed, 6 Jun 2018 21:12:58 +0000 (17:12 -0400)]
linux.h: Make some decls HIDDEN as they should be

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoFix decl for get_sector_size()
Peter Jones [Wed, 6 Jun 2018 21:12:16 +0000 (17:12 -0400)]
Fix decl for get_sector_size()

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoConstify efidp_make_acpi_hid_ex() args and make its prototype more readible
Peter Jones [Wed, 6 Jun 2018 21:09:30 +0000 (17:09 -0400)]
Constify efidp_make_acpi_hid_ex() args and make its prototype more readible

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMove the PMEM device parser to linux-pmem.c
Peter Jones [Wed, 6 Jun 2018 20:53:37 +0000 (16:53 -0400)]
Move the PMEM device parser to linux-pmem.c

This won't actually *work* yet, because the infrastructure to use it
(replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoAdd a PCI parser that's independent of the other stuff.
Peter Jones [Wed, 6 Jun 2018 20:51:08 +0000 (16:51 -0400)]
Add a PCI parser that's independent of the other stuff.

This doesn't actually remove the old one, but a later patch will when
it's replacing all that stuff.

This won't actually *work* yet, either, because the infrastructure to
use it (replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMove SAS parsing to linux-sas.c
Peter Jones [Wed, 6 Jun 2018 20:47:11 +0000 (16:47 -0400)]
Move SAS parsing to linux-sas.c

This won't actually *work* yet, because the infrastructure to use it
(replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMove SATA parsing to linux-sata.c
Peter Jones [Wed, 6 Jun 2018 20:45:21 +0000 (16:45 -0400)]
Move SATA parsing to linux-sata.c

This won't actually *work* yet, because the infrastructure to use it
(replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMove nvme parsing to linux-nvme.c
Peter Jones [Wed, 6 Jun 2018 20:43:30 +0000 (16:43 -0400)]
Move nvme parsing to linux-nvme.c

This won't actually *work* yet, because the infrastructure to use it
(replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMove virtblk device parsing to linux-virtblk.c
Peter Jones [Wed, 6 Jun 2018 20:41:50 +0000 (16:41 -0400)]
Move virtblk device parsing to linux-virtblk.c

This won't actually *work* yet, because the infrastructure to use it
(replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMove i2o device parsing to linux-i2o.c
Peter Jones [Wed, 6 Jun 2018 20:40:05 +0000 (16:40 -0400)]
Move i2o device parsing to linux-i2o.c

This won't actually *work* yet, because the infrastructure to use it
(replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMove traditional SCSI parsing to linux-scsi.c
Peter Jones [Wed, 6 Jun 2018 20:37:46 +0000 (16:37 -0400)]
Move traditional SCSI parsing to linux-scsi.c

This won't actually *work* yet, because the infrastructure to use it
(replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMove ATA parsing to linux-ata.c
Peter Jones [Wed, 6 Jun 2018 20:32:26 +0000 (16:32 -0400)]
Move ATA parsing to linux-ata.c

This won't actually *work* yet, because the infrastructure to use it
(replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoAdd a (not great) macro to print parser debugging arrows.
Peter Jones [Thu, 7 Jun 2018 17:07:55 +0000 (13:07 -0400)]
Add a (not great) macro to print parser debugging arrows.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoAdd "struct device" in preperation for removing "struct disk_info".
Peter Jones [Wed, 6 Jun 2018 20:15:35 +0000 (16:15 -0400)]
Add "struct device" in preperation for removing "struct disk_info".

Also adds src/linux-*.c to the makefile

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoefi_loadopt_create(): add some debugging
Peter Jones [Wed, 6 Jun 2018 20:55:58 +0000 (16:55 -0400)]
efi_loadopt_create(): add some debugging

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoucs2.h: there's no reason ucs2_to_utf8 shouldn't malloc directly.
Peter Jones [Wed, 30 May 2018 20:59:46 +0000 (16:59 -0400)]
ucs2.h: there's no reason ucs2_to_utf8 shouldn't malloc directly.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agorename the pci_root_info fields to match the struct name
Peter Jones [Tue, 22 May 2018 14:04:52 +0000 (10:04 -0400)]
rename the pci_root_info fields to match the struct name

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMove get_sector_size() to the linux specific code
Peter Jones [Tue, 22 May 2018 13:57:25 +0000 (09:57 -0400)]
Move get_sector_size() to the linux specific code

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agolinux.h: add some more sysfs helpers, and improve their error handling.
Peter Jones [Tue, 22 May 2018 13:55:05 +0000 (09:55 -0400)]
linux.h: add some more sysfs helpers, and improve their error handling.

... this also moves them from util.h

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMore fixups for CONSTRUCTOR/DESTRUCTOR/HIDDEN/PUBLIC/etc.
Peter Jones [Mon, 21 May 2018 19:53:30 +0000 (15:53 -0400)]
More fixups for CONSTRUCTOR/DESTRUCTOR/HIDDEN/PUBLIC/etc.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoAdd some helpers for file path mangling
Peter Jones [Mon, 21 May 2018 18:23:52 +0000 (14:23 -0400)]
Add some helpers for file path mangling

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoutil.h: Add error reporting in read_file()
Peter Jones [Mon, 21 May 2018 15:18:00 +0000 (11:18 -0400)]
util.h: Add error reporting in read_file()

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoTemporary hack in get_partition_number
Peter Jones [Wed, 6 Jun 2018 20:30:08 +0000 (16:30 -0400)]
Temporary hack in get_partition_number

This code has been wrong for a while, but it's getting removed, so
really don't bother *fixing* it so much as appeasing newer gcc's
noticing that it's uninitialized.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMake LIBEFIVAR_OPS=help work
Peter Jones [Mon, 21 May 2018 13:40:01 +0000 (09:40 -0400)]
Make LIBEFIVAR_OPS=help work

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoAdd some more debug facilities.
Peter Jones [Thu, 26 Apr 2018 19:57:48 +0000 (15:57 -0400)]
Add some more debug facilities.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoAdd hexdumper
Peter Jones [Thu, 26 Apr 2018 19:05:38 +0000 (15:05 -0400)]
Add hexdumper

6 years agoMake all of our Make.* files have vim:ft=make
Peter Jones [Mon, 21 May 2018 14:08:55 +0000 (10:08 -0400)]
Make all of our Make.* files have vim:ft=make

... except Make.version because it's fully automated.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agofix some dumb stuff in 'make install' targets
Peter Jones [Mon, 21 May 2018 13:53:15 +0000 (09:53 -0400)]
fix some dumb stuff in 'make install' targets

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agogpt.h: minor cleanups (mostly formatting/whitespace)
Peter Jones [Fri, 18 May 2018 17:23:01 +0000 (13:23 -0400)]
gpt.h: minor cleanups (mostly formatting/whitespace)

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoget_partition_info(): fix the return code error path.
Peter Jones [Wed, 18 Apr 2018 21:47:26 +0000 (17:47 -0400)]
get_partition_info(): fix the return code error path.

Half the code thinks >= 0 is success, half the code things <= 0 is
success...

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoclang: ?e64_to_cpu() and cpu_to_?e64(): cast to uint64_t.
Peter Jones [Thu, 17 May 2018 21:57:10 +0000 (17:57 -0400)]
clang: ?e64_to_cpu() and cpu_to_?e64(): cast to uint64_t.

On x86_64, clang makes __builtin_bswap64() return "unsigned long"
instead of "unsigned long long", so using PRIx64 complains all over the
place.  Casting to uint64_t satisfies both compilers.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMore aggressively use macros for compiler attributes
Peter Jones [Thu, 17 May 2018 20:37:57 +0000 (16:37 -0400)]
More aggressively use macros for compiler attributes

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoSimplify our include files
Peter Jones [Thu, 17 May 2018 20:31:59 +0000 (16:31 -0400)]
Simplify our include files

Make everything just include src/efivar.h or src/efiboot.h, and let
those sort out the correct things to include.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoutil.h: whitespace cleanup
Peter Jones [Thu, 19 Apr 2018 14:25:16 +0000 (10:25 -0400)]
util.h: whitespace cleanup

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agogpt: get rid of ad-hoc warning reporting; use efi_error()
Peter Jones [Wed, 18 Apr 2018 21:46:45 +0000 (17:46 -0400)]
gpt: get rid of ad-hoc warning reporting; use efi_error()

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agogpt: don't use the __ versions of cpu_to_le??()/le??_to_cpu()
Peter Jones [Thu, 17 May 2018 20:34:49 +0000 (16:34 -0400)]
gpt: don't use the __ versions of cpu_to_le??()/le??_to_cpu()

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoefivar: fix efi_well_known_guids and efi_well_known_guids_end definitions
Peter Jones [Thu, 17 May 2018 19:10:40 +0000 (15:10 -0400)]
efivar: fix efi_well_known_guids and efi_well_known_guids_end definitions

From github:

build command: make CROSS_COMPILE=aarch64-linux-gnu- prefix=/home/b58867/Desktop/ls1043ardb/efivar/efivar_arm64 static

compilation error:
aarch64-linux-gnu-gcc -O2 -flto -g3 -I/home/b58867/Desktop/ls1043ardb/efivar/src/include/ -specs=/home/b58867/Desktop/ls1043ardb/efivar/gcc.specs -L. -Wl,-z,muldefs -static -o efivar-static efivar.c dp.static.o dp-acpi.static.o dp-hw.static.o dp-media.static.o dp-message.static.o efivarfs.static.o error.static.o export.static.o guid.static.o guids.static.o guid-symbols.static.o lib.static.o vars.static.o -ldl
guid.c:112:24: error: type of ‘efi_well_known_guids_end’ does not match original declaration [-Werror]
extern struct guidname efi_well_known_guids_end
^
efivar.c:490:28: note: previously declared here
extern struct guidname *efi_well_known_guids_end;
^
efivar.c:489:27: error: type of ‘efi_well_known_guids’ does not match original declaration [-Werror]
extern struct guidname efi_well_known_guids[];
^
guid.c:108:24: note: previously declared here
extern struct guidname efi_well_known_guids
^
lto1: all warnings being treated as errors
lto-wrapper: fatal error: aarch64-linux-gnu-gcc returned 1 exit status

Fixes github issue #102

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoFix our pkg-config-ldflags invocation.
Peter Jones [Wed, 18 Apr 2018 21:44:22 +0000 (17:44 -0400)]
Fix our pkg-config-ldflags invocation.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoWe don't use list.h at all; axe it.
Peter Jones [Wed, 9 May 2018 20:14:52 +0000 (16:14 -0400)]
We don't use list.h at all; axe it.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoAnother minor docs typo fix.
Peter Jones [Thu, 17 May 2018 15:44:25 +0000 (11:44 -0400)]
Another minor docs typo fix.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agominor correction to the efi_variable_import and efi_variable_export man-page
Robert Bisewski [Sun, 29 Apr 2018 19:08:45 +0000 (14:08 -0500)]
minor correction to the efi_variable_import and efi_variable_export man-page

6 years agorewrite efivarfs_set_variable() [9896c26c7e68-based]
Laszlo Ersek [Wed, 16 May 2018 17:21:27 +0000 (19:21 +0200)]
rewrite efivarfs_set_variable() [9896c26c7e68-based]

This patch rewrites the efivarfs_set_variable() function, to address the
following issues:

- a size_t value is printed with %zd -- size_t is unsigned, so it should
  be printed with %zu or %zx,

- a VLA is used for storing input of basically unbounded size -- we should
  use a range-checked malloc() call instead,

- the efivarfs file is opened for writing while it may be immutable --
  this is the trickiest issue to resolve,

- passing just O_APPEND|O_CREAT to open() is undefined -- O_WRONLY is
  required, and O_APPEND and (O_CREAT | O_EXCL) should both be independent
  of it (and of each other),

- some error branches call efi_error() without setting errno first,

- the variable is removed on any write failure, even if we didn't create
  the variable -- failed writes are expected to be atomic (from the kernel
  side and from the firmware side) and not to leave behind side effects;
  so only delete the variable on error if we created it.

A small helper function efivarfs_make_fd_mutable() is introduced as well.

(It's best to review the new efivarfs_set_variable() function in its
entirety, with the patch applied, rather than comparing old vs. new, hunk
for hunk.)

Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1516599
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
6 years agoSilence some trivial clang-analyzer/coverity complaints.
Peter Jones [Tue, 17 Apr 2018 17:49:19 +0000 (13:49 -0400)]
Silence some trivial clang-analyzer/coverity complaints.

One minor memory leak in /usr/bin/efivar, a couple of places where the
analyzers make assumptions without being able to figure out the data
flow.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agodp-acpi: improve formatting of AcpiEx() device paths.
Peter Jones [Tue, 17 Apr 2018 17:44:58 +0000 (13:44 -0400)]
dp-acpi: improve formatting of AcpiEx() device paths.

This also fixes a minor scan-build complaint about cidlen being assigned
but not used.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoAdd a clang-analyzer scan-build make targets as well.
Peter Jones [Tue, 17 Apr 2018 17:26:45 +0000 (13:26 -0400)]
Add a clang-analyzer scan-build make targets as well.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoWork around coverity being a pretty lazy and poor tool.
Peter Jones [Tue, 17 Apr 2018 16:28:24 +0000 (12:28 -0400)]
Work around coverity being a pretty lazy and poor tool.

I mean, come on, at least dynamically import the types you've missed
from the version of GCC that's installed on the system and you're
pretending to emulate.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoUpdate travis to use some better build scripts
Peter Jones [Wed, 11 Apr 2018 20:46:23 +0000 (16:46 -0400)]
Update travis to use some better build scripts

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoSimplify the docker/travis stuff some
Peter Jones [Mon, 9 Apr 2018 19:33:44 +0000 (15:33 -0400)]
Simplify the docker/travis stuff some

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agotry to make travis work again...
Peter Jones [Mon, 9 Apr 2018 19:04:13 +0000 (15:04 -0400)]
try to make travis work again...

6 years agoBump version to 35
Peter Jones [Mon, 9 Apr 2018 18:52:25 +0000 (14:52 -0400)]
Bump version to 35

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoDon't use _Generic because gcc 4.x doesn't have it...
Peter Jones [Mon, 13 Mar 2017 17:36:55 +0000 (13:36 -0400)]
Don't use _Generic because gcc 4.x doesn't have it...

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMake efi_get_variable_exists match the version we put on it.
Peter Jones [Mon, 19 Mar 2018 16:41:07 +0000 (12:41 -0400)]
Make efi_get_variable_exists match the version we put on it.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMake non-pull-request builds work.
Peter Jones [Tue, 13 Mar 2018 23:25:25 +0000 (19:25 -0400)]
Make non-pull-request builds work.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoUse https for github urls in travis.
Peter Jones [Tue, 13 Mar 2018 23:07:52 +0000 (19:07 -0400)]
Use https for github urls in travis.

If I don't, I awesomely get:

git remote add remote git@github.com:${remote_repo}
git fetch remote
Host key verification failed.
fatal: Could not read from remote repository.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agomore travis stuf...
Peter Jones [Tue, 13 Mar 2018 22:38:48 +0000 (18:38 -0400)]
more travis stuf...

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMore travis stuff maybe.
Peter Jones [Tue, 13 Mar 2018 22:36:26 +0000 (18:36 -0400)]
More travis stuff maybe.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMake the log smaller...
Peter Jones [Tue, 13 Mar 2018 22:11:45 +0000 (18:11 -0400)]
Make the log smaller...

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoSome more travis work...
Peter Jones [Tue, 13 Mar 2018 22:08:16 +0000 (18:08 -0400)]
Some more travis work...

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMake travis dump some stuff at us.
Peter Jones [Tue, 13 Mar 2018 21:59:28 +0000 (17:59 -0400)]
Make travis dump some stuff at us.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoWork around -Werror=stringop-overflow= being daft.
Peter Jones [Tue, 13 Mar 2018 21:10:56 +0000 (17:10 -0400)]
Work around -Werror=stringop-overflow= being daft.

With:

len = strlen(foo + offset) + 1;
buf = calloc(1, len);
if (!buf)
err(1, "out of memory");
strncpy(buf, foo+offset, len);

-Wstringop-overflow complains:

efivar.c:169:2: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
  strncpy(name_buf, guid_name + name_pos, name_len);
  ^
efivar.c:163:13: note: length computed here
  name_len = strlen(guid_name + name_pos) + 1;
             ^
lto1: all warnings being treated as errors

Which... Duh, so was the allocation it's writing into.  So what?

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoUpdate travis.yml to be wildly different...
Peter Jones [Tue, 13 Mar 2018 21:10:49 +0000 (17:10 -0400)]
Update travis.yml to be wildly different...

6 years agoMake 0abba7dc-e516-4167-bbf5-4d9d1c739416 reflect its use in fwupdate
Peter Jones [Tue, 13 Mar 2018 14:31:00 +0000 (10:31 -0400)]
Make 0abba7dc-e516-4167-bbf5-4d9d1c739416 reflect its use in fwupdate

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agomakeguids: generalize the efi_guid_empty mechanism to arbitrary aliases.
Peter Jones [Tue, 13 Mar 2018 15:07:15 +0000 (11:07 -0400)]
makeguids: generalize the efi_guid_empty mechanism to arbitrary aliases.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoAdd efi_get_variable_exists()
Richard Hughes [Fri, 9 Mar 2018 11:21:03 +0000 (11:21 +0000)]
Add efi_get_variable_exists()

Sometimes we just want to know if a variable exists, and don't care about the
attributes or what the variable contains. Use efi_get_variable_attributes()
under the covers to avoid adding yet-another-fvunc to all the backends.

6 years agoUse __builtin_bswap16() in EFI_GUID and other places.
Peter Jones [Mon, 12 Mar 2018 14:38:44 +0000 (10:38 -0400)]
Use __builtin_bswap16() in EFI_GUID and other places.

This makes EFI_GUID() usually not be an expression that has to be in a
function.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoefivarfs / vars: usleep() before reading from efivarfs if euid != 0
Peter Jones [Fri, 23 Feb 2018 20:49:02 +0000 (15:49 -0500)]
efivarfs / vars: usleep() before reading from efivarfs if euid != 0

There's a kernel rate limiter on efi variable reads now for
non-root users, and we'd rather just not hit it than have to dig out
from having hit it.  So this adds a 10ms sleep before each read call.

If you do have 50 variables, efibootmgr will do 100 reads, which would
trigger the rate limit.  In that case, this patch adds 1 second (plus
lossage due to calling, etc.), so it should stay just below the
triggering threshold.  That will definitely be /smoother/ than hitting
it, and almost certainly faster as well, because the extra calls will
re-enforce the limit.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoBump version to 34
Peter Jones [Tue, 13 Feb 2018 16:21:21 +0000 (11:21 -0500)]
Bump version to 34

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoAdd UX capsule to map for 33 not 32
Mario Limonciello [Thu, 11 Jan 2018 21:18:05 +0000 (15:18 -0600)]
Add UX capsule to map for 33 not 32

commit cd732494 fixed UX capsule support, but it mistakingly marked
it for version 32.  It really should be marked for 33.

6 years agoAdd a patch from Helmut Grohne for cross compiling
Mario Limonciello [Mon, 8 Jan 2018 23:12:30 +0000 (17:12 -0600)]
Add a patch from Helmut Grohne for cross compiling

Originally came from
https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=843261;filename=efivar_30-1.1.debdiff;msg=5

6 years agoClean up superfluous slashes
Jan Tojnar [Sun, 17 Dec 2017 07:54:50 +0000 (08:54 +0100)]
Clean up superfluous slashes

6 years agoUse correct paths in pc files
Jan Tojnar [Sun, 17 Dec 2017 07:41:00 +0000 (08:41 +0100)]
Use correct paths in pc files

Previously, the paths in the pkgconfig files were hardcoded resulting
in broken include paths on NixOS.

This patch replaces the paths with placeholders that will be changed
during making.

6 years agoBe more stringent on the criteria for not doing disk probes.
Peter Jones [Fri, 9 Feb 2018 16:16:47 +0000 (11:16 -0500)]
Be more stringent on the criteria for not doing disk probes.

This bit of the nvdimm code stops HD() paths from getting generated
right sometimes.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agodefine strndupa if it is not defined
Dan Robertson [Wed, 7 Feb 2018 13:01:44 +0000 (13:01 +0000)]
define strndupa if it is not defined

musl does not include strndupa in <string.h>. Define strndupa if it has
not already been defined.

6 years agocleanup: found is always true in branch
Dan Robertson [Wed, 7 Feb 2018 13:00:09 +0000 (13:00 +0000)]
cleanup: found is always true in branch

Remove use of found in conditional, as it is always true.

6 years agoBump version to 33
Peter Jones [Tue, 23 Jan 2018 16:12:56 +0000 (11:12 -0500)]
Bump version to 33

- Add NVDIMM support.
- Doesn't change much, but we need to bump to 33 because of an fwupdate bug.

Signed-off-by: Peter Jones <pjones@redhat.com>