Skip to content

Commit 9dfbe9f

Browse files
committed
Limit max_req_size under arm64 (or any other platform that uses swiotlb) to prevent potential buffer overflow due to bouncing.
Signed-off-by: Yaroslav Rosomakho <[email protected]>
1 parent 338c41c commit 9dfbe9f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/mmc/host/bcm2835-mmc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <linux/dmaengine.h>
3939
#include <linux/dma-mapping.h>
4040
#include <linux/of_dma.h>
41+
#include <linux/swiotlb.h>
4142

4243
#include "sdhci.h"
4344

@@ -1374,7 +1375,10 @@ static int bcm2835_mmc_add_host(struct bcm2835_host *host)
13741375
}
13751376
#endif
13761377
mmc->max_segs = 128;
1377-
mmc->max_req_size = 524288;
1378+
if (swiotlb_max_segment())
1379+
mmc->max_req_size = (1 << IO_TLB_SHIFT) * IO_TLB_SEGSIZE;
1380+
else
1381+
mmc->max_req_size = 524288;
13781382
mmc->max_seg_size = mmc->max_req_size;
13791383
mmc->max_blk_size = 512;
13801384
mmc->max_blk_count = 65535;

0 commit comments

Comments
 (0)