Skip to content

Commit a5a16e4

Browse files
geertuborkmann
authored andcommitted
xsk: Fix umem fill/completion queue mmap on 32-bit
With gcc-4.1.2 on 32-bit: net/xdp/xsk.c:663: warning: integer constant is too large for ‘long’ type net/xdp/xsk.c:665: warning: integer constant is too large for ‘long’ type Add the missing "ULL" suffixes to the large XDP_UMEM_PGOFF_*_RING values to fix this. net/xdp/xsk.c:663: warning: comparison is always false due to limited range of data type net/xdp/xsk.c:665: warning: comparison is always false due to limited range of data type "unsigned long" is 32-bit on 32-bit systems, hence the offset is truncated, and can never be equal to any of the XDP_UMEM_PGOFF_*_RING values. Use loff_t (and the required cast) to fix this. Fixes: 423f383 ("xsk: add umem fill queue support and mmap") Fixes: fe23083 ("xsk: add umem completion queue support and mmap") Signed-off-by: Geert Uytterhoeven <[email protected]> Acked-by: Björn Töpel <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent 23316a3 commit a5a16e4

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/uapi/linux/if_xdp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ struct xdp_statistics {
6363
/* Pgoff for mmaping the rings */
6464
#define XDP_PGOFF_RX_RING 0
6565
#define XDP_PGOFF_TX_RING 0x80000000
66-
#define XDP_UMEM_PGOFF_FILL_RING 0x100000000
67-
#define XDP_UMEM_PGOFF_COMPLETION_RING 0x180000000
66+
#define XDP_UMEM_PGOFF_FILL_RING 0x100000000ULL
67+
#define XDP_UMEM_PGOFF_COMPLETION_RING 0x180000000ULL
6868

6969
/* Rx/Tx descriptor */
7070
struct xdp_desc {

net/xdp/xsk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ static int xsk_getsockopt(struct socket *sock, int level, int optname,
643643
static int xsk_mmap(struct file *file, struct socket *sock,
644644
struct vm_area_struct *vma)
645645
{
646-
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
646+
loff_t offset = (loff_t)vma->vm_pgoff << PAGE_SHIFT;
647647
unsigned long size = vma->vm_end - vma->vm_start;
648648
struct xdp_sock *xs = xdp_sk(sock->sk);
649649
struct xsk_queue *q = NULL;

0 commit comments

Comments
 (0)