In preparation for the MarkdownLintCheck plugin being added to the
repo, this change defaults the plugin to `AuditOnly` mode in each
package. This allows package maintainers to enable the plugin as they
see fit.
Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
When caching the DHCPv6 discover packet to Mode->DhcpDiscover in
PxeBcDhcp6CallBack, the destination was incorrectly specified as
Mode->DhcpDiscover.Dhcpv4 (the DHCPv4 union member). Change it to
Mode->DhcpDiscover to correctly reference the union and avoid
type confusion when copying a DHCPv6 packet.
Signed-off-by: Abuthahir M <abuthahirm@ami.com>
In Ip6ProcessRouterAdvertise, IpSb->InterfaceId is dereferenced in
CopyMem to form a stateless address. Add a guard to ensure
IpSb->InterfaceId is not NULL before entering the block, preventing
a potential NULL pointer dereference.
Signed-off-by: Abuthahir M <abuthahirm@ami.com>
In Ip6CleanService, Ip6FreeNeighborEntry may attempt to send packets via
MNP. Defensively move the neighbor table cleanup to occur before MNP
teardown so that the MNP child handle and its resources remain valid
during neighbor entry cleanup.
Signed-off-by: Abuthahir M <abuthahirm@ami.com>
Replace the ASSERT (Instance->Config != NULL) in Dhcp6UpdateIaInfo with
an explicit NULL check that returns EFI_DEVICE_ERROR. Also add a
complementary guard in Dhcp6GenerateIaCb alongside the existing check
for Instance->IaCb.Ia. These are defensive changes to prevent potential
NULL pointer dereferences.
Signed-off-by: Abuthahir M <abuthahirm@ami.com>
During SnpUndi32Initialize(), CurrentAddress is unconditionally
overwritten with PermanentAddress before UNDI initialization. This
causes MAC address passthrough (MacPassthru) to fail, as the NIC's
actual current address, which may differ from its permanent address,
is lost.
After UNDI initialization completes, call PxeGetStnAddr() to read
the NIC's station address via the UNDI interface and update
CurrentAddress, PermanentAddress, and BroadcastAddress in the mode
structure with the values reported by the hardware.
The call is added to both initialization paths: the cable-detect
success path and the fallback no-cable-detect path.
Signed-off-by: Jared Pan <jared.pan@dell.com>
IScsiBuildKeyValueList parses the data segment of a received iSCSI
login, text or CHAP response into key=value pairs. After locating '='
within the remaining length, it sets KeyValuePair->Value and calls
AsciiStrLen(Value) to measure the value before subtracting it from the
remaining length. AsciiStrLen has no length cap, and the data segment
copied from the received PDU (AllocatePool(Len) + NetbufQueCopy of the
data-segment length) is not guaranteed to be NUL-terminated.
A malicious or redirecting target can send a data segment whose final
value lacks a trailing NUL (e.g. the 3 bytes "X=Y"), so AsciiStrLen
reads past the end of the segment allocation, an attacker-controlled
out-of-bounds read. The SafeUint32Sub bound check only runs after the
over-read.
Replace AsciiStrLen(Value) with AsciiStrnLenS(Value, Len), capping the
scan to the bytes remaining from Value onward. An unterminated value
then returns Len and the existing SafeUint32Sub rejects the segment.
The single change covers all three callers (login redirect, operational
parameter negotiation and CHAP).
Signed-off-by: Syed Mohammed Nayyar <jmestwa@gmail.com>
EfiPxeBcStart() in PxeBcImpl.c has conditional code branches for
IPV4 and IPV6.
- IPV4 branch should use EFI_IP4_COMPLETION_TOKEN which is
Private->IcmpToken.
- IPV6 branch should use EFI_IP6_COMPLETION_TOKEN which is
Private->Icmp6Token.
Right now, the IPv4 branch incorrectly initializes
Private->Icmp6Token to EFI_NOT_READY. That is changed to
Private->IcmpToken.
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
In Ip4FormExtractConfig(), the Status variable was assigned only within
a conditional block but used outside of it, which could lead to an
uninitialized variable warning.
Fix this by moving the relevant code outside of the conditional block so
that Status is always properly initialized before use.
Signed-off-by: Tuan Phan <tuan.phan@oss.qualcomm.com>
In HttpBootGetBootFileCaller(), under the LoadBootFile case, the Status
variable is only assigned within a for loop. If the loop is not executed,
this results in an uninitialized variable warning when Status is later
referenced.
Resolve this issue by return Status directly inside the loop.
Signed-off-by: Tuan Phan <tuan.phan@oss.qualcomm.com>
Dhcp6SeekInnerOptionSafe() reads the IA_NA/IA_TA option-len field from a
received datagram and only validates it against the fixed minimums, never
against OptionLen (the bytes actually remaining in the packet). A reply
can declare an option-len up to 0xFFFF while the real buffer is only the
16-byte (IA_NA) or 8-byte (IA_TA) minimum, so the returned inner length
is far larger than the buffer.
That length is then passed as SeekLen to Dhcp6SeekOption(), which walks
ReadUnaligned16() cursors up to Buf + SeekLen and reads past the end of
the packet allocation, an attacker-controlled out-of-bounds read.
Bound the declared inner length against OptionLen minus the IA header
size in both the IA_NA and IA_TA branches, rejecting over-declared
options with EFI_DEVICE_ERROR. Parenthesize DHCP6_MIN_SIZE_OF_IA_NA so
the subtraction in that bound binds correctly. Add host tests covering
the over-declared, off-by-one, and exact-boundary cases for both IA_NA
and IA_TA.
Signed-off-by: jmestwa-coder <jmestwa@gmail.com>
Root Cause:
The AttemptName string field in IScsiConfigVfr.vfr had
default = STRING_TOKEN(STR_NULL), which resolves to an empty
string. When optimized defaults are loaded (F3), the form browser
resets every field to its defined default, wiping out the actual
attempt names (e.g. Attempt 1, Attempt 2) and leaving the field
blank.
Fix:
Add the INTERACTIVE flag to the AttemptName string field in VFR.
This tells the form browser to invoke the driver callback when
loading defaults instead of applying the hardcoded empty string.
Introduce a helper function IScsiGetAttemptNameDefault() that reads
the stored attempt name from mCallbackInfo->Current->AttemptName,
registers it as a HII string, and returns it as the default value.
The helper also validates that the question type is
EFI_IFR_TYPE_STRING before accessing Value->string.
In IScsiFormCallback, handle EFI_BROWSER_ACTION_DEFAULT_STANDARD,
EFI_BROWSER_ACTION_DEFAULT_MANUFACTURING, and
EFI_BROWSER_ACTION_DEFAULT_SAFE for KEY_ATTEMPT_NAME by delegating
to the helper. This ensures loading any class of defaults always
restores the correct attempt name for whichever attempt is open.
Cc: Saloni Kasbekar <saloni.kasbekar@intel.com>
Cc: Zachary Clark-williams <zachary.clark-williams@intel.com>
Signed-off-by: Abuthahir M <abuthahirm@ami.com>
In HttpsReceive(), the return value of TlsCommonTransmit() was not
checked. Add error handling with proper cleanup of PacketOut and
BufferOut before returning on failure.
Cc: Saloni Kasbekar <saloni.kasbekar@intel.com>
Cc: Zachary Clark-williams <zachary.clark-williams@intel.com>
Signed-off-by: abuthahirm <abuthahirm@ami.com>
In GetDns4ServerFromDhcp4(), the return value of Dhcp4->Build()
was not checked. Add error handling and a NULL check on the
resulting Token.Packet before use.
Cc: Saloni Kasbekar <saloni.kasbekar@intel.com>
Cc: Zachary Clark-williams <zachary.clark-williams@intel.com>
Signed-off-by: abuthahirm <abuthahirm@ami.com>
DpcQueueDpc() expands the DPC entry free list when it is empty. If an
allocation fails after at least one entry has already been added to the
free list, the current code continues and inserts the failed allocation
result into the list.
Stop expanding the free list when an allocation fails and the free list
already contains entries. The caller can then continue with one of the
entries that was successfully allocated.
Signed-off-by: Dongyan Qian <qiandongyan@loongson.cn>
Unknown or closed segments still go down the RST path into
TcpSendIpPacket. When no IpIo sender exists for the destination,
each packet logs “No appropriate IpSender.” next to the usual
discard traces and floods the console. The change calls
IpIoFindSender before SEND_RESET and discards when it fails,
which stops that storm and leaves normal RST behavior unchanged
when a sender is present.
Cc: Saloni Kasbekar <saloni.kasbekar@intel.com>
Cc: Zachary Clark-williams <zachary.clark-williams@intel.com>
Cc: Mike Beaton <mjsbeaton@gmail.com>
Signed-off-by: Matthew Graham <Matthew.Graham@amd.com>
The answer section loop in ParseDnsResponse() iterated a counter
AnswerSectionNum from 0 to DnsHeader->AnswersNum using a while loop
with a manual increment at the bottom. Convert it to an equivalent
for loop to make the initialization, condition, and increment
explicit.
Also replace the unconditional Status = EFI_NOT_FOUND assignment
before the loop with a conditional that only sets it when the loop
is never entered (DnsHeader->AnswersNum == 0). ParseDnsResponse()
initializes Status to EFI_SUCCESS at function entry, and the loop
body always overwrites Status, so the pre-assignment was dead code
in the common case. The conditional form makes the intent explicit:
EFI_NOT_FOUND is only the result when there are no answer records.
Cc: Saloni Kasbekar <saloni.kasbekar@intel.com>
Cc: Zachary Clark-williams <zachary.clark-williams@intel.com>
Signed-off-by: abuthahirm <abuthahirm@ami.com>
In Ip4Config2ConvertIfrNvDataToConfigNvData(), when the policy is
changed away from a static configuration (PolicyChanged is TRUE), the
first call to Ip4Cfg2->SetData() was not checking its return value and
always returned EFI_SUCCESS. Fix this to check and return Status on
error, consistent with the second SetData call in the same function.
Cc: Saloni Kasbekar <saloni.kasbekar@intel.com>
Cc: Zachary Clark-williams <zachary.clark-williams@intel.com>
Signed-off-by: abuthahirm <abuthahirm@ami.com>
Issue: UI accepts invalid IPv4 addresses ending with a dot in the
IPv4 Network Configuration page. Examples:
- Local IP Address: 192.168.1.10.
- Subnet Mask: 255.255.255.0.
- Gateway: 2.2.2.2.
- DNS Servers: 1.1.1.1.
Root Cause:
The function Ip4Config2StrToIp converts user-entered IPv4 strings
into numbers. When an address ending with a dot like '1.1.1.1.' is
entered, the code skips over the 4th dot, reaches the string's null
terminator, and incorrectly treats it as valid.
Fix:
Refactor Ip4Config2StrToIp to be a thin wrapper around the existing
BaseLib StrToIpv4Address() helper. After parsing, the EndPointer is
checked to ensure the entire string was consumed (i.e. EndPointer
points to the null terminator). Any trailing characters, including
a trailing dot, cause EFI_INVALID_PARAMETER to be returned.
Signed-off-by: Abuthahir M <abuthahirm@ami.com>
In GoogleTest driver, Ip6OptionGoogleTest.h appears twice in [Sources]
section, so remove the duplicate one.
Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
Include other events from EDKII_HTTP_CALLBACK_EVENT to print failure
information in the event of HTTP Boot failure
Signed-off-by: Saloni Kasbekar <saloni.kasbekar@intel.com>
Install EDKII_HTTP_CALLBACK_PROTOCOL in HttpBootDxe to receive TLS
events from HttpDxe during the HTTP Boot process. When a TLS error
occurs (failed TLS session connection or TLS configuration), print an
error message on screen using AsciiPrint().
The callback is installed in HttpBootInstallCallback() and uninstalled
in HttpBootUninstallCallback(), ensuring TLS errors are only printed
during the HTTP Boot process and not for other TLS accesses.
Signed-off-by: Saloni Kasbekar <saloni.kasbekar@intel.com>
Adds missing `Token.Context = Private` initialization in two MTFTP
write-file functions. Without this, the `Context` field passed to the
MTFTP `WriteFile` callback was uninitialized, which could lead to a
page fault when the callback attempted to access the `Private` driver
context. The corresponding read-file functions already set this field
correctly.
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Resets DhcpSb->IoStatus on stop to prevent a stale state from
persisting which might impact future operations dependent on
the IO status.
Co-authored-by: Wenbo Hou <wenbhou@microsoft.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Ip4StartAutoConfig() and Ip6ConfigStartStatefulAutoConfig() close the
DHCP service binding notify event when the service child is
successfully created, but do not NULL the instance field afterward.
On re-entry, the stale handle passes the non-NULL condition and is
closed a second time, which results in a page fault with memory
protections enabled.
This change sets the event field to NULL immediately after
CloseEvent() so that subsequent calls skip attempting to close the
event again.
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
The Uni file standard specifies that comments begin with the
characters "//". The following files contained incorrectly
formatted C-style comments and have been updated:
NetworkPkg/Application/VConfig/VConfigStrings.uni
NetworkPkg/HttpBootDxe/HttpBootConfigStrings.uni
NetworkPkg/Ip6Dxe/Ip6DxeStrings.uni
NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxeStrings.uni
The problems were identified during testing of the parser
https://github.com/xpahos/edk2-idea.
Signed-off-by: Alexander Gryanko <xpahos@gmail.com>
Replace traditional `#ifndef`/`#define`/`#endif` include guards with
`#pragma` once.
`#pragma once` is a widely supported preprocessor directive that
prevents header files from being included multiple times. It is
supported by all toolchains used to build edk2: GCC, Clang/LLVM, and
MSVC.
Compared to macro-based include guards, `#pragma once`:
- Eliminates the risk of macro name collisions or copy/paste errors
where two headers inadvertently use the same guard macro.
- Eliminate inconsistency in the way include guard macros are named
(e.g., some files use `__FILE_H__`, others use `FILE_H_`, etc.).
- Reduces boilerplate (three lines replaced by one).
- Avoids polluting the macro namespace with guard symbols.
- Can improve build times as the preprocessor can skip re-opening the
file entirely, rather than re-reading it to find the matching
`#endif` ("multiple-include optimization").
- Note that some compilers may already optimize traditional include
guards, by recognzining the idiomatic pattern.
This change is made acknowledging that overall portability of the
code will technically be reduced, as `#pragma once` is not part of the
C/C++ standards.
However, this is considered acceptable given:
1. edk2 already defines a subset of supported compilers in
BaseTools/Conf/tools_def.template, all of which have supported
`#pragma once` for over two decades.
2. There have been concerns raised to the project about inconsistent
include guard naming and potential macro collisions.
Approximate compiler support dates:
- MSVC: Supported since Visual C++ 4.2 (1996)
- GCC: Supported since 3.4 (2004)
(http://gnu.ist.utl.pt/software/gcc/gcc-3.4/changes.html)
- Clang (LLVM based): Since initial release in 2007
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
The comment for the Buffer parameter incorrectly said
"then no the size" instead of "then the size".
This patch fixes the typo only; no functional changes.
Signed-off-by: Dongyan Qian <qiandongyan@loongson.cn>
NetworkPkg will build failed on LOONGARCH64 platform, because
LOONGARCH64 don't support MdePkg/Library/BaseRngLib. So add
MdeModulePkg/Library/BaseRngLibTimerLib as BaseRngLib of
LOONGARCH64 platform.
Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
Cc: Chao Li <lichao@loongson.cn>
XCODE5 toolchain finds this, with error:
WifiConnectionMgrHiiConfigAccess.c:393:29: error: variable 'AvailableCount' set but not used
Fixes: 90b24889f9
Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
Previous PR https://github.com/tianocore/edk2/pull/6087 restored the
ability to build OvmfPkg with -D NETWORK_ENABLE=0.
b3b3cfab7e has broken it again, since the
.dsc references to OvmfPkg/VirtioNetDxe/VirtioNet.inf were moved from
outside !if $(NETWORK_ENABLE) == TRUE to inside it, while the .fdf
references remained outside.
In discussion in https://github.com/tianocore/edk2/pull/11719 it was
decided to move the .fdf references inside the conditional, i.e. not to
include VirtioNetDxe unless the rest of the network stack is being built.
Removal of VirtioNetDxe driver on -D NETWORK_ENABLE=0 has only
been applied to those packages which are already using
OvmfPkg/Dsc/Includes/NetworkComponents.dsc.inc.
f9408b7cc1 introduces new PCDs which also
need to be moved inside a NETWORK_ENABLE test in order to allow building
with -D NETWORK_ENABLE=0, which is also done here.
Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
The DXE_SAL_DRIVER module type was introduced to support
Itanium (IPF) platforms. Since support for Itanium processors has been
dropped, the instances of DXE_SAL_DRIVER have been removed.
Ref: [3cb0a311cb]
Cc: Sachin Ganesh <sachinganesh@ami.com>
Signed-off-by: Sathya Ravichandran <sathyar@ami.com>
CPB, DB, and CDB structs to use DMA-able memory.
Updates the overall SNP_DRIVER allocation to use AllocatePool() instead of PciIo->AllocateBuffer(). This moves this struct out of DMA-able memory.
Allocates the PXE_CDB struct as a pointer instead, using PciIo->AllocateBuffer() for DMA-able memory.
End result:
CPB, DB, and CDB are allocated with individual PciIo->AllocateBuffer() calls with a size of 4096 for CPB and DB. and sizeof(PXE_CDB) for CDB.
Each of these members point to locations within the Allocated Buffer, and all of these pointers are at-least
8-Byte aligned.
SNP_DRIVER is allocated with AllocatePool()
In the SNP_DRIVER structure, the PXE_CDB member is changed to a pointer so we can allocate it with PciIo->AllocateBuffer()
Signed-off-by: Eeshan Londhe <eeshanlondhe@microsoft.com>
When PxeBcLoadBootFile() fails, it reports a status code to notify
listeners (such as telemetry/SEL logging drivers) about the error.
However, the current implementation reports the status code for all
error conditions, including benign cases, such as where the caller passes
Buffer == NULL with EFI_BUFFER_TOO_SMALL to query the required size.
This causes false positive error reports in telemetry systems, as
EFI_BUFFER_TOO_SMALL with Buffer == NULL is an expected and normal
operation for size queries, not an actual error condition.
The PXE-E05 error message is already correctly guarded with the
condition "(Status == EFI_BUFFER_TOO_SMALL) && (Buffer != NULL)",
but the status code reporting was unconditional.
Add a buffer null check before REPORT_STATUS_CODE_WITH_EXTENDED_DATA
to ensure status codes are only reported for actual errors:
- Report when Status != EFI_BUFFER_TOO_SMALL (all other errors)
- Report when Status == EFI_BUFFER_TOO_SMALL AND Buffer != NULL (PXE-E05)
- Skip when Status == EFI_BUFFER_TOO_SMALL AND Buffer == NULL (size query)
This prevents spurious error logs while maintaining proper error
reporting for genuine failures including PXE-E05, PXE-E07, PXE-E09,
PXE-E99, and all other error conditions.
Signed-off-by: Marc Chen <marc.chen@microsoft.com>
Make use the newly introduced ShellPrintHiiDefaultEx() alias and
replace wherever it is possible:
- "ShellPrintHiiEx (-1, -1, NULL,"
with:
- "ShellPrintHiiDefaultEx ("
No functional change is introduced.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
edk2 is dropping support for the ARM32 architecture. This
commit removes ARM32 code from NetworkPkg. This also drops
irrelevant VALID_ARCHITECTURES comments from infs that are
not arch specific.
Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
CLANGDWARF generates a build error for calling convention
mismatch in UdpRead(), UdpWrite(), and Configure() mock
functions. Add EFIAPI so mock function matches function
prototype of function being mocked.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
CLANGDWARF generates build error for missing braces when
initializing a complex structure. Change initialization of
EFI_DHCP6_IA local variable to a call to ZeroMem() instead.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
- Fix WifiMgrOnTimerTick to ensure the timer does
not exit early when a disconnect is pending,
allowing UI-initiated disconnects to complete as
expected.
Signed-off-by: Zachary Clark-Williams <Zachary.Clark-Williams@intel.com>
Commit 7c204d7 changed the behavior of the WiFi
Connection Manager. It no longer scans for available
networks when the driver loads, because scanning
during that time disrupts connections for other
features. To avoid blocking other processes, the
driver should initiate a scan only when appropriate.
This update introduces a one-time scan that occurs
when the user opens the network settings page in
the UI, enables WiFi, and then opens the network
list page to view available networks.
Signed-off-by: Zachary Clark-Williams <zachary.clark-williams@intel.com>
Replace timer eventclose with scan timerset in WifiConnectionManagerDxe.
This change ensures that the driver sets and manages scan timers
correctly without requiring a reload when the user enables WiFi and
initiates a scan for available networks.
By using scan timerset directly, the driver maintains consistent
behavior across WiFi sessions and avoids redundant event handling.
Signed-off-by: Zachary Clark-Williams <zachary.clark-williams@intel.com>
Add missing EAP-TLS option to HII configuration
Implemented support for EAP-TLS authentication in
the WifiConnectionManagerDxe HII interface. This
change ensures that the EAP-TLS option is available
for selection in the UI, addressing cases where it
was previously missing.
Signed-off-by: Zachary Clark-Williams <Zachary.Clark-Williams@intel.com>
Update unit tests to use GoogleTestLib.h instead
of gtest.h so the edk2 extensions for google tests
are always available.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>