mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "David S. Miller" <davem@davemloft.net>
To: davej@redhat.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: filldir[64] oddness
Date: Wed, 08 Mar 2006 20:32:04 -0800 (PST)	[thread overview]
Message-ID: <20060308.203204.115109492.davem@davemloft.net> (raw)
In-Reply-To: <20060309042744.GA23148@redhat.com>

From: Dave Jones <davej@redhat.com>
Date: Wed, 8 Mar 2006 23:27:44 -0500

> #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
> #define ROUND_UP(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1))
> 
> 140  	static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
> 141  			   ino_t ino, unsigned int d_type)
> 142  	{
> 143  		struct linux_dirent __user * dirent;
> 144  		struct getdents_callback * buf = (struct getdents_callback *) __buf
> 145  		int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 2);
> 
> How come that NAME_OFFSET isn't causing an oops when
> it dereferences stackjunk->d_name ?

d_name a char[] array, and we're just doing pointer arithmetic
here.  It's the same as "offsetof(d_name, struct linux_dirent)"
or something like that.

I think coverity is being trigger happy in this case :-)

  reply	other threads:[~2006-03-09  4:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-09  4:27 Dave Jones
2006-03-09  4:32 ` David S. Miller [this message]
2006-03-09  4:38   ` Dave Jones
2006-03-09  4:40   ` Al Viro
2006-03-09 17:02     ` Bryan O'Sullivan
2006-03-09 17:07       ` Dave Jones
2006-03-09 17:15         ` Bryan O'Sullivan
2006-03-09 17:27           ` Dave Jones
2006-03-10  1:41       ` Kyle Moffett
2006-03-10  1:44         ` Al Viro
2006-03-09  4:33 ` Vadim Lobanov
2006-03-09  4:34 ` Stephen Rothwell
2006-03-09  4:38 ` Al Viro

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=20060308.203204.115109492.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=davej@redhat.com \
    --cc=linux-kernel@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

Powered by JetHome