Skip to content

pstore: fix two ramoops error-path bugs

Andrea Parri lkml stable 1 version Applied

Status from this message: Applied to for-next/pstore, thanks!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 4 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/2pstore: don't leave an ERR_PTR in the ramoops zone pointerfs/pstore/ram.c+1 -00 replies
2/2pstore: reject persistent RAM zones too small for the buffer headerfs/pstore/ram_core.c+6 -03 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] pstore: fix two ramoops error-path bugs

Two bugs in the ramoops error paths, found by review and confirmed with test-only reproducers against an unfixed kernel:

- ramoops_init_prz() stores persistent_ram_new()'s ERR_PTR in the zone pointer and returns without clearing it; the probe error path then passes it to persistent_ram_free(), which dereferences it and oopses.

- persistent_ram_buffer_map() computes buffer_size = size - sizeof(struct persistent_ram_buffer) with no lower bound, so a zone no larger than the header underflows buffer_size to a huge value and defeats the bounds checks in the write paths.

The second patch adds a new failure return from persistent_ram_new() for undersized zones, which is exactly the error path that exposes the first
bug: a tiny zone now leaves an ERR_PTR behind on cleanup. Applied without the first patch, it turns the memory-corruption bug into a probe-time panic on the same input, so the ERR_PTR fix is sent first.

Andrea Parri (2):
pstore: don't leave an ERR_PTR in the ramoops zone pointer
pstore: reject persistent RAM zones too small for the buffer header

 fs/pstore/ram.c      | 1 +
 fs/pstore/ram_core.c | 6 ++++++
 2 files changed, 7 insertions(+)
Signature · 1 line
2.53.0