From: David Daney <ddaney.cavm@gmail.com>
To: "Kasatkin, Dmitry" <dmitry.kasatkin@intel.com>
Cc: herbert@gondor.apana.org.au,
linux-crypto <linux-crypto@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-security-module <linux-security-module@vger.kernel.org>
Subject: Re: on stack dynamic allocations
Date: Thu, 16 Aug 2012 14:30:57 -0700 [thread overview]
Message-ID: <502D6691.5010101@gmail.com> (raw)
In-Reply-To: <CALLzPKYzc5FwPFTn5Ztg58vfkMO2EZ8P-MLEmVXRqdBE+CkkSg@mail.gmail.com>
On 08/16/2012 02:20 PM, Kasatkin, Dmitry wrote:
> Hello,
>
> Some places in the code uses variable-size allocation on stack..
> For example from hmac_setkey():
>
> struct {
> struct shash_desc shash;
> char ctx[crypto_shash_descsize(hash)];
> } desc;
>
>
> sparse complains
>
> CHECK crypto/hmac.c
> crypto/hmac.c:57:47: error: bad constant expression
>
> I like it instead of kmalloc..
>
> But what is position of kernel community about it?
If you know that the range of crypto_shash_descsize(hash) is bounded,
just use the upper bound.
If the range of crypto_shash_descsize(hash) is unbounded, then the stack
will overflow and ... BOOM!
David Daney
WARNING: multiple messages have this Message-ID (diff)
From: David Daney <ddaney.cavm@gmail.com>
To: "Kasatkin, Dmitry" <dmitry.kasatkin@intel.com>
Cc: herbert@gondor.hengli.com.au,
linux-crypto <linux-crypto@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-security-module <linux-security-module@vger.kernel.org>
Subject: Re: on stack dynamic allocations
Date: Thu, 16 Aug 2012 14:30:57 -0700 [thread overview]
Message-ID: <502D6691.5010101@gmail.com> (raw)
In-Reply-To: <CALLzPKYzc5FwPFTn5Ztg58vfkMO2EZ8P-MLEmVXRqdBE+CkkSg@mail.gmail.com>
On 08/16/2012 02:20 PM, Kasatkin, Dmitry wrote:
> Hello,
>
> Some places in the code uses variable-size allocation on stack..
> For example from hmac_setkey():
>
> struct {
> struct shash_desc shash;
> char ctx[crypto_shash_descsize(hash)];
> } desc;
>
>
> sparse complains
>
> CHECK crypto/hmac.c
> crypto/hmac.c:57:47: error: bad constant expression
>
> I like it instead of kmalloc..
>
> But what is position of kernel community about it?
If you know that the range of crypto_shash_descsize(hash) is bounded,
just use the upper bound.
If the range of crypto_shash_descsize(hash) is unbounded, then the stack
will overflow and ... BOOM!
David Daney
next prev parent reply other threads:[~2012-08-16 21:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-16 21:20 on stack dynamic allocations Kasatkin, Dmitry
2012-08-16 21:20 ` Kasatkin, Dmitry
2012-08-16 21:30 ` David Daney [this message]
2012-08-16 21:30 ` David Daney
2012-08-17 8:18 ` Jussi Kivilinna
2012-08-17 8:18 ` Jussi Kivilinna
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=502D6691.5010101@gmail.com \
--to=ddaney.cavm@gmail.com \
--cc=dmitry.kasatkin@intel.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.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.