smatch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: smatch@vger.kernel.org
Subject: Re: tracing back a variable
Date: Tue, 10 Apr 2018 06:12:29 -0500	[thread overview]
Message-ID: <cd497228-e038-2c74-0508-da5367241381@embeddedor.com> (raw)
In-Reply-To: <20180410101934.iyvjf2mocbl65cgy@mwanda>

Hi Dan,

On 04/10/2018 05:19 AM, Dan Carpenter wrote:
> On Mon, Apr 09, 2018 at 11:25:48AM -0500, Gustavo A. R. Silva wrote:
>> Hi all,
>>
>> I wonder if smatch can be used to trace back a particular variable in order
>> to determine if such variable is directly or indirectly controlled from any
>> syscall?
>>
> 
> Of course, you *could* build something like that...
> 
> There is the get_implied_rl() function.  You give it a variable and it
> tells you if the variable can be controlled by the user.  So it could
> be from a syscall, kstrtol() or from skb->data etc.
> 
> So say you have something like:
> 
> 	u8 foo = *(char *)skb->data;
> 
> 	if (foo > 8)
> 		return;
> 
> Then get_implied_rl() will say foo is 0-8 range.
> 
> In theory there is enough information in the database so you could trace
> function parameters to find out where they come from, but no one has
> tested that so it probably doesn't work.
> 
> What are you working on?  Perhaps there is a different way to get the
> information you want.
> 

I'm analyzing code patterns that could be potentially vulnerable to 
variant 1 of Spectre.

So I want to determine if the variable x in the sample below can somehow 
be controlled by the user:

if (x < array1_size) {
   v = array2[array1[x]*256]
}

Thanks
--
Gustavo


      reply	other threads:[~2018-04-10 12:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-09 16:25 tracing back a variable Gustavo A. R. Silva
2018-04-10 10:19 ` Dan Carpenter
2018-04-10 11:12   ` Gustavo A. R. Silva [this message]

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=cd497228-e038-2c74-0508-da5367241381@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=dan.carpenter@oracle.com \
    --cc=smatch@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).