Bug 732989 - sftp always exits with invalid pointer
Summary: sftp always exits with invalid pointer
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: libedit
Version: rawhide
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Kamil Dudka
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 728413 732286 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-08-24 12:00 UTC by Tomáš Bžatek
Modified: 2015-03-03 23:01 UTC (History)
12 users (show)

Fixed In Version: libedit-3.0-4.20110227cvs.fc16
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-09-09 05:24:04 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Tomáš Bžatek 2011-08-24 12:00:49 UTC
Description of problem:
sftp command always fails with 
*** glibc detected *** /usr/bin/sftp: free(): invalid pointer: 0xd8d8d8d8d8d8d8d8 ***
on program exit

Version-Release number of selected component (if applicable):
glibc-2.14.90-5.x86_64
openssh-5.8p2-20.fc17.x86_64

How reproducible:
always

Steps to Reproduce:
$ sftp localhost
tbzatek@localhost's password: 
Connected to localhost.
sftp> ^D
*** glibc detected *** sftp: free(): invalid pointer: 0xd8d8d8d8d8d8d8d8 ***
*** glibc detected *** sftp: free(): invalid pointer: 0xd8d8d8d8d8d8d8d8 ***
*** glibc detected *** sftp: free(): invalid pointer: 0xd8d8d8d8d8d8d8d8 ***
*** glibc detected *** sftp: free(): invalid pointer: 0xd8d8d8d8d8d8d8d8 ***

Additional info:
Where should I place breakpoint in gdb to catch this?

Comment 1 Jan F. Chadima 2011-08-25 08:31:07 UTC
*** Bug 732286 has been marked as a duplicate of this bug. ***

Comment 2 Jan F. Chadima 2011-08-25 08:33:15 UTC
(In reply to comment #0)
> Description of problem:
> sftp command always fails with 
> *** glibc detected *** /usr/bin/sftp: free(): invalid pointer:
> 0xd8d8d8d8d8d8d8d8 ***
> on program exit
> 
> Version-Release number of selected component (if applicable):
> glibc-2.14.90-5.x86_64
> openssh-5.8p2-20.fc17.x86_64
> 
> How reproducible:
> always
> 

I unsuccessfuly tried to reproduce it.


> Steps to Reproduce:
> $ sftp localhost
> tbzatek@localhost's password: 
> Connected to localhost.
> sftp> ^D
> *** glibc detected *** sftp: free(): invalid pointer: 0xd8d8d8d8d8d8d8d8 ***
> *** glibc detected *** sftp: free(): invalid pointer: 0xd8d8d8d8d8d8d8d8 ***
> *** glibc detected *** sftp: free(): invalid pointer: 0xd8d8d8d8d8d8d8d8 ***
> *** glibc detected *** sftp: free(): invalid pointer: 0xd8d8d8d8d8d8d8d8 ***
> 
> Additional info:
> Where should I place breakpoint in gdb to catch this?

int
sftp_server_main(int argc, char **argv, struct passwd *user_pw)

Comment 3 Jan F. Chadima 2011-08-25 08:35:49 UTC
*** Bug 728413 has been marked as a duplicate of this bug. ***

Comment 4 Hin-Tak Leung 2011-08-25 10:24:30 UTC
Hmm, I am a bit annoyed that (1) the earlier bug report was closed as a duplicate of a later one - with little additional information - it would only be fair to close an earlier report as duplicate of a later one if the 2nd bug report was accompanied by a fix, (2) the newer bug report is not viewable without logging on.

While I understand the latter might be a security issue, considered that the first one is still open to public's viewing, it doesn't make sense to protect the 2nd... Likewise, although Bug 732286 looks related (mem=0xe0e0e0e0e0e0e0e0), I'd rather it is closed as duplicate if/when there is a diagnosis/fix here, and it does not make sense to protect a later report if the earlier one is still viewable to public.

Anyway, since there are two people who consistently reproduce this bug, I hope something good can come out soon.

Comment 5 Tomas Mraz 2011-08-25 11:06:55 UTC
I do not really think this is a Security sensitive bug as the sftp process is running with the user credentials.

Comment 6 Josh Bressers 2011-08-25 11:13:01 UTC
I can get sftp to segfault if I run sftp with the environment variable MALLOC_PERTURB_=106 set.

Comment 7 Hin-Tak Leung 2011-08-25 11:22:53 UTC
(In reply to comment #6)
> I can get sftp to segfault if I run sftp with the environment variable
> MALLOC_PERTURB_=106 set.

Indeed I have these from "export":
declare -x MALLOC_CHECK_="1"
declare -x MALLOC_PERTURB_="145"

They came from "/etc/sysconfig/debug" - beside those those, 
it also set a 3rd variable:
export G_SLICE=debug-blocks

"/etc/sysconfig/debug" comes from a package called debugmode-9.30-2.fc15.x86_64,
 initscripts-9.30-2.fc15.src.rpm as is.

Comment 8 Jan F. Chadima 2011-08-25 12:42:54 UTC
the problem is caused by the EdiLine destructor called from sftp.

Comment 9 Tomas Mraz 2011-08-25 13:41:09 UTC
Yes, there is clear bug in the libedit el_end() - there is an use of memory after free.

Comment 10 Kamil Dudka 2011-08-25 13:50:30 UTC
This should fix it:

diff --git a/src/el.c b/src/el.c
index 168734c..d41bb3b 100644
--- a/src/el.c
+++ b/src/el.c
@@ -139,13 +139,13 @@ el_end(EditLine *el)
    sig_end(el);

    el_free((ptr_t) el->el_prog);
-   el_free((ptr_t) el);
 #ifdef WIDECHAR
    el_free((ptr_t) el->el_scratch.cbuff);
    el_free((ptr_t) el->el_scratch.wbuff);
    el_free((ptr_t) el->el_lgcyconv.cbuff);
    el_free((ptr_t) el->el_lgcyconv.wbuff);
 #endif
+   el_free((ptr_t) el);
 }

Comment 11 Kamil Dudka 2011-08-26 10:54:42 UTC
fixed in libedit-3.0-3.20110802cvs.fc17

Comment 12 Fedora Update System 2011-08-26 11:32:00 UTC
libedit-3.0-4.20110227cvs.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/libedit-3.0-4.20110227cvs.fc16

Comment 13 Fedora Update System 2011-08-26 11:32:03 UTC
libedit-3.0-4.20110227cvs.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/libedit-3.0-4.20110227cvs.fc15

Comment 14 Fedora Update System 2011-08-26 14:17:52 UTC
Package libedit-3.0-4.20110227cvs.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing libedit-3.0-4.20110227cvs.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/libedit-3.0-4.20110227cvs.fc16
then log in and leave karma (feedback).

Comment 15 Fedora Update System 2011-09-09 05:23:57 UTC
libedit-3.0-4.20110227cvs.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 16 Fedora Update System 2011-09-09 16:55:38 UTC
libedit-3.0-4.20110227cvs.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.


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