Commit 425dab97 authored by Dominique Martinet's avatar Dominique Martinet Committed by Will Deacon
Browse files

FROMGIT: swiotlb: add overflow checks to swiotlb_bounce



This is a follow-up on 5f89468e ("swiotlb: manipulate orig_addr
when tlb_addr has offset") which fixed unaligned dma mappings,
making sure the following overflows are caught:

- offset of the start of the slot within the device bigger than
requested address' offset, in other words if the base address
given in swiotlb_tbl_map_single to create the mapping (orig_addr)
was after the requested address for the sync (tlb_offset) in the
same block:

 |------------------------------------------| block
              <----------------------------> mapped part of the block
              ^
              orig_addr
       ^
       invalid tlb_addr for sync

- if the resulting offset was bigger than the allocation size
this one could happen if the mapping was not until the end. e.g.

 |------------------------------------------| block
      <---------------------> mapped part of the block
      ^                               ^
      orig_addr                       invalid tlb_addr

Both should never happen so print a warning and bail out without trying
to adjust the sizes/offsets: the first one could try to sync from
orig_addr to whatever is left of the requested size, but the later
really has nothing to sync there...

Signed-off-by: default avatarDominique Martinet <dominique.martinet@atmark-techno.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: default avatarBumyong Lee <bumyong.lee@samsung.com>
Cc: Chanho Park <chanho61.park@samsung.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad@kernel.org>
(cherry picked from commit 868c9ddc swiotlb/devel/for-linus-5.15)
Signed-off-by: default avatarWill Deacon <willdeacon@google.com>
Bug: 190591509
Change-Id: I87aaae6b0a5e385abe8e579cb75abe33b2f2c2be
parent 23af5c3e
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment