[SRU Impish/OEM-5.14 1/2] sock: remove one redundant SKB_FRAG_PAGE_ORDER macro

Thadeu Lima de Souza Cascardo cascardo at canonical.com
Thu Mar 24 11:14:53 UTC 2022


From: Yunsheng Lin <linyunsheng at huawei.com>

Both SKB_FRAG_PAGE_ORDER are defined to the same value in
net/core/sock.c and drivers/vhost/net.c.

Move the SKB_FRAG_PAGE_ORDER definition to net/core/sock.h,
as both net/core/sock.c and drivers/vhost/net.c include it,
and it seems a reasonable file to put the macro.

Signed-off-by: Yunsheng Lin <linyunsheng at huawei.com>
Acked-by: Jason Wang <jasowang at redhat.com>
Signed-off-by: David S. Miller <davem at davemloft.net>
(cherry picked from commit 723783d077e39c256a1fafebbd97cbb14207c28f)
CVE-2022-27666
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo at canonical.com>
---
 drivers/vhost/net.c | 2 --
 include/net/sock.h  | 1 +
 net/core/sock.c     | 1 -
 3 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index bff77e92a19e..dfe239f09514 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -652,8 +652,6 @@ static bool tx_can_batch(struct vhost_virtqueue *vq, size_t total_len)
 	       !vhost_vq_avail_empty(vq->dev, vq);
 }
 
-#define SKB_FRAG_PAGE_ORDER     get_order(32768)
-
 static bool vhost_net_page_frag_refill(struct vhost_net *net, unsigned int sz,
 				       struct page_frag *pfrag, gfp_t gfp)
 {
diff --git a/include/net/sock.h b/include/net/sock.h
index 8bb190a43013..cef86bc2ec63 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2709,6 +2709,7 @@ extern int sysctl_optmem_max;
 extern __u32 sysctl_wmem_default;
 extern __u32 sysctl_rmem_default;
 
+#define SKB_FRAG_PAGE_ORDER	get_order(32768)
 DECLARE_STATIC_KEY_FALSE(net_high_order_alloc_disable_key);
 
 static inline int sk_get_wmem0(const struct sock *sk, const struct proto *proto)
diff --git a/net/core/sock.c b/net/core/sock.c
index ec1e201c4e63..0fbe739cac0a 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2488,7 +2488,6 @@ static void sk_leave_memory_pressure(struct sock *sk)
 	}
 }
 
-#define SKB_FRAG_PAGE_ORDER	get_order(32768)
 DEFINE_STATIC_KEY_FALSE(net_high_order_alloc_disable_key);
 
 /**
-- 
2.32.0




More information about the kernel-team mailing list