LVS
lvs-devel
Google
 
Web LinuxVirtualServer.org

Re: [PATCHv2 net-next] ipvs: reduce stack usage for sockopt data

To: Julian Anastasov <ja@xxxxxx>
Subject: Re: [PATCHv2 net-next] ipvs: reduce stack usage for sockopt data
Cc: Simon Horman <horms@xxxxxxxxxxxx>, lvs-devel@xxxxxxxxxxxxxxx, Dan Carpenter <dan.carpenter@xxxxxxxxxx>, Andrey Utkin <andrey.krieger.utkin@xxxxxxxxx>, David Binderman <dcb314@xxxxxxxxxxx>
From: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
Date: Wed, 3 Sep 2014 11:11:21 +0200
Hi Julian,

On Wed, Sep 03, 2014 at 12:02:49AM +0300, Julian Anastasov wrote:
> Use union to reserve the required stack space for sockopt data
> which is less than the currently hardcoded value of 128.
> Now the tables for commands should be more readable.
> The checks added for readability are optimized by compiler,
> others warn at compile time if command uses too much
> stack or exceeds the storage of set_arglen and get_arglen.
> 
> As Dan Carpenter points out, we can run for unprivileged user,
> so we can silent some error messages.
> 
> Signed-off-by: Julian Anastasov <ja@xxxxxx>
> CC: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> CC: Andrey Utkin <andrey.krieger.utkin@xxxxxxxxx>
> CC: David Binderman <dcb314@xxxxxxxxxxx>
> ---
> 
> This is 2nd version. I removed the macros and tried to
> fit in 80 columns... Pablo, please check this version.
> Also, let us know if you are going to apply the final
> version directly or whether Simon should take it first.
> Thanks!

Thanks for spinning a second version. I took it over and made some
minor comestic changes. I noticed SET_CMDID() is equivalent to
GET_CMDID() so, while at it, I have merged them. This allowed me to
fit the structure in 80-chars per column by using spaces to pad the
initialization area (I remeber to have seen this trick in other parts
of the kernel code).

An another question, in do_ip_vs_get_ctl() I can see:

+       copylen = get_arglen[CMDID(cmd)];
+       if (*len < (int) copylen || *len < 0) {

len is signed, the casting also enforces signed arithmetics. copylen
can be 0 at worst case for unused options. Perhaps I'm overlooking
something but I think *len < 0 is redundant.

Let me know, I can mangle that here. Thanks!

Attachment: 0001-ipvs-reduce-stack-usage-for-sockopt-data.patch
Description: Text Data

<Prev in Thread] Current Thread [Next in Thread>