Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3677017ybd; Fri, 28 Jun 2019 13:00:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqy87E20Z5NvRnKwy/sWtlukfqaCmCJeBlTKFti9/fYRO7ccUY5FBcbQRcnvaKujct6blybz X-Received: by 2002:a65:454c:: with SMTP id x12mr10972052pgr.354.1561752049311; Fri, 28 Jun 2019 13:00:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561752049; cv=none; d=google.com; s=arc-20160816; b=O4rHYa8lt+lhqn1K66J+1sFp6WwagiPFMh+UjTtUDHJHZE9XfKaHluJeweKu0hSwYW OAN6sZZBbmsIBeNHIJU6FHjl96HPEIPfhC3z5E+UKqBIqiL1dHCvpNzlUjDx1G5Xppci mRXkIdObkwNZ5DCGJDSOD2BN9D4f5J0QddRChafwVeRfTLr+cF1VNvyD8ffYZWzAl4qc 7gi4kHO8iT6ku+BFEz99gz0xU0Eef6tqL5JuhbMfsXgNuO1ItmsAUxMGCVTRm5BCXIqI wiPRqBE1gKbsP833mllmzjGyhgNOi7NNQVcfXMSk+F0ngQBKpMrJrXHzjkP7JEnqH2Z/ Q70g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=JnkachwQP0cyQ9JdMbTUnW5qndJ/fTXRxpRomw9WY6k=; b=tu6JsIQ0ZP9Nvs3rY9CW8lRzXHHuG6xFwkiA+jpvsmo2ZwPnD5IXE0PVykRtuijNFL 8MNCFy3n4Z/fAHOXFVuhYY/kW2sGOs69DFBujCR/IQ4Vf2IwUs4he35lH/7g/8OKMkG5 YLAg2a0IeNYGow0CkJtjBsUt6MslA7dDoCyI/ZqwL0ajuMsV/U7+OSOCj9yBZryyRsV1 VBUMkJWbIEdQ9rBcXJOShZ5dvfL8hMZkskDm4dC/8dPV/UWOsZdxF7rssffNnuRP89/H avoD89qU3HeRfZ8JTO9VZpixEkz2Eq2EQHyP+cnnG4m+++gWbOKu+LPGfWhO+ONjObAR U/uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vVLyvukr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 35si2992159plb.62.2019.06.28.13.00.32; Fri, 28 Jun 2019 13:00:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vVLyvukr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727075AbfF1T7F (ORCPT + 99 others); Fri, 28 Jun 2019 15:59:05 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:42917 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727042AbfF1T7E (ORCPT ); Fri, 28 Jun 2019 15:59:04 -0400 Received: by mail-yw1-f67.google.com with SMTP id n127so1540168ywd.9 for ; Fri, 28 Jun 2019 12:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JnkachwQP0cyQ9JdMbTUnW5qndJ/fTXRxpRomw9WY6k=; b=vVLyvukrpuQtbZdzKfeFDmHdS8rq0f9WdO6YO1eZI6sLIUF996To1rdL8/7+axITIy 85yp8tjhuqeC8aQG5v6WRyAA6OCt/OvXJzXuB3erg1B1/6I/VhC97S1snroCo/cGfDMP uVp7k4O91vtcWDPfd0EgxARsjrcpaEz0vxiRw/U3zJGyqOMaKnEbJrlYwP0YHPX11owd ydc6SDTxO8stFGHPET1XRyuFJtUOZ/g0botEElyakKaPs0TwZwUnhxua9Brg/C7XrXzK Tzz95CL2xg4AohWS6sDOA/H16jSdpmsb38czV9xkwcdD72qnaCznSjjlKboOu3AVh9Qv 0LPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JnkachwQP0cyQ9JdMbTUnW5qndJ/fTXRxpRomw9WY6k=; b=H/9T+kMeIDNV6gPnNJcU4+8A9A6o7uj3F6gOicFEnoTaSYLgp66h2HcR9RbbDMPa4Z J+yElNZQxXSkNCAc5eqQLx9IimSq1a36KAc+JgKRTNO+XTqofDz4NrqQcH4/8mwai5e4 T58PJcGrr/MPbqAPy1XSRq1SdiKQrva2caLRraLxpQgP4DY0wzTEk5fl2mzUARUdWtXY see1cvyYBUKYuZ5om6cHiJ4lhntaGMfRK6FMXpwFuTyhasjyd5s2Ob4c/dlnDJ3zmj7G 2mi/HORacrsN0rLvVkzvtJ0hdQqJAbYFwjZU4D9S5UQQoh2fpA5Z0rDHGtU4B4Id+0/a PxoA== X-Gm-Message-State: APjAAAUDXirBUYB6r+T/n24Hwe2ReGWwwwXbx+ooVsoyuKRI1gp59w4I TaD9jaS6HvneqcWZKe1r7V2frlBbUnI= X-Received: by 2002:a81:838d:: with SMTP id t135mr7666921ywf.56.1561751943444; Fri, 28 Jun 2019 12:59:03 -0700 (PDT) Received: from mail-yw1-f44.google.com (mail-yw1-f44.google.com. [209.85.161.44]) by smtp.gmail.com with ESMTPSA id l22sm695520ywl.68.2019.06.28.12.59.03 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Fri, 28 Jun 2019 12:59:03 -0700 (PDT) Received: by mail-yw1-f44.google.com with SMTP id j190so3815774ywb.0 for ; Fri, 28 Jun 2019 12:59:03 -0700 (PDT) X-Received: by 2002:a81:4807:: with SMTP id v7mr6063772ywa.494.1561751494211; Fri, 28 Jun 2019 12:51:34 -0700 (PDT) MIME-Version: 1.0 References: <20190628123819.2785504-1-arnd@arndb.de> <20190628123819.2785504-4-arnd@arndb.de> In-Reply-To: <20190628123819.2785504-4-arnd@arndb.de> From: Willem de Bruijn Date: Fri, 28 Jun 2019 15:50:57 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 4/4] ipvs: reduce kernel stack usage To: Arnd Bergmann Cc: Kees Cook , Wensong Zhang , Simon Horman , Julian Anastasov , "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , James Smart , Dick Kennedy , "James E . J . Bottomley" , "Martin K . Petersen" , Larry Finger , Florian Schilhabel , Greg Kroah-Hartman , James Morris , linux-scsi@vger.kernel.org, linux-kernel , devel@driverdev.osuosl.org, Network Development , lvs-devel@vger.kernel.org, netfilter-devel , coreteam@netfilter.org, Ard Biesheuvel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 28, 2019 at 8:40 AM Arnd Bergmann wrote: > > With the new CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL option, the stack > usage in the ipvs debug output grows because each instance of > IP_VS_DBG_BUF() now has its own buffer of 160 bytes that add up > rather than reusing the stack slots: > > net/netfilter/ipvs/ip_vs_core.c: In function 'ip_vs_sched_persist': > net/netfilter/ipvs/ip_vs_core.c:427:1: error: the frame size of 1052 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] > net/netfilter/ipvs/ip_vs_core.c: In function 'ip_vs_new_conn_out': > net/netfilter/ipvs/ip_vs_core.c:1231:1: error: the frame size of 1048 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] > net/netfilter/ipvs/ip_vs_ftp.c: In function 'ip_vs_ftp_out': > net/netfilter/ipvs/ip_vs_ftp.c:397:1: error: the frame size of 1104 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] > net/netfilter/ipvs/ip_vs_ftp.c: In function 'ip_vs_ftp_in': > net/netfilter/ipvs/ip_vs_ftp.c:555:1: error: the frame size of 1200 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] > > Since printk() already has a way to print IPv4/IPv6 addresses using > the %pIS format string, use that instead, since these are sockaddr_in and sockaddr_in6, should that have the 'n' specifier to denote network byteorder? > combined with a macro that > creates a local sockaddr structure on the stack. These will still > add up, but the stack frames are now under 200 bytes. would it make sense to just define a helper function that takes const char * level and msg strings and up to three struct nf_inet_addr* and do the conversion in there? No need for macros and no state on the stack outside error paths at all. > > Signed-off-by: Arnd Bergmann > --- > I'm not sure this actually does what I think it does. Someone > needs to verify that we correctly print the addresses here. > I've also only added three files that caused the warning messages > to be reported. There are still a lot of other instances of > IP_VS_DBG_BUF() that could be converted the same way after the > basic idea is confirmed. > --- > include/net/ip_vs.h | 71 +++++++++++++++++++-------------- > net/netfilter/ipvs/ip_vs_core.c | 44 ++++++++++---------- > net/netfilter/ipvs/ip_vs_ftp.c | 20 +++++----- > 3 files changed, 72 insertions(+), 63 deletions(-) > > diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h > index 3759167f91f5..3dfbeef67be6 100644 > --- a/include/net/ip_vs.h > +++ b/include/net/ip_vs.h > @@ -227,6 +227,16 @@ static inline const char *ip_vs_dbg_addr(int af, char *buf, size_t buf_len, > sizeof(ip_vs_dbg_buf), addr, \ > &ip_vs_dbg_idx) > > +#define IP_VS_DBG_SOCKADDR4(fam, addr, port) \ > + (struct sockaddr*)&(struct sockaddr_in) \ > + { .sin_family = (fam), .sin_addr = (addr)->in, .sin_port = (port) } might as well set .sin_family = AF_INET here and AF_INET6 below? > +#define IP_VS_DBG_SOCKADDR6(fam, addr, port) \ > + (struct sockaddr*)&(struct sockaddr_in6) \ > + { .sin6_family = (fam), .sin6_addr = (addr)->in6, .sin6_port = (port) }