[Devel] [PATCH RHEL COMMIT] ms/memcg: ipv6/sit: account and don't WARN on ip_tunnel_prl structs allocation

Konstantin Khorenko khorenko at virtuozzo.com
Tue Sep 28 14:16:12 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after ark-5.14
------>
commit 358d89cbd1ba4c4f8b684ff2bf8dc88e6ce93454
Author: Vasily Averin <vvs at virtuozzo.com>
Date:   Tue Sep 28 14:16:12 2021 +0300

    ms/memcg: ipv6/sit: account and don't WARN on ip_tunnel_prl structs allocation
    
    Author: Andrey Ryabinin <aryabinin at virtuozzo.com>
    
    The size of the ip_tunnel_prl structs allocation is controllable from
    user-space, thus it's better to avoid spam in dmesg if allocation failed.
    Also add __GFP_ACCOUNT as this is a good candidate for per-memcg
    accounting. Allocation is temporary and limited by 4GB.
    
    Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
    
    Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
    
    Signed-off-by: David S. Miller <davem at davemloft.net>
    (cherry picked from commit 1b51d8271973e4966078f0c1a5cb061ae9a424d2)
    https://jira.sw.ru/browse/PSBM-133990
    Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
---
 net/ipv6/sit.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index bf12540bbd6a..7eb40217085a 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -327,7 +327,7 @@ static int ipip6_tunnel_get_prl(struct net_device *dev, struct ifreq *ifr)
 	 * we try harder to allocate.
 	 */
 	kp = (cmax <= 1 || ve_capable(CAP_NET_ADMIN)) ?
-		kcalloc(cmax, sizeof(*kp), GFP_KERNEL | __GFP_NOWARN) :
+		kcalloc(cmax, sizeof(*kp), GFP_KERNEL_ACCOUNT | __GFP_NOWARN) :
 		NULL;
 
 	rcu_read_lock();
@@ -340,7 +340,8 @@ static int ipip6_tunnel_get_prl(struct net_device *dev, struct ifreq *ifr)
 		 * For root users, retry allocating enough memory for
 		 * the answer.
 		 */
-		kp = kcalloc(ca, sizeof(*kp), GFP_ATOMIC);
+		kp = kcalloc(ca, sizeof(*kp), GFP_ATOMIC | __GFP_ACCOUNT |
+					      __GFP_NOWARN);
 		if (!kp) {
 			ret = -ENOMEM;
 			goto out;


More information about the Devel mailing list