Issue 2189 - Paged Results Control patch
Summary: Paged Results Control patch
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: contrib (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-20 16:56 UTC by lynnmoss@us.ibm.com
Modified: 2014-08-01 21:05 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description ando@openldap.org 2002-11-20 13:39:36 UTC
changed notes
moved from Incoming to Contrib
Comment 1 ando@openldap.org 2002-11-20 16:38:37 UTC
> This patch is an implementation of RFC2696, "LDAP Control Extension for
Simple
> Paged Results Manipulation" for your review.

The patch is very interesting; however there is a problem in handling the
cookie.
I applied the patch with minor fixes and everything works fine for the first
page; however, after the cookie is sent back to the client, the next submission
results in an invalid cookie.  MOreover, you're doing a lot of mallocs that can
be easily replacd by stack allocation.  I'm going to try to fix your patch if
I can; otherwise I'll post a revised version of it so that you can take care
of my remarks.

Thanks again for the submission.

Pierangelo.
Comment 2 ando@openldap.org 2002-11-20 16:38:56 UTC
changed notes
changed state Open to Feedback
Comment 3 lynnmoss@us.ibm.com 2002-11-20 16:56:02 UTC
Full_Name: Lynn Moss
Version: HEAD branch
OS: Linux
URL: ftp://ftp.openldap.org/incoming/pagecontrol-112002.patch
Submission from: (NULL) (129.42.208.186)


This patch is an implementation of RFC2696, "LDAP Control Extension for Simple
Paged
Results Manipulation" for your review.

Comment 4 ando@openldap.org 2002-11-20 16:56:16 UTC
Forget about my previous posting: I found the bug.
You were doing some ber-decoding in place, freeing 
the ber before saving the contents.  I'm committing.

Pierangelo.
Comment 5 ando@openldap.org 2002-11-20 17:18:58 UTC
changed notes
changed state Feedback to Test
Comment 6 ando@openldap.org 2002-11-20 17:25:50 UTC
Note that, before support for this control is released, the server side 
of the patch should be carefully reviewed to ensure it complies with 
chapter 6 of RFC 2696:

> 6. Security Considerations
> 
>    Server implementors should consider the resources used when clients
>    send searches with the simple paged control, to ensure that a
>    client's misuse of this control does not lock out other legitimate
>    operations.
> 
>    Servers implementations may enforce an overriding sizelimit, to
>    prevent the retrieval of large portions of a publically-accessible
>    directory.
> 
>    Clients can, using this control, determine how many entries match a
>    particular filter, before the entries are returned to the client.
>    This may require special processing in servers which perform access
>    control checks on entries to determine whether the existence of the
>    entry can be disclosed to the client.

Pierangelo.
Comment 7 lynnmoss@us.ibm.com 2002-11-21 15:42:06 UTC




Pierangelo,
    Thanks for debugging this for me so quickly!  The paging worked fine on
the second page for me and all subsequent pages for me, so I don't know why
I didn't catch the error.   Are there still mallocs that should be changed
to stack allocation per your previous post?
        Lynn

Comment 8 lynnmoss@us.ibm.com 2002-11-21 16:27:01 UTC




Pierangelo,
   Regarding chapter 6, security considerations:
Paragraph 1 seems to be satisfied, since one can have multiple searches (or
other operations) happening concurrently with no problem.
Paragraph 2: The size limit for the search is still respected, so I believe
this condition is satisfied.
Paragraph 3:  I'm not really sure how to interpret this one, but the server
doesn't give an indication of the number of entries that will match before
returning the first entries, so I would say that this is not satisfied.  Is
this necessary to add?
          Lynn

Comment 9 ando@openldap.org 2002-11-21 19:00:03 UTC
> Pierangelo,
>    Regarding chapter 6, security considerations:
> Paragraph 1 seems to be satisfied, since one can have multiple searches
> (or other operations) happening concurrently with no problem.
> Paragraph 2: The size limit for the search is still respected, so I
> believe this condition is satisfied.

sure.

> Paragraph 3:  I'm not really sure how to interpret this one, but the
> server doesn't give an indication of the number of entries that will
> match before returning the first entries, so I would say that this is
> not satisfied.  Is this necessary to add?

I think what you're doing is fine: it seems conservative
(accroding to RFC 2696) to return 0 as count of entries
that still have to be processed; however, an estimate of
how many entries will be returned next is given by the
number of candidates (if we accept it  as a conservative
estimate, i.e. a worst case in terms of resources usage).

The point is that we should not reveal this information
unless we give the sysadmin the possibility to protect
it if required.  We would need to set up a sort of meta-ACL
that protects the count of entries that are available;
to reuse a big chunk of code we might introduce a new type
of limit in the limits stuff (see slapd.conf(5) "limits"
and servers/slapd/limits.c); I'm thinking of a

limits anonymous size.pr=10 size.pr=noEntriesLeft

to limit the size of the page a specific user might request
and to hide the number of entries left.

This would lead to a higher granularity of the page size
(the RFC states it cannot exceed the sizelimit imposed by
the server; since slapd enforces limits on a per user basis,
in this way we may allow a higher granularity.

Pierangelo.

PS: regarding the question about unnecessary mallocs, I think
I fixed the one I noticed; there's a FIXME in
servers/slapd/controls.c
where you initially malloc 3*sizeof(LDAPControl *); is it
really necessary?

-- 
Pierangelo Masarati
mailto:pierangelo.masarati@sys-net.it


Comment 10 ando@openldap.org 2002-11-21 19:03:20 UTC
>
>
>
>
>
> Pierangelo,
>     Thanks for debugging this for me so quickly!  The paging worked fine
> on
> the second page for me and all subsequent pages for me, so I don't know
> why I didn't catch the error.

Typical of some libc implementations not to invalidate
memory after free()ing it :)

>   Are there still mallocs that should be
> changed to stack allocation per your previous post?

See my previous reply.

Pierangelo.

-- 
Pierangelo Masarati
mailto:pierangelo.masarati@sys-net.it


Comment 11 ando@openldap.org 2002-11-21 20:00:17 UTC
> to reuse a big chunk of code we might introduce a new type
> of limit in the limits stuff (see slapd.conf(5) "limits"
> and servers/slapd/limits.c); I'm thinking of a
>
> limits anonymous size.pr=10 size.pr=noEntriesLeft
>
> to limit the size of the page a specific user might request
> and to hide the number of entries left.
>
> This would lead to a higher granularity of the page size
> (the RFC states it cannot exceed the sizelimit imposed by
> the server; since slapd enforces limits on a per user basis,
> in this way we may allow a higher granularity.

I've committed a quick hack that implements this;
moreover, I think I've found a leak in back-bdb/search.c
where a ber was not freed after flattening.

Pierangelo.

-- 
Pierangelo Masarati
mailto:pierangelo.masarati@sys-net.it


Comment 12 lynnmoss@us.ibm.com 2002-11-21 21:32:09 UTC




Pierangelo,
> I fixed the one I noticed; there's a FIXME in
> servers/slapd/controls.c
> where you initially malloc 3*sizeof(LDAPControl *); is it
> really necessary?

I believe you are correct that this isn't necessary.  Thanks!
   Lynn

Comment 13 Kurt Zeilenga 2002-11-27 10:44:35 UTC
changed notes
changed state Test to Closed
Comment 14 Howard Chu 2009-02-17 06:59:13 UTC
moved from Contrib to Archive.Contrib
Comment 15 OpenLDAP project 2014-08-01 21:05:14 UTC
applied to HEAD with changes;
please test
targetted for 2.2.