All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Eric Dumazet <dada1@cosmosbay.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Linux Netdev List <netdev@vger.kernel.org>,
	Netfilter Development Mailinglist
	<netfilter-devel@lists.netfilter.org>
Subject: Re: [PATCH, take2] netfilter : struct xt_table_info diet
Date: Thu, 15 Nov 2007 16:58:43 +0100	[thread overview]
Message-ID: <473C6CB3.6040803@trash.net> (raw)
In-Reply-To: <20071115164516.ced96a9e.dada1@cosmosbay.com>

Eric Dumazet wrote:
> On Thu, 15 Nov 2007 13:41:54 +0100
> Patrick McHardy <kaber@trash.net> wrote:
> 
>>> +#define XT_TABLE_INFO_SZ (offsetof(struct xt_table_info, entries) \
>>> +			  + nr_cpu_ids * sizeof(char *))
>>
>>>  	/* overflow check */
>>> -	if (tmp.size >= (INT_MAX - sizeof(struct xt_table_info)) / NR_CPUS -
>>> -			SMP_CACHE_BYTES)
>>> +	if (tmp.size >= INT_MAX / num_possible_cpus())
>>>  		return -ENOMEM;
>> We need to make sure offsetof(struct xt_table_info, entries) +
>> nr_cpu_ids * sizeof(char *) doesn't overflow, so why doesn't it
>> use nr_cpu_ids here as well?
>>
> 
> nr_cpu_ids is <= NR_CPUS, so XT_TABLE_INFO_SZ cannot overflow


Yes, but nr_cpu_ids is >= num_possible_cpus, which is what we're
using with your patch.

> The 'overflow check' we do here is in fact not very usefull now
> that we dont need to multiply tmp.size by NR_CPUS and potentially
> overflow the result.
> 
> We can delete the test, because kmalloc()/vmalloc() will probably
> fail gracefully if we ask too much memory.


You're right, I'll remove it. Thanks.

  reply	other threads:[~2007-11-15 15:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-14 21:50 [PATCH, take2] netfilter : struct xt_table_info diet Eric Dumazet
2007-11-15 12:41 ` Patrick McHardy
2007-11-15 15:45   ` Eric Dumazet
2007-11-15 15:58     ` Patrick McHardy [this message]
2007-11-20  6:32 ` Simon Horman
2007-11-20  7:02   ` Herbert Xu
2007-11-20  7:50     ` Patrick McHardy
2007-11-20  7:54   ` Patrick McHardy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=473C6CB3.6040803@trash.net \
    --to=kaber@trash.net \
    --cc=dada1@cosmosbay.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@lists.netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.