lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190627220836.2572684-4-jonathan.lemon@gmail.com>
Date:   Thu, 27 Jun 2019 15:08:33 -0700
From:   Jonathan Lemon <jonathan.lemon@...il.com>
To:     <netdev@...r.kernel.org>, <bjorn.topel@...el.com>,
        <magnus.karlsson@...el.com>, <saeedm@...lanox.com>,
        <maximmi@...lanox.com>, <brouer@...hat.com>
CC:     <kernel-team@...com>
Subject: [PATCH 3/6 bpf-next] Always check the recycle stack when using the umem fq.

The specific _rq variants are deprecated, and will be removed next.

Signed-off-by: Jonathan Lemon <jonathan.lemon@...il.com>
---
 include/net/xdp_sock.h | 22 +++-------------------
 net/xdp/xsk.c          | 22 +++++++++++++++++++---
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/include/net/xdp_sock.h b/include/net/xdp_sock.h
index 7df7b417ac53..55f5f27ef22a 100644
--- a/include/net/xdp_sock.h
+++ b/include/net/xdp_sock.h
@@ -99,33 +99,17 @@ static inline dma_addr_t xdp_umem_get_dma(struct xdp_umem *umem, u64 addr)
 /* Reuse-queue aware version of FILL queue helpers */
 static inline bool xsk_umem_has_addrs_rq(struct xdp_umem *umem, u32 cnt)
 {
-	struct xdp_umem_fq_reuse *rq = umem->fq_reuse;
-
-	if (rq->length >= cnt)
-		return true;
-
-	return xsk_umem_has_addrs(umem, cnt - rq->length);
+	return xsk_umem_has_addrs(umem, cnt);
 }
 
 static inline u64 *xsk_umem_peek_addr_rq(struct xdp_umem *umem, u64 *addr)
 {
-	struct xdp_umem_fq_reuse *rq = umem->fq_reuse;
-
-	if (!rq->length)
-		return xsk_umem_peek_addr(umem, addr);
-
-	*addr = rq->handles[rq->length - 1] & umem->chunk_mask;
-	return addr;
+	return xsk_umem_peek_addr(umem, addr);
 }
 
 static inline void xsk_umem_discard_addr_rq(struct xdp_umem *umem)
 {
-	struct xdp_umem_fq_reuse *rq = umem->fq_reuse;
-
-	if (!rq->length)
-		xsk_umem_discard_addr(umem);
-	else
-		rq->length--;
+	return xsk_umem_discard_addr(umem);
 }
 
 static inline void xsk_umem_recycle_addr(struct xdp_umem *umem, u64 addr)
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 74417a851ed5..fc33070b1821 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -39,19 +39,35 @@ bool xsk_is_setup_for_bpf_map(struct xdp_sock *xs)
 
 bool xsk_umem_has_addrs(struct xdp_umem *umem, u32 cnt)
 {
-	return xskq_has_addrs(umem->fq, cnt);
+	struct xdp_umem_fq_reuse *rq = umem->fq_reuse;
+
+        if (rq->length >= cnt)
+                return true;
+
+	return xskq_has_addrs(umem->fq, cnt - rq->length);
 }
 EXPORT_SYMBOL(xsk_umem_has_addrs);
 
 u64 *xsk_umem_peek_addr(struct xdp_umem *umem, u64 *addr)
 {
-	return xskq_peek_addr(umem->fq, addr);
+	struct xdp_umem_fq_reuse *rq = umem->fq_reuse;
+
+	if (!rq->length)
+		return xskq_peek_addr(umem->fq, addr);
+
+	*addr = rq->handles[rq->length - 1] & umem->chunk_mask;
+	return addr;
 }
 EXPORT_SYMBOL(xsk_umem_peek_addr);
 
 void xsk_umem_discard_addr(struct xdp_umem *umem)
 {
-	xskq_discard_addr(umem->fq);
+	struct xdp_umem_fq_reuse *rq = umem->fq_reuse;
+
+	if (!rq->length)
+		xskq_discard_addr(umem->fq);
+	else
+		rq->length--;
 }
 EXPORT_SYMBOL(xsk_umem_discard_addr);
 
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ