Commit Graph

5961 Commits (decee20ec84977ae1d1a7f54fa91e73017f6731d)
 

Author SHA1 Message Date
Michael Brown decee20ec8 [build] Disable position-independent code for ARM64 EFI builds
Some versions of gcc (observed with the cross-compiling gcc 9.3.0 in
Ubuntu 20.04) default to enabling -fPIE.  Experimentation shows that
this results in the emission of R_AARCH64_ADR_GOT_PAGE relocation
records for __stack_chk_guard.  These relocation types are not
supported by elf2efi.c.

Fix by explicitly disabling position-independent code for ARM64 EFI
builds.

Debugged-by: Antony Messerli <antony@mes.ser.li>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-27 21:47:04 +01:00
Michael Brown 8a1d66c7ae [golan] Add explicit type casts for nodnic_queue_pair_type
GCC 10 emits warnings for implicit conversions of enumerated types.

The flexboot_nodnic code defines nodnic_queue_pair_type with values
identical to those of ib_queue_pair_type, and implicitly casts between
them.  Add an explicit cast to fix the warning.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-27 21:16:07 +01:00
Michael Brown 28cf9806d1 [intel] Avoid spurious compiler warning on GCC 10
GCC 10 produces a spurious warning about an out-of-bounds array access
for the unsized raw dword array in union intelvf_msg.

Avoid the warning by embedding the zero-length array within a struct.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-27 21:16:07 +01:00
Bruce Rogers f982a71297 [build] Be explicit about -fcommon compiler directive
gcc10 switched default behavior from -fcommon to -fno-common.  Since
"__shared" relies on the legacy behavior, explicitly specify it.

Signed-off-by: Bruce Rogers <brogers@suse.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-27 21:16:07 +01:00
Michael Brown 3f637d7462 [ocsp] Accept SHA1 certID responses even if SHA1 is not enabled
Various implementation quirks in OCSP servers make it impractical to
use anything other than SHA1 to construct the issuerNameHash and
issuerKeyHash identifiers in the request certID.  For example: both
the OpenCA OCSP responder used by ipxe.org and the Boulder OCSP
responder used by LetsEncrypt will fail if SHA256 is used in the
request certID.

As of commit 6ffe28a ("[ocsp] Accept response certID with missing
hashAlgorithm parameters") we rely on asn1_digest_algorithm() to parse
the algorithm identifier in the response certID.  This will fail if
SHA1 is disabled via config/crypto.h.

Fix by using a direct ASN.1 object comparison on the OID within the
algorithm identifier.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-25 13:04:54 +01:00
Michael Brown a61b27b97f [efi] Enable stack protection where possible
Enable -fstack-protector for EFI builds, where binary size is less
critical than for BIOS builds.

The stack cookie must be constructed immediately on entry, which
prohibits the use of any viable entropy source.  Construct a cookie by
XORing together various mildly random quantities to produce a value
that will at least not be identical on each run.

On detecting a stack corruption, attempt to call Exit() with an
appropriate error.  If that fails, then lock up the machine since
there is no other safe action that can be taken.

The old conditional check for support of -fno-stack-protector is
omitted since this flag dates back to GCC 4.1.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-24 16:23:21 +01:00
Michael Brown 8830f2f351 [parseopt] Treat empty integer strings in user input as invalid
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-19 17:33:27 +01:00
Michael Brown 2000297011 [util] Treat empty integer strings as invalid
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-19 16:56:02 +01:00
Michael Brown 770a7bd43a [snp] Retry initialisation if link is reported as down
Some devices (observed with a Getac RX10 tablet and docking station
containing an embedded AX88179 USB NIC) seem to be capable of
detecting link state only during the call to Initialize(), and will
occasionally erroneously report that the link is down for the first
few such calls.

Work around these devices by retrying the Initialize() call multiple
times, terminating early if a link is detected.  The eventual absence
of a link is treated as a non-fatal error, since it is entirely
possible that the link really is down.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-19 00:18:22 +01:00
Michael Brown 7f2006a9ad [crypto] Disable MD5 as an OID-identifiable algorithm by default
Disable the use of MD5 as an OID-identifiable algorithm.  Note that
the MD5 algorithm implementation will still be present in the build,
since it is used implicitly by various cryptographic components such
as HTTP digest authentication; this commit removes it only from the
list of OID-identifiable algorithms.

It would be appropriate to similarly disable the use of SHA-1 by
default, but doing so would break the use of OCSP since several OCSP
responders (including the current version of openca-ocspd) are not
capable of interpreting the hashAlgorithm field and so will fail if
the client uses any algorithm other than the configured default.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-16 23:41:43 +01:00
Michael Brown bb74f00512 [crypto] Ensure that test code drags in required ASN.1 object identifiers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-16 23:41:43 +01:00
Michael Brown bd7a5e4b9c [crypto] Allow algorithms to be included without being OID-identifiable
There are many ways in which the object for a cryptographic algorithm
may be included, even if not explicitly enabled in config/crypto.h.
For example: the MD5 algorithm is required by TLSv1.1 or earlier, by
iSCSI CHAP authentication, by HTTP digest authentication, and by NTLM
authentication.

In the current implementation, inclusion of an algorithm for any
reason will result in the algorithm's ASN.1 object identifier being
included in the "asn1_algorithms" table, which consequently allows the
algorithm to be used for any ASN1-identified purpose.  For example: if
the MD5 algorithm is included in order to support HTTP digest
authentication, then iPXE would accept a (validly signed) TLS
certificate using an MD5 digest.

Split the ASN.1 object identifiers into separate files that are
required only if explicitly enabled in config/crypto.h.  This allows
an algorithm to be omitted from the "asn1_algorithms" table even if
the algorithm implementation is dragged in for some other purpose.

The end result is that only the algorithms that are explicitly enabled
in config/crypto.h can be used for ASN1-identified purposes such as
signature verification.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-16 17:14:54 +01:00
Michael Brown dc785b0fb6 [tls] Default to supporting only TLSv1.1 or above
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-16 13:14:12 +01:00
Michael Brown 2dac11eb1d [tls] Allow a minimum TLS protocol version to be specified
The supported ciphers and digest algorithms may already be specified
via config/crypto.h.  Extend this to allow a minimum TLS protocol
version to be specified.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-12 21:40:33 +01:00
Michael Brown 9ee70fb95b [efi] Attempt to connect our driver directly if ConnectController fails
Some platforms (observed with an AMI BIOS on an Apollo Lake system)
will spuriously fail the call to ConnectController() when the UEFI
network stack is disabled.  This appears to be a BIOS bug that also
affects attempts to connect any non-iPXE driver to the NIC controller
handle via the UEFI shell "connect" utility.

Work around this BIOS bug by falling back to calling our
efi_driver_start() directly if the call to ConnectController() fails.
This bypasses any BIOS policy in terms of deciding which driver to
connect but still cooperates with the UEFI driver model in terms of
handle ownership, since the use of EFI_OPEN_PROTOCOL_BY_DRIVER ensures
that the BIOS is aware of our ownership claim.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-10 23:01:23 +01:00
Michael Brown 6a6def775d [uri] Avoid appearing to access final byte of a potentially empty string
The URI parsing code for "host[:port]" checks that the final character
is not ']' in order to allow for IPv6 literals.  If the entire
"host[:port]" portion of the URL is an empty string, then this will
access the preceding character.  This does not result in accessing
invalid memory (since the string is guaranteed by construction to
always have a preceding character) and does not result in incorrect
behaviour (since if the string is empty then strrchr() is guaranteed
to return NULL), but it does make the code confusing to read.

Fix by inverting the order of the two tests.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-05 10:01:19 +01:00
Michael Brown ac28bbb7ea [efi] Work around UEFI specification bug in LoadImage for SAN boot
As described in the previous commit, work around a UEFI specification
bug that necessitates calling UnloadImage if the return value from
LoadImage is EFI_SECURITY_VIOLATION.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-05 09:44:22 +01:00
Michael Brown 18d2162f64 [efi] Work around UEFI specification bug in LoadImage
iPXE currently assumes that any error returned from LoadImage()
indicates that the image was not loaded.  This assumption was correct
at the time the code was written and remained correct for UEFI
specifications up to and including version 2.1.

In version 2.3, the UEFI specification broke API and ABI compatibility
by defining that a return value of EFI_SECURITY_VIOLATION would now
indicate that the image had been loaded and a valid image handle had
been created, but that the image should not be started.

The wording in version 2.2 is ambiguous, and does not define whether
or not a return value of EFI_SECURITY_VIOLATION indicates that a valid
image handle has been created.

Attempt to work around all of these incompatible and partially
undefined APIs by calling UnloadImage if we get a return value of
EFI_SECURITY_VIOLATION.  Minimise the risk of passing an uninitialised
pointer to UnloadImage by setting ImageHandle to NULL prior to calling
LoadImage.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-04 22:40:35 +01:00
Michael Brown d68befef1a [png] Fix potential integer overflow
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-06-04 22:09:11 +01:00
Joseph Wong ebff21a515 [bnxt] Add driver support for Broadcom NetXtreme-E Adapters
Signed-off-by: Joseph Wong <joseph.wong@broadcom.com>
2020-05-06 15:41:45 +01:00
Michael Brown bdf0e029ae [efi] Disambiguate errors returned by ConnectController
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-03-14 09:49:49 +00:00
Michael Brown efc1ae5aba [int13con] Create log partition only when CONSOLE_INT13 is enabled
Reduce the size of the USB disk image in the common case that
CONSOLE_INT13 is not enabled.

Originally-implemented-by: Romain Guyard <romain.guyard@mujin.co.jp>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-03-01 12:59:03 +00:00
Michael Brown 49319f1bc9 [bios] Define macros for constructing partition table entries
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-03-01 12:34:45 +00:00
Michael Brown e3ca211071 [iscsi] Eliminate variable-length stack allocation in URI parsing
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-02-16 23:47:06 +00:00
Michael Brown e2e29e7ae3 [iscsi] Eliminate variable-length stack allocations in CHAP handlers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-02-16 23:19:55 +00:00
Michael Brown 446e8f14e8 [settings] Eliminate variable-length stack allocation
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-02-16 22:30:38 +00:00
Michael Brown 0a74321915 [slam] Allow for the possibility of IPv6 multicast addresses
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-02-16 22:02:25 +00:00
Michael Brown c5306bcfa5 [slam] Eliminate variable-length stack allocation
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-02-16 21:55:59 +00:00
Michael Brown 6248ac396a [infiniband] Eliminate variable-length stack allocation
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-02-16 21:42:35 +00:00
Michael Brown c625681ca1 [tftp] Eliminate unnecessary variable-length stack allocation
Eliminate an unnecessary variable-length stack allocation and memory
copy by allowing TFTP option processors to modify the option string
in-place.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-02-16 20:08:20 +00:00
Michael Brown 18dc73d27e [travis] Ensure that most recent tag is always available
Remove clone depth limit, to ensure that the most recent tag (from
which the version should be constructed) is always present.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-01-03 00:14:03 +01:00
Michael Brown 8f1514a004 [build] Construct full version number automatically from git revision
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2020-01-02 23:54:24 +01:00
Ignat Korchagin ea832529a5 [snp] Set EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST bit as per UEFI spec
According to UEFI specification 2.8 p 24.1 we must set the
EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST bit in the "Disable" mask, when
"ResetMCastFilter" is TRUE.

Signed-off-by: Ignat Korchagin <ignat@cloudflare.com>
Split-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-12-16 10:46:04 +00:00
Ignat Korchagin ed4a82e239 [snp] Try promiscuous multicast receive filter if the regular one fails
Currently, if the SNP driver for whatever reason fails to enable
receive filters for multicast frames, it falls back to enabling just
unicast and broadcast filters.  This breaks some IPv6 functionality as
the network card does not respond to neighbour solicitation requests.

Some cards refuse to enable EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST, but
do support enabling EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST,
so try it before falling back to just unicast+broadcast.

Signed-off-by: Ignat Korchagin <ignat@cloudflare.com>
Split-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-12-16 10:42:09 +00:00
Michael Brown a2d3bedf1f [peerdist] Allow for the use of a hosted cache server
Allow a PeerDist hosted cache server to be specified via the
${peerhost} setting, e.g.:

  # Use 192.168.0.1 as hosted cache server
  set peerhost 192.168.0.1

Note that this simply treats the hosted cache server as a permanently
discovered peer for all segments.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-12-15 23:29:44 +00:00
Michael Brown 53af9905e0 [peerdist] Allow PeerDist to be globally enabled or disabled
Allow the use of PeerDist content encoding to be enabled or disabled
via the ${peerdist} setting, e.g.:

  # Disable PeerDist
  set peerdist 0

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-12-13 14:44:22 +00:00
Michael Brown 3fe683ebab [lan78xx] Always enable automatic speed and duplex detection
On devices with no EEPROM or OTP, the MAC_CR register defaults to not
using automatic link speed detection, with the result that no packets
are successfully sent or received.

Fix by always enabling automatic speed and duplex detection, since
iPXE provides no mechanism for manual configuration of either link
speed or duplex.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-09-29 20:59:22 +01:00
Michael Brown 41a9a5c7b3 [efi] Do not attempt EFI_USB_IO_PROTOCOL transfers during shutdown
On at least some platforms (observed with a Raspberry Pi), any attempt
to perform USB transfers via EFI_USB_IO_PROTOCOL during EFI shutdown
will lock up the system.  This is quite probably due to the already
documented failure of all EFI timers when ExitBootServices() is
called: see e.g. commit 5cf5ffea2 "[efi] Work around temporal anomaly
encountered during ExitBootServices()".

Work around this problem by refusing to poll endpoints if shutdown is
in progress, and by immediately failing any attempts to enqueue new
transfers.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-09-15 10:40:23 +01:00
Michael Brown 4c8721331d [efi] Report failed control transfers as expected by the USB core
The USB core reuses the I/O buffer space occupied by the USB setup
packet to hold the completion status for message transfers, assuming
that the message() method will always strip the setup packet before
returning.  This assumption is correct for all of the hardware
controller drivers (XHCI, EHCI, and UHCI), since these drivers are
able to enqueue the transfer as a separate action from waiting for the
transfer to complete.

The EFI_USB_IO_PROTOCOL does not allow us to separate actions in this
way: there is only a single blocking method that both enqueues and
waits for completion.  Our usbio driver therefore currently defers
stripping the setup packet until the control endpoint is polled.

This causes a bug if a message transfer is enqueued but never polled
and is subsequently cancelled, since the cancellation will be reported
with the I/O buffer still containing the setup packet.  This breaks
the assumption that the setup packet has been stripped, and triggers
an assertion failure in usb_control_complete().

Fix by always stripping the setup packet in usbio_endpoint_message(),
and adjusting usbio_control_poll() to match.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-09-15 10:25:46 +01:00
Michael Brown 0b3000bbec [golan] Fix address-of-pointer bug for multicast attach/detach
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-08-17 17:51:18 +01:00
Michael Brown f1e6efa40b [ethernet] Avoid false positive Coverity warning
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-08-17 17:30:09 +01:00
Michael Brown a5c41483d2 [coverity] Override assumptions about wcrtomb() and hmac_init()
Newer versions of Coverity use built-in models for wcrtomb() and
hmac_init() that are capable of returning errors, and reports defects
due to code failing to check for these errors.  The actual iPXE
implementations are simpler than Coverity's models and can never
return errors, so these defects are false positives.

Fix by overriding Coverity's built-in models for these functions.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-08-17 17:18:54 +01:00
Michael Brown 0cc12f053c [crypto] Profile the various stages of modular multiplication
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-08-17 01:24:51 +01:00
Michael Brown 131635eac0 [crypto] Drag in configured digestInfo prefixes for any use of RSA
Ensure that the configured RSA digestInfo prefixes are included in any
build that includes rsa.o (rather than relying on x509.o or tls.o also
being present in the final binary).

This allows the RSA self-tests to be run in isolation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-08-17 01:18:34 +01:00
Michael Brown fd96acb7de [tls] Add missing call to tls_tx_resume() when restarting negotiation
The restart of negotiation triggered by a HelloRequest currently does
not call tls_tx_resume() and so may end up leaving the connection in
an idle state in which the pending ClientHello is never sent.

Fix by calling tls_tx_resume() as part of tls_restart(), since the
call to tls_tx_resume() logically belongs alongside the code that sets
bits in tls->tx_pending.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-08-16 22:51:14 +01:00
Michael Brown d8a1958ba5 [peerdist] Limit number of concurrent raw block downloads
Raw block downloads are expensive if the origin server uses HTTPS,
since each concurrent download will require local TLS resources
(including potentially large received encrypted data buffers).

Raw block downloads may also be prohibitively slow to initiate when
the origin server is using HTTPS and client certificates.  Origin
servers for PeerDist downloads are likely to be running IIS, which has
a bug that breaks session resumption and requires each connection to
go through the full client certificate verification.

Limit the total number of concurrent raw block downloads to ameliorate
these problems.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-08-16 22:19:50 +01:00
Michael Brown 02b26de963 [peerdist] Start block download timers from within opener methods
Move the responsibility for starting the block download timers from
peerblk_expired() to peerblk_raw_open() and peerblk_retrieval_open(),
in preparation for adding the ability to defer calls to
peerblk_raw_open() via a block download queue.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-08-16 22:19:50 +01:00
Michael Brown 6df2c6ab76 [process] Add PROC_INIT() for initialising static processes
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-08-16 22:19:48 +01:00
Michael Brown c63ef427a2 [build] Add predefined shortcut for Raspberry Pi builds
Add a build shortcut "rpi", allowing for e.g.

  make CONFIG=rpi CROSS=aarch64-linux-gnu- bin-arm64-efi/rpi.efi

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-08-02 11:57:35 +01:00
Michael Brown c742c576d0 [build] Move predefined all-drivers build shortcut to Makefile
The (very approximate) split between Makefile.housekeeping and
Makefile is that the former provides mechanism and the latter provides
policy.

Provide a section within Makefile as a home for predefined build
shortcuts such as the existing all-drivers build.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2019-08-02 11:00:43 +01:00