unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#11442: dbus uses Emacs integer as pointer, possible core dump
@ 2012-05-09 15:20 Paul Eggert
  2012-05-09 15:35 ` Michael Albinus
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Eggert @ 2012-05-09 15:20 UTC (permalink / raw)
  To: 11442; +Cc: Michael Albinus

The trunk version of Emacs src/dbusbind.c contains a function
xd_get_connection_address that does this:

     connection = (DBusConnection *) (intptr_t) XFASTINT (val);

This converts an Emacs integer to a pointer without checking
that it is actually of the proper C type.  It is possible
for Lisp code to mistakenly put an integer there that will
cause Emacs to dump core.  Shouldn't this be made safe, so
that Lisp code can't do that?  For example, a DbusConnection *
could be made a proper Lisp pseudovector or misc type or
something like that.  The idea is to avoid a bad pointer
leaking into the C code.





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

* bug#11442: dbus uses Emacs integer as pointer, possible core dump
  2012-05-09 15:20 bug#11442: dbus uses Emacs integer as pointer, possible core dump Paul Eggert
@ 2012-05-09 15:35 ` Michael Albinus
  2012-05-09 15:45   ` Andreas Schwab
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Albinus @ 2012-05-09 15:35 UTC (permalink / raw)
  To: Paul Eggert; +Cc: 11442

Paul Eggert <eggert@cs.ucla.edu> writes:

Hi Paul,

> The trunk version of Emacs src/dbusbind.c contains a function
> xd_get_connection_address that does this:
>
>     connection = (DBusConnection *) (intptr_t) XFASTINT (val);
>
> This converts an Emacs integer to a pointer without checking
> that it is actually of the proper C type.  It is possible
> for Lisp code to mistakenly put an integer there that will
> cause Emacs to dump core.

In general, I agree with you. In the given case, it is just a pointer
address which has been written in Fdbus_init_bus. No other place is
expected to write such an address, but since it is a Lisp object,
somebody could do by mistake.

>  Shouldn't this be made safe, so that Lisp code can't do that?  For
> example, a DbusConnection * could be made a proper Lisp pseudovector
> or misc type or something like that.  The idea is to avoid a bad
> pointer leaking into the C code.

DbusConnection * is included by <dbus/dbus.h>; we cannot make it a
private type. But if there is something we could add as "glue type",
please do. I'm not so familar with Emacs' internal type armors.

Best regards, Michael.





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

* bug#11442: dbus uses Emacs integer as pointer, possible core dump
  2012-05-09 15:35 ` Michael Albinus
@ 2012-05-09 15:45   ` Andreas Schwab
  2012-05-09 21:19     ` Michael Albinus
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2012-05-09 15:45 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 11442, Paul Eggert

Michael Albinus <michael.albinus@gmx.de> writes:

> Paul Eggert <eggert@cs.ucla.edu> writes:
>
> Hi Paul,
>
>> The trunk version of Emacs src/dbusbind.c contains a function
>> xd_get_connection_address that does this:
>>
>>     connection = (DBusConnection *) (intptr_t) XFASTINT (val);
>>
>> This converts an Emacs integer to a pointer without checking
>> that it is actually of the proper C type.  It is possible
>> for Lisp code to mistakenly put an integer there that will
>> cause Emacs to dump core.
>
> In general, I agree with you. In the given case, it is just a pointer
> address which has been written in Fdbus_init_bus. No other place is
> expected to write such an address, but since it is a Lisp object,
> somebody could do by mistake.

Why is Vdbus_registered_buses exported to lisp?

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





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

* bug#11442: dbus uses Emacs integer as pointer, possible core dump
  2012-05-09 15:45   ` Andreas Schwab
@ 2012-05-09 21:19     ` Michael Albinus
  2012-05-09 21:35       ` Paul Eggert
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Albinus @ 2012-05-09 21:19 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 11442, Paul Eggert

Andreas Schwab <schwab@linux-m68k.org> writes:

>> In general, I agree with you. In the given case, it is just a pointer
>> address which has been written in Fdbus_init_bus. No other place is
>> expected to write such an address, but since it is a Lisp object,
>> somebody could do by mistake.
>
> Why is Vdbus_registered_buses exported to lisp?

Indeed, that's the question.

When I wrote the new code for private buses, it was needed in dbus.el
(don't remember the reason). In the final code I've committed,
dbus-registered-buses isn't needed anymore on Lisp level.

I've converted it to be an internal Lisp object. Paul, is this
sufficient from your pov, or do we need more checks?

> Andreas.

Best regards, Michael.





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

* bug#11442: dbus uses Emacs integer as pointer, possible core dump
  2012-05-09 21:19     ` Michael Albinus
@ 2012-05-09 21:35       ` Paul Eggert
  0 siblings, 0 replies; 5+ messages in thread
From: Paul Eggert @ 2012-05-09 21:35 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Andreas Schwab, 11442-done

On 05/09/2012 02:19 PM, Michael Albinus wrote:
> I've converted it to be an internal Lisp object.

Thanks; that looks good.  Closing the bug.





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

end of thread, other threads:[~2012-05-09 21:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-09 15:20 bug#11442: dbus uses Emacs integer as pointer, possible core dump Paul Eggert
2012-05-09 15:35 ` Michael Albinus
2012-05-09 15:45   ` Andreas Schwab
2012-05-09 21:19     ` Michael Albinus
2012-05-09 21:35       ` Paul Eggert

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).