All of lore.kernel.org
 help / color / mirror / Atom feed
* CONFIG_DEBUG_PAGEALLOC and virt_addr_valid()
@ 2004-04-01 19:11 Sridhar Samudrala
  2004-04-01 19:30 ` Dave Hansen
  2004-04-01 19:44 ` Christoph Hellwig
  0 siblings, 2 replies; 7+ messages in thread
From: Sridhar Samudrala @ 2004-04-01 19:11 UTC (permalink / raw)
  To: linux-kernel

When CONFIG_DEBUG_PAGEALLOC is enabled, i am noticing that virt_addr_valid()
(called from sctp_is_valid_kaddr()) is returning true even for freed objects.
Is this a bug or expected behavior?

Thanks
Sridhar

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: CONFIG_DEBUG_PAGEALLOC and virt_addr_valid()
  2004-04-01 19:11 CONFIG_DEBUG_PAGEALLOC and virt_addr_valid() Sridhar Samudrala
@ 2004-04-01 19:30 ` Dave Hansen
  2004-04-01 19:44 ` Christoph Hellwig
  1 sibling, 0 replies; 7+ messages in thread
From: Dave Hansen @ 2004-04-01 19:30 UTC (permalink / raw)
  To: Sridhar Samudrala [imap]; +Cc: Linux Kernel Mailing List

On Thu, 2004-04-01 at 11:11, Sridhar Samudrala wrote:
> When CONFIG_DEBUG_PAGEALLOC is enabled, i am noticing that virt_addr_valid()
> (called from sctp_is_valid_kaddr()) is returning true even for freed objects.
> Is this a bug or expected behavior?

It's expected.  Right now it just makes sure the address translates to a
valid pfn.  Figuring out whether there are actually pagetables
underneath that address would require a pagetable walk.  

Don't we unmap things when they are free'd with CONFIG_DEBUG_PAGEALLOC? 
I guess we could add a pagetable walk in the debug case to
virt_addr_valid(), but it would probably make CONFIG_DEBUG_PAGEALLOC
even more of a dog than it already is.  

-- Dave


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: CONFIG_DEBUG_PAGEALLOC and virt_addr_valid()
  2004-04-01 19:11 CONFIG_DEBUG_PAGEALLOC and virt_addr_valid() Sridhar Samudrala
  2004-04-01 19:30 ` Dave Hansen
@ 2004-04-01 19:44 ` Christoph Hellwig
  2004-04-01 20:58   ` Sridhar Samudrala
  1 sibling, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2004-04-01 19:44 UTC (permalink / raw)
  To: Sridhar Samudrala; +Cc: linux-kernel

On Thu, Apr 01, 2004 at 11:11:39AM -0800, Sridhar Samudrala wrote:
> When CONFIG_DEBUG_PAGEALLOC is enabled, i am noticing that virt_addr_valid()
> (called from sctp_is_valid_kaddr()) is returning true even for freed objects.
> Is this a bug or expected behavior?

Generally every use of virt_addr_valid() is a bug.  What are you trying to
do?


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: CONFIG_DEBUG_PAGEALLOC and virt_addr_valid()
  2004-04-01 19:44 ` Christoph Hellwig
@ 2004-04-01 20:58   ` Sridhar Samudrala
  2004-04-01 21:15     ` Richard B. Johnson
  2004-04-02  0:29     ` Andrew Morton
  0 siblings, 2 replies; 7+ messages in thread
From: Sridhar Samudrala @ 2004-04-01 20:58 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-kernel

On Thu, 1 Apr 2004, Christoph Hellwig wrote:

> On Thu, Apr 01, 2004 at 11:11:39AM -0800, Sridhar Samudrala wrote:
> > When CONFIG_DEBUG_PAGEALLOC is enabled, i am noticing that virt_addr_valid()
> > (called from sctp_is_valid_kaddr()) is returning true even for freed objects.
> > Is this a bug or expected behavior?
>
> Generally every use of virt_addr_valid() is a bug.  What are you trying to
> do?

We are trying to validate a kernel address that is passed by the user. Is
there a better way to do that?

When an SCTP association is established, the pointer to the association
structure is passed to the user as an identifier of the association. This
identifier is used in the later calls by the user.

-Sridhar

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: CONFIG_DEBUG_PAGEALLOC and virt_addr_valid()
  2004-04-01 20:58   ` Sridhar Samudrala
@ 2004-04-01 21:15     ` Richard B. Johnson
  2004-04-02  0:29     ` Andrew Morton
  1 sibling, 0 replies; 7+ messages in thread
From: Richard B. Johnson @ 2004-04-01 21:15 UTC (permalink / raw)
  To: Sridhar Samudrala; +Cc: Christoph Hellwig, linux-kernel

On Thu, 1 Apr 2004, Sridhar Samudrala wrote:

> On Thu, 1 Apr 2004, Christoph Hellwig wrote:
>
> > On Thu, Apr 01, 2004 at 11:11:39AM -0800, Sridhar Samudrala wrote:
> > > When CONFIG_DEBUG_PAGEALLOC is enabled, i am noticing that virt_addr_valid()
> > > (called from sctp_is_valid_kaddr()) is returning true even for freed objects.
> > > Is this a bug or expected behavior?
> >
> > Generally every use of virt_addr_valid() is a bug.  What are you trying to
> > do?
>
> We are trying to validate a kernel address that is passed by the user. Is
> there a better way to do that?
>
> When an SCTP association is established, the pointer to the association
> structure is passed to the user as an identifier of the association. This
> identifier is used in the later calls by the user.
>
> -Sridhar

Are you now moving the protocol out of user-space and into the
kernel?  If so, you should use the Unix/Linux methods of reading/
writing user memory.

Any protection is on a per-page basis. If you give a user some
pointer into the kernel, he can destroy a whole page before it
is detected! So, even if virt_addr_valid() did the "right" thing
you'd be in a lot of trouble using it.


Cheers,
Dick Johnson
Penguin : Linux version 2.4.24 on an i686 machine (797.90 BogoMips).
            Note 96.31% of all statistics are fiction.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: CONFIG_DEBUG_PAGEALLOC and virt_addr_valid()
  2004-04-01 20:58   ` Sridhar Samudrala
  2004-04-01 21:15     ` Richard B. Johnson
@ 2004-04-02  0:29     ` Andrew Morton
  2004-04-02  1:39       ` Sridhar Samudrala
  1 sibling, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2004-04-02  0:29 UTC (permalink / raw)
  To: Sridhar Samudrala; +Cc: hch, linux-kernel

Sridhar Samudrala <sri@us.ibm.com> wrote:
>
> On Thu, 1 Apr 2004, Christoph Hellwig wrote:
> 
> > On Thu, Apr 01, 2004 at 11:11:39AM -0800, Sridhar Samudrala wrote:
> > > When CONFIG_DEBUG_PAGEALLOC is enabled, i am noticing that virt_addr_valid()
> > > (called from sctp_is_valid_kaddr()) is returning true even for freed objects.
> > > Is this a bug or expected behavior?
> >
> > Generally every use of virt_addr_valid() is a bug.  What are you trying to
> > do?
> 
> We are trying to validate a kernel address that is passed by the user. Is
> there a better way to do that?

yup.  Pass the user an integer.

> When an SCTP association is established, the pointer to the association
> structure is passed to the user as an identifier of the association. This
> identifier is used in the later calls by the user.

Please don't do that.  See lib/idr.c.  I expect it does exactly what you
want.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: CONFIG_DEBUG_PAGEALLOC and virt_addr_valid()
  2004-04-02  0:29     ` Andrew Morton
@ 2004-04-02  1:39       ` Sridhar Samudrala
  0 siblings, 0 replies; 7+ messages in thread
From: Sridhar Samudrala @ 2004-04-02  1:39 UTC (permalink / raw)
  To: Andrew Morton; +Cc: hch, linux-kernel

On Thu, 1 Apr 2004, Andrew Morton wrote:

> Sridhar Samudrala <sri@us.ibm.com> wrote:
> >
> > On Thu, 1 Apr 2004, Christoph Hellwig wrote:
> >
> > > On Thu, Apr 01, 2004 at 11:11:39AM -0800, Sridhar Samudrala wrote:
> > > > When CONFIG_DEBUG_PAGEALLOC is enabled, i am noticing that virt_addr_valid()
> > > > (called from sctp_is_valid_kaddr()) is returning true even for freed objects.
> > > > Is this a bug or expected behavior?
> > >
> > > Generally every use of virt_addr_valid() is a bug.  What are you trying to
> > > do?
> >
> > We are trying to validate a kernel address that is passed by the user. Is
> > there a better way to do that?
>
> yup.  Pass the user an integer.
>
> > When an SCTP association is established, the pointer to the association
> > structure is passed to the user as an identifier of the association. This
> > identifier is used in the later calls by the user.
>
> Please don't do that.  See lib/idr.c.  I expect it does exactly what you
> want.

Yes. I think i should be able to use it to generate ids for the associations.
Thanks for pointing it out.
-Sridhar

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-04-02  1:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-01 19:11 CONFIG_DEBUG_PAGEALLOC and virt_addr_valid() Sridhar Samudrala
2004-04-01 19:30 ` Dave Hansen
2004-04-01 19:44 ` Christoph Hellwig
2004-04-01 20:58   ` Sridhar Samudrala
2004-04-01 21:15     ` Richard B. Johnson
2004-04-02  0:29     ` Andrew Morton
2004-04-02  1:39       ` Sridhar Samudrala

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.