linux-yocto/drivers
Michael C. Pratt 3b02d7d87d nvmem: layouts: u-boot-env: remove crc32 endianness conversion
commit 2d7521aa26 upstream.

On 11 Oct 2022, it was reported that the crc32 verification
of the u-boot environment failed only on big-endian systems
for the u-boot-env nvmem layout driver with the following error.

  Invalid calculated CRC32: 0x88cd6f09 (expected: 0x096fcd88)

This problem has been present since the driver was introduced,
and before it was made into a layout driver.

The suggested fix at the time was to use further endianness
conversion macros in order to have both the stored and calculated
crc32 values to compare always represented in the system's endianness.
This was not accepted due to sparse warnings
and some disagreement on how to handle the situation.
Later on in a newer revision of the patch, it was proposed to use
cpu_to_le32() for both values to compare instead of le32_to_cpu()
and store the values as __le32 type to remove compilation errors.

The necessity of this is based on the assumption that the use of crc32()
requires endianness conversion because the algorithm uses little-endian,
however, this does not prove to be the case and the issue is unrelated.

Upon inspecting the current kernel code,
there already is an existing use of le32_to_cpu() in this driver,
which suggests there already is special handling for big-endian systems,
however, it is big-endian systems that have the problem.

This, being the only functional difference between architectures
in the driver combined with the fact that the suggested fix
was to use the exact same endianness conversion for the values
brings up the possibility that it was not necessary to begin with,
as the same endianness conversion for two values expected to be the same
is expected to be equivalent to no conversion at all.

After inspecting the u-boot environment of devices of both endianness
and trying to remove the existing endianness conversion,
the problem is resolved in an equivalent way as the other suggested fixes.

Ultimately, it seems that u-boot is agnostic to endianness
at least for the purpose of environment variables.
In other words, u-boot reads and writes the stored crc32 value
with the same endianness that the crc32 value is calculated with
in whichever endianness a certain architecture runs on.

Therefore, the u-boot-env driver does not need to convert endianness.
Remove the usage of endianness macros in the u-boot-env driver,
and change the type of local variables to maintain the same return type.

If there is a special situation in the case of endianness,
it would be a corner case and should be handled by a unique "compatible".

Even though it is not necessary to use endianness conversion macros here,
it may be useful to use them in the future for consistent error printing.

Fixes: d5542923f2 ("nvmem: add driver handling U-Boot environment variables")
Reported-by: INAGAKI Hiroshi <musashino.open@gmail.com>
Link: https://lore.kernel.org/all/20221011024928.1807-1-musashino.open@gmail.com
Cc: stable@vger.kernel.org
Signed-off-by: "Michael C. Pratt" <mcpratt@pm.me>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
Link: https://lore.kernel.org/r/20250716144210.4804-1-srini@kernel.org
[ applied changes to drivers/nvmem/u-boot-env.c before code was moved to
  drivers/nvmem/layouts/u-boot-env.c ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-07-24 08:51:55 +02:00
..
accessibility
acpi Revert "ACPI: battery: negate current when discharging" 2025-07-17 18:32:08 +02:00
amba
android
ata ata: pata_cs5536: fix build on 32-bit UML 2025-07-10 15:59:50 +02:00
atm atm: idt77252: Add missing dma_map_error() 2025-07-17 18:32:13 +02:00
auxdisplay auxdisplay: charlcd: Partially revert "Move hwidth and bwidth to struct hd44780_common" 2025-06-04 14:40:07 +02:00
base pmdomain: governor: Consider CPU latency tolerance from pm_domain_cpu_gov 2025-07-24 08:51:49 +02:00
bcma
block nbd: fix uaf in nbd_genl_connect() error path 2025-07-17 18:32:11 +02:00
bluetooth Bluetooth: btusb: QCA: Fix downloading wrong NVM for WCN6855 GF variant without board ID 2025-07-24 08:51:52 +02:00
bus Revert "bus: ti-sysc: Probe for l4_wkup and l4_cfg interconnect devices first" 2025-06-27 11:07:36 +01:00
cdrom
char ipmi:msghandler: Fix potential memory corruption in ipmi_create_user() 2025-07-17 18:32:07 +02:00
clk clk: rockchip: rk3036: mark ddrphy as critical 2025-06-27 11:07:34 +01:00
clocksource clocksource: mips-gic-timer: Enable counter when CPUs start 2025-06-04 14:40:12 +02:00
comedi comedi: Fix initialization of data for instructions that write to subdevice 2025-07-24 08:51:51 +02:00
connector
counter counter: interrupt-cnt: Protect enable/disable OPs with mutex 2025-06-27 11:07:16 +01:00
cpufreq Revert "cpufreq: tegra186: Share policy per cluster" 2025-06-27 11:07:40 +01:00
cpuidle cpuidle: menu: Avoid discarding useful information 2025-06-04 14:40:11 +02:00
crypto crypto: marvell/cesa - Do not chain submitted requests 2025-06-27 11:07:25 +01:00
cxl
dax
dca
devfreq
dio
dma dmaengine: nbpfaxi: Fix memory corruption in probe() 2025-07-24 08:51:49 +02:00
dma-buf dma-buf: fix timeout handling in dma_resv_wait_timeout v2 2025-07-10 15:59:53 +02:00
edac EDAC/altera: Use correct write width with the INTTEST register 2025-06-27 11:07:29 +01:00
eisa
extcon
firewire
firmware firmware: arm_scmi: Ensure that the message-id supports fastchannel 2025-07-06 10:58:04 +02:00
fpga fpga: altera-cvp: Increase credit timeout 2025-06-04 14:40:10 +02:00
fsi
gnss
gpio gpio: pca953x: fix IRQ storm on system wake up 2025-06-04 14:40:01 +02:00
gpu drm/tegra: nvdec: Fix dma_alloc_coherent error check 2025-07-17 18:32:11 +02:00
greybus
hid HID: mcp2221: Set driver data before I2C adapter add 2025-07-24 08:51:54 +02:00
hsi HSI: ssi_protocol: Fix use after free vulnerability in ssi_protocol Driver Due to Race Condition 2025-04-25 10:43:47 +02:00
hte
hv Drivers: hv: vmbus: Add utility function for querying ring size 2025-07-06 10:57:58 +02:00
hwmon hwmon: (corsair-cpro) Validate the size of the received input buffer 2025-07-24 08:51:52 +02:00
hwspinlock
hwtracing coresight: Only check bottom two claim bits 2025-07-06 10:57:55 +02:00
i2c i2c: stm32: fix the device used for the DMA map 2025-07-24 08:51:47 +02:00
i3c i3c: master: svc: Fix implicit fallthrough in svc_i3c_master_ibi_work() 2025-06-04 14:40:22 +02:00
idle cpuidle, intel_idle: Fix CPUIDLE_FLAG_IBRS 2025-03-13 12:53:11 +01:00
iio iio: adc: stm32-adc: Fix race in installing chained IRQ handler 2025-07-24 08:51:50 +02:00
infiniband RDMA/mlx5: Fix CC counters query for MPV 2025-07-10 15:59:46 +02:00
input Input: xpad - set correct controller type for Acer NGR200 2025-07-24 08:51:47 +02:00
interconnect
iommu iommu/amd: Ensure GA log notifier callbacks finish running before module unload 2025-06-27 11:07:34 +01:00
ipack
irqchip irqchip/gic-v2m: Prevent use after free of gicv2m_get_fwnode() 2025-05-09 09:41:45 +02:00
isdn
leds leds: multicolor: Fix intensity setting while SW blinking 2025-07-06 10:57:54 +02:00
macintosh
mailbox mailbox: Not protect module_put with spin_lock_irqsave 2025-07-06 10:57:54 +02:00
mcb mcb: fix a double free bug in chameleon_parse_gdd() 2025-05-02 07:46:57 +02:00
md raid10: cleanup memleak at raid10_make_request 2025-07-17 18:32:11 +02:00
media media: uvcvideo: Rollback non processed entities on error 2025-07-06 10:58:03 +02:00
memory memory: omap-gpmc: drop no compatible check 2025-04-10 14:33:39 +02:00
memstick memstick: core: Zero initialize id_reg in h_memstick_read_dev_id() 2025-07-24 08:51:49 +02:00
message
mfd mfd: max14577: Fix wakeup source leaks on device unbind 2025-07-06 10:57:54 +02:00
misc VMCI: fix race between vmci_host_setup_notify and vmci_ctx_unset_notify 2025-06-27 11:07:25 +01:00
mmc mmc: sdhci_am654: Workaround for Errata i2312 2025-07-24 08:51:49 +02:00
most
mtd mtd: spinand: fix memory leak of ECC engine conf 2025-07-10 15:59:51 +02:00
mux
net net/mlx5: Correctly set gso_size when LRO is used 2025-07-24 08:51:53 +02:00
nfc
ntb ntb_hw_amd: Add NTB PCI ID for new gen CPU 2025-05-02 07:47:04 +02:00
nubus
nvdimm libnvdimm/labels: Fix divide error in nd_label_data_init() 2025-06-04 14:40:04 +02:00
nvme nvme: fix misaccounting of nvme-mpath inflight I/O 2025-07-24 08:51:52 +02:00
nvmem nvmem: layouts: u-boot-env: remove crc32 endianness conversion 2025-07-24 08:51:55 +02:00
of of: module: add buffer overflow check in of_modalias() 2025-05-02 07:47:08 +02:00
opp OPP: OF: Fix an OF node leak in _opp_add_static_v2() 2025-02-21 13:49:02 +01:00
parisc
parport parport_pc: add support for ASIX AX99100 2025-02-21 13:50:11 +01:00
pci PCI: apple: Set only available ports up 2025-07-06 10:57:58 +02:00
pcmcia
peci
perf perf/arm-cmn: Initialise cmn->cpu earlier 2025-06-04 14:40:25 +02:00
phy phy: tegra: xusb: Fix unbalanced regulator disable in UTMI PHY mode 2025-07-24 08:51:47 +02:00
pinctrl pinctrl: qcom: msm: mark certain pins as invalid for interrupts 2025-07-17 18:32:08 +02:00
platform platform/x86: ideapad-laptop: use usleep_range() for EC polling 2025-07-17 18:32:04 +02:00
pnp
power power: supply: bq27xxx: Retrieve again when busy 2025-06-27 11:07:32 +01:00
powercap powercap: call put_device() on an error path in powercap_register_control_type() 2025-03-28 21:58:50 +01:00
pps pps: Fix a use-after-free 2025-02-21 13:49:55 +01:00
ps3
ptp ptp: allow reading of currently dialed frequency to succeed on free-running clocks 2025-06-27 11:07:39 +01:00
pwm pwm: mediatek: Ensure to disable clocks in error path 2025-07-17 18:32:09 +02:00
rapidio drivers/rapidio/rio_cm.c: prevent possible heap overwrite 2025-06-27 11:07:36 +01:00
ras
regulator regulator: gpio: Fix the out-of-bounds access to drvdata::gpiods 2025-07-10 15:59:44 +02:00
remoteproc remoteproc: core: Release rproc->clean_table after rproc_attach() fails 2025-06-27 11:07:31 +01:00
reset
rpmsg rpmsg: qcom_smd: Fix uninitialized return variable in __qcom_smd_send() 2025-06-27 11:07:15 +01:00
rtc rtc: cmos: use spin_lock_irqsave in cmos_interrupt 2025-07-10 15:59:43 +02:00
s390 s390/pkey: Prevent overflow in size calculation for memdup_user() 2025-07-06 10:57:59 +02:00
sbus
scsi scsi: qla4xxx: Fix missing DMA mapping error in qla4xxx_alloc_pdu() 2025-07-10 15:59:46 +02:00
sh
siox
slimbus slimbus: messaging: Free transaction ID in delayed interrupt scenario 2025-03-13 12:53:22 +01:00
soc soc: aspeed: lpc-snoop: Don't disable channels that aren't enabled 2025-07-24 08:51:50 +02:00
soundwire soundwire: slave: fix an OF node reference leak in soundwire slave device 2025-04-10 14:33:35 +02:00
spi spi: spi-fsl-dspi: Clear completion counter before initiating transfer 2025-07-10 15:59:47 +02:00
spmi
ssb
staging staging: rtl8723bs: Avoid memset() in aes_cipher() and aes_decipher() 2025-07-06 10:58:01 +02:00
target scsi: target: Fix NULL pointer dereference in core_scsi3_decode_spec_i_port() 2025-07-10 15:59:50 +02:00
tc
tee tee: Prevent size calculation wraparound on 32-bit kernels 2025-06-27 11:07:36 +01:00
thermal thermal/drivers/qoriq: Power down TMU on system suspend 2025-06-04 14:40:03 +02:00
thunderbolt thunderbolt: Fix bit masking in tb_dp_port_set_hops() 2025-07-24 08:51:47 +02:00
tty pch_uart: Fix dma_sync_sg_for_device() nents value 2025-07-24 08:51:47 +02:00
ufs scsi: ufs: core: Fix spelling of a sysfs attribute name 2025-07-10 15:59:46 +02:00
uio uio_hv_generic: Align ring size to system page 2025-07-06 10:57:58 +02:00
usb usb: dwc3: qcom: Don't leave BCR asserted 2025-07-24 08:51:55 +02:00
vdpa vdpa/mlx5: Fix oversized null mkey longer than 32bit 2025-04-25 10:43:40 +02:00
vfio vfio/type1: Fix error unwind in migration dirty bitmap allocation 2025-06-27 11:07:11 +01:00
vhost vhost-scsi: protect vq->log_used with vq->mutex 2025-07-17 18:32:15 +02:00
video fbdev: hyperv_fb: Convert comma to semicolon 2025-07-06 10:58:03 +02:00
virt drivers: virt: acrn: hsm: Use kzalloc to avoid info leak in pmcmd_ioctl 2025-03-13 12:53:23 +01:00
virtio virtio_ring: Fix data race by tagging event_triggered as racy for KCSAN 2025-06-04 14:40:01 +02:00
vlynq
w1
watchdog watchdog: da9052_wdt: respect TWDMIN 2025-06-27 11:07:35 +01:00
xen xenbus: Allow PVH dom0 a non-local xenstore 2025-06-04 14:40:18 +02:00
zorro
Kconfig
Makefile