deepin-kernel/drivers
Michael C. Pratt 8783786694 nvmem: layouts: u-boot-env: remove crc32 endianness conversion
commit 2d7521aa26ec2dc8b877bb2d1f2611a2df49a3cf 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>
(cherry picked from commit 48e8791843206baf76827df1b6ee3cb88a2a17d8)
2025-07-28 15:19:09 +08:00
..
accel accel/qaic: Mask out SR-IOV PCI resources 2025-06-10 16:18:00 +08:00
accessibility
acpi Revert "ACPI: battery: negate current when discharging" 2025-07-22 16:16:42 +08:00
amba
android
ata ata: pata_cs5536: fix build on 32-bit UML 2025-07-14 10:42:16 +08:00
atm atm: idt77252: Add missing `dma_map_error()` 2025-07-22 16:16:46 +08:00
auxdisplay auxdisplay: charlcd: Partially revert "Move hwidth and bwidth to struct hd44780_common" 2025-06-10 10:34:56 +08:00
base pmdomain: governor: Consider CPU latency tolerance from pm_domain_cpu_gov 2025-07-28 15:19:03 +08:00
bcma
block ublk: sanity check add_dev input for underflow 2025-07-22 16:16:46 +08:00
bluetooth Bluetooth: btusb: QCA: Fix downloading wrong NVM for WCN6855 GF variant without board ID 2025-07-28 15:19:06 +08:00
bus Revert "bus: ti-sysc: Probe for l4_wkup and l4_cfg interconnect devices first" 2025-07-03 11:32:05 +08:00
cache
cdrom
cdx
char ipmi:msghandler: Fix potential memory corruption in ipmi_create_user() 2025-07-22 16:16:40 +08:00
clk clk: rockchip: rk3036: mark ddrphy as critical 2025-07-03 11:32:03 +08:00
clocksource sw64: cpufreq: optimize the granularity of cpufreq 2025-06-19 13:39:49 +08:00
comedi comedi: Fix initialization of data for instructions that write to subdevice 2025-07-28 15:19:04 +08:00
connector
counter counter: interrupt-cnt: Protect enable/disable OPs with mutex 2025-06-20 14:40:04 +08:00
cpufreq Revert "cpufreq: tegra186: Share policy per cluster" 2025-07-03 11:32:12 +08:00
cpuidle cpuidle: menu: Avoid discarding useful information 2025-06-10 10:35:01 +08:00
crypto drivers/crypto/ccp: fix soft lockup warning in psp_mutex_lock_timeout() 2025-07-21 23:57:48 +08:00
cxl cxl/region: Add a dev_err() on missing target list entries 2025-07-09 09:49:55 +08:00
dax
dca
devfreq
dio
dma dmaengine: nbpfaxi: Fix memory corruption in probe() 2025-07-28 15:19:02 +08:00
dma-buf dma-buf: fix timeout handling in dma_resv_wait_timeout v2 2025-07-14 10:42:18 +08:00
edac EDAC/amd64: Fix size calculation for Non-Power-of-Two DIMMs 2025-07-09 09:50:01 +08:00
eisa
extcon
firewire
firmware firmware: arm_scmi: Ensure that the message-id supports fastchannel 2025-07-09 09:50:04 +08:00
fpga fpga: fix potential null pointer deref in fpga_mgr_test_img_load_sgt() 2025-06-20 14:40:05 +08:00
fsi
gnss
gpio gpio: mlxbf3: only get IRQ for device instance 0 2025-07-03 11:32:13 +08:00
gpu drm/amdgpu/gfx8: reset compute ring wptr on the GPU on resume 2025-07-28 15:19:01 +08:00
greybus
hid HID: core: do not bypass hid_hw_raw_request 2025-07-28 15:19:01 +08:00
hsi HSI: ssi_protocol: Fix use after free vulnerability in ssi_protocol Driver Due to Race Condition 2025-05-09 18:47:30 +08:00
hte
hv Drivers: hv: vmbus: Add utility function for querying ring size 2025-07-09 09:49:58 +08:00
hwmon hwmon: (corsair-cpro) Validate the size of the received input buffer 2025-07-28 15:19:06 +08:00
hwspinlock
hwtracing coresight: Only check bottom two claim bits 2025-07-09 09:49:56 +08:00
i2c i2c: omap: fix deprecated of_property_read_bool() use 2025-07-28 15:19:09 +08:00
i3c i3c: master: svc: Fix implicit fallthrough in svc_i3c_master_ibi_work() 2025-06-10 16:18:05 +08:00
idle intel_idle: add Clearwater Forest SoC support 2025-06-06 21:44:35 +08:00
iio iio: adc: stm32-adc: Fix race in installing chained IRQ handler 2025-07-28 15:19:04 +08:00
infiniband RDMA/mlx5: Fix vport loopback for MPV device 2025-07-14 10:42:12 +08:00
input Input: xpad - set correct controller type for Acer NGR200 2025-07-28 15:19:01 +08:00
interconnect
iommu iommu/rockchip: prevent iommus dead loop when two masters share one IOMMU 2025-07-14 10:42:18 +08:00
ipack
irqchip sw64: delete useless I/O access in VM and emulator 2025-07-08 15:28:32 +08:00
isdn
leds leds: multicolor: Fix intensity setting while SW blinking 2025-07-09 09:49:55 +08:00
macintosh
mailbox mailbox: Not protect module_put with spin_lock_irqsave 2025-07-09 09:49:54 +08:00
mcb mcb: fix a double free bug in chameleon_parse_gdd() 2025-05-09 23:02:29 +08:00
md dm-bufio: fix sched in atomic context 2025-07-28 15:19:01 +08:00
media media: uvcvideo: Rollback non processed entities on error 2025-07-09 09:50:04 +08:00
memory
memstick memstick: core: Zero initialize id_reg in h_memstick_read_dev_id() 2025-07-28 15:19:02 +08:00
message
mfd mfd: max14577: Fix wakeup source leaks on device unbind 2025-07-09 09:49:54 +08:00
misc misc: tps6594-pfsm: Add NULL pointer check in tps6594_pfsm_probe() 2025-07-09 09:49:56 +08:00
mmc mmc: sdhci_am654: Workaround for Errata i2312 2025-07-28 15:19:03 +08:00
most
mtd mtd: spinand: fix memory leak of ECC engine conf 2025-07-14 10:42:17 +08:00
mux
net hv_netvsc: Set VF priv_flags to IFF_NO_ADDRCONF before open to prevent IPv6 addrconf 2025-07-28 15:19:07 +08:00
nfc
ntb ntb_hw_amd: Add NTB PCI ID for new gen CPU 2025-05-09 23:02:49 +08:00
nubus
nvdimm libnvdimm/labels: Fix divide error in nd_label_data_init() 2025-06-10 10:34:52 +08:00
nvme nvme: fix misaccounting of nvme-mpath inflight I/O 2025-07-28 15:19:05 +08:00
nvmem nvmem: layouts: u-boot-env: remove crc32 endianness conversion 2025-07-28 15:19:09 +08:00
of of: resolver: Fix device node refcount leakage in of_resolve_phandles() 2025-05-09 22:55:07 +08:00
opp
parisc
parport
pci pci: Update the number of outbound and inbound 2025-07-28 09:43:37 +08:00
pcmcia
peci
perf perf/dwc_pcie: Fix typos in event names 2025-07-22 16:16:49 +08:00
phy phy: tegra: xusb: Disable periodic tracking on Tegra234 2025-07-28 15:19:00 +08:00
pinctrl pinctrl: qcom: msm: mark certain pins as invalid for interrupts 2025-07-22 16:16:41 +08:00
platform platform/x86: think-lmi: Fix sysfs group cleanup 2025-07-14 10:42:19 +08:00
pmdomain pmdomain: imx: gpcv2: use proper helper for property detection 2025-06-10 10:35:02 +08:00
pnp
power power: supply: bq27xxx: Retrieve again when busy 2025-07-03 11:32:00 +08:00
powercap powercap: intel_rapl: Do not change CLAMPING bit if ENABLE bit cannot be changed 2025-07-14 10:42:18 +08:00
pps
ps3
ptp ptp: allow reading of currently dialed frequency to succeed on free-running clocks 2025-07-03 11:32:10 +08:00
pwm pwm: mediatek: Ensure to disable clocks in error path 2025-07-22 16:16:43 +08:00
rapidio drivers/rapidio/rio_cm.c: prevent possible heap overwrite 2025-07-03 11:32:06 +08:00
ras
regulator regulator: pwm-regulator: Manage boot-on with disabled PWM channels 2025-07-28 15:19:08 +08:00
remoteproc remoteproc: core: Release rproc->clean_table after rproc_attach() fails 2025-07-03 11:31:57 +08:00
reset reset:phytium: Add the driver for reset controller. 2025-05-08 14:02:47 +08:00
rpmsg rpmsg: qcom_smd: Fix uninitialized return variable in __qcom_smd_send() 2025-06-20 14:39:54 +08:00
rtc rtc: cmos: use spin_lock_irqsave in cmos_interrupt 2025-07-14 10:42:10 +08:00
s390 s390/pkey: Prevent overflow in size calculation for memdup_user() 2025-07-09 09:49:59 +08:00
sbus
scsi scsi: Bypass certain SCSI commands on disks with "use_192_bytes_for_3f" attribute 2025-07-14 10:47:39 +08:00
sh
siox
slimbus
soc soc: aspeed: lpc-snoop: Don't disable channels that aren't enabled 2025-07-28 15:19:03 +08:00
soundwire soundwire: amd: fix for clearing command status register 2025-07-28 15:19:04 +08:00
spi spi: Add check for 8-bit transfer with 8 IO mode support 2025-07-28 15:19:01 +08:00
spmi spmi: Only use Hikey 970 SPMI controller driver when ARM64 2025-06-19 16:56:24 +08:00
ssb
staging ANDROID: ashmem: Export is_ashmem_file 2025-07-15 21:05:23 +08:00
target scsi: target: Fix NULL pointer dereference in core_scsi3_decode_spec_i_port() 2025-07-14 10:42:16 +08:00
tc
tee tee: Prevent size calculation wraparound on 32-bit kernels 2025-07-03 11:32:05 +08:00
thermal thermal: intel: x86_pkg_temp_thermal: Fix bogus trip temperature 2025-06-10 16:18:04 +08:00
thunderbolt thunderbolt: Fix bit masking in tb_dp_port_set_hops() 2025-07-28 15:19:01 +08:00
tty pch_uart: Fix dma_sync_sg_for_device() nents value 2025-07-28 15:19:01 +08:00
ufs scsi: ufs: core: Fix clk scaling to be conditional in reset and restore 2025-07-14 10:42:15 +08:00
uio uio_hv_generic: Align ring size to system page 2025-07-09 09:49:58 +08:00
usb usb: dwc3: qcom: Don't leave BCR asserted 2025-07-28 15:19:08 +08:00
vdpa vdpa/mlx5: Fix mlx5_vdpa_get_config() endianness on big-endian machines 2025-06-10 10:35:00 +08:00
vfio vfio/type1: Fix error unwind in migration dirty bitmap allocation 2025-06-20 14:39:23 +08:00
vhost vhost-scsi: Return queue full for page alloc failures during copy 2025-06-10 10:35:00 +08:00
video dummycon: Trigger redraw when switching consoles with deferred takeover 2025-07-09 09:49:58 +08:00
virt
virtio virtio_ring: Fix data race by tagging event_triggered as racy for KCSAN 2025-06-10 10:34:49 +08:00
vlynq
w1
watchdog watchdog: da9052_wdt: respect TWDMIN 2025-07-03 11:32:05 +08:00
xen xen/x86: fix initial memory balloon target 2025-06-20 14:38:59 +08:00
zorro
Kconfig
Makefile
OWNERS