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 f2c93db69871576a85fcf84eb938e7a4e670899c
Author: Konstantin Khorenko <khore...@virtuozzo.com>
Date:   Thu Sep 30 16:04:04 2021 +0300

    net/sock: teach sock_kmalloc() to call kvmalloc() when possible
    
    sock_setsockopt()
     sk_attach_filter()
      sock_kmalloc()
    
    Memory size to be allocated depends on the number of rules provided by
    userspace, but not more than net.core.optmem_max (20480 by default),
    which still allows to allocate 3rd order pages via kmalloc() =>
    it's better to substitute it with kvmalloc().
    
    But sock_kmalloc() can be called with GFP_ATOMIC from some places,
    so we cannot unconditionally call kvmalloc() instead of kmalloc().
    
    Hopefully sk_attach_filter() calls sock_kmalloc() with GFP_KERNEL,
    so kvmalloc() can be used there.
    
    => use kvmalloc_check() which calls kvmalloc() if it's allowed
    by provided flags.
    
    https://jira.sw.ru/browse/PSBM-82593
    
    Signed-off-by: Konstantin Khorenko <khore...@virtuozzo.com>
    
    Ughh, but ok.
    Reviewed-by: Andrey Ryabinin <aryabi...@virtuozzo.com>
    
    (cherry picked from vz7 commit 29b736c18d06 ("net/sock: teach 
sock_kmalloc() to
    call kvmalloc() when possible"))
    
    VZ 8 rebase part https://jira.sw.ru/browse/PSBM-127798
    
    Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalit...@virtuozzo.com>
    
    (cherry picked from vz8 commit 29f9cfc48b3f5d31cb4259eaea6216254cf8c498)
    Signed-off-by: Andrey Zhadchenko <andrey.zhadche...@virtuozzo.com>
---
 net/core/sock.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/core/sock.c b/net/core/sock.c
index 202ea92adccb..35db91ba6ff8 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2359,7 +2359,7 @@ void *sock_kmalloc(struct sock *sk, int size, gfp_t 
priority)
                 * might sleep.
                 */
                atomic_add(size, &sk->sk_omem_alloc);
-               mem = kmalloc(size, priority);
+               mem = kvmalloc_check(size, priority);
                if (mem)
                        return mem;
                atomic_sub(size, &sk->sk_omem_alloc);
@@ -2378,9 +2378,9 @@ static inline void __sock_kfree_s(struct sock *sk, void 
*mem, int size,
        if (WARN_ON_ONCE(!mem))
                return;
        if (nullify)
-               kfree_sensitive(mem);
-       else
-               kfree(mem);
+               memset(mem, 0, size);
+
+       kvfree(mem);
        atomic_sub(size, &sk->sk_omem_alloc);
 }
 
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to