Skip to content

Commit

Permalink
pstore/ram: Use memcpy_fromio() to save old buffer
Browse files Browse the repository at this point in the history
The ramoops buffer may be mapped as either I/O memory or uncached
memory.  On ARM64, this results in a device-type (strongly-ordered)
mapping.  Since unnaligned accesses to device-type memory will
generate an alignment fault (regardless of whether or not strict
alignment checking is enabled), it is not safe to use memcpy().
memcpy_fromio() is guaranteed to only use aligned accesses, so use
that instead.

Signed-off-by: Andrew Bresticker <[email protected]>
Signed-off-by: Enric Balletbo Serra <[email protected]>
Reviewed-by: Puneet Kumar <[email protected]>
Signed-off-by: Kees Cook <[email protected]>
Cc: [email protected]
  • Loading branch information
abrestic authored and kees committed Sep 8, 2016
1 parent 7e75678 commit d771fdf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/pstore/ram_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ void persistent_ram_save_old(struct persistent_ram_zone *prz)
}

prz->old_log_size = size;
memcpy(prz->old_log, &buffer->data[start], size - start);
memcpy(prz->old_log + size - start, &buffer->data[0], start);
memcpy_fromio(prz->old_log, &buffer->data[start], size - start);
memcpy_fromio(prz->old_log + size - start, &buffer->data[0], start);
}

int notrace persistent_ram_write(struct persistent_ram_zone *prz,
Expand Down

0 comments on commit d771fdf

Please sign in to comment.