Bug 690526 - Double free in dse_add()
Summary: Double free in dse_add()
Status: CLOSED CURRENTRELEASE
Alias: None
Product: 389
Classification: Retired
Component: Directory Server
Version: 1.2.8
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Nathan Kinder
QA Contact: Viktor Ashirov
URL:
Whiteboard:
Keywords:
Depends On:
Blocks: 639035 389_1.2.8 690536
TreeView+ depends on / blocked
 
Reported: 2011-03-24 15:14 UTC by Nathan Kinder
Modified: 2015-12-07 17:00 UTC (History)
2 users (show)

(edit)
Clone Of:
: 690536 (view as bug list)
(edit)
Last Closed: 2015-12-07 17:00:39 UTC


Attachments (Terms of Use)
Patch for cov#10734 (2.19 KB, patch)
2011-03-24 15:18 UTC, Nathan Kinder
nkinder: review?
rmeggins: review+
Details | Diff

Description Nathan Kinder 2011-03-24 15:14:57 UTC
It's possible to encounter a double free of a Slapi_Entry in an error condition in dse_add().  This function makes a copy of the entry being added for use by postop plug-ins, but it can be free'd twice in the following code:

  e_copy = slapi_entry_dup(e);
  if ( dse_add_entry_pb(pdse, e_copy, pb) != 0)
  {
      slapi_send_ldap_result( pb, LDAP_OPERATIONS_ERROR, NULL, NULL, 0, NULL );
      slapi_sdn_done(&sdn);
      return dse_add_return(error, e_copy);
  }

The dse_add_entry_pb() function frees the passed in entry in all conditions, but dse_add_return() also free's the passed in entry.  This double free could trigger a crash.

The way dse_add works is that entry in SLAPI_ADD_ENTRY in the pblock should be consumed upon success, but will be left for the caller to deal with upon failure.  We should be passing NULL for the second argument to dse_add_return() to avoid the double free.

Comment 1 Nathan Kinder 2011-03-24 15:18:30 UTC
Created attachment 487370 [details]
Patch for cov#10734

Comment 2 Rich Megginson 2011-03-24 15:24:27 UTC
Do we need to get this in asap?

Comment 3 Nathan Kinder 2011-03-24 15:37:24 UTC
(In reply to comment #2)
> Do we need to get this in asap?

I don't know how easy it is to trigger this issue since it is in an error block when adding an entry to the dse backend, but it seems like we should try to get it in ASAP to me.

Comment 4 Nathan Kinder 2011-03-24 15:39:15 UTC
Pushed to master.  Thanks to Rich for his review!

Counting objects: 11, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 1.02 KiB, done.
Total 6 (delta 4), reused 0 (delta 0)
To ssh://git.fedorahosted.org/git/389/ds.git
   b41338f..1b22679  master -> master

Comment 5 Nathan Kinder 2011-03-24 15:43:42 UTC
Pushed to 389-ds-base-1.2.8 branch:

Counting objects: 11, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 1.02 KiB, done.
Total 6 (delta 4), reused 0 (delta 0)
To ssh://git.fedorahosted.org/git/389/ds.git
   e641e98..753c550  128-local -> 389-ds-base-1.2.8

Comment 6 Amita Sharma 2011-05-02 05:50:32 UTC
Rich has confirmed the issue is fixed.


Note You need to log in before you can comment on or make changes to this bug.