i3-compatible Wayland compositor
Go to file
Rouven Czerwinski 46be87929f desktop: output: fix use-after-free in destroy
handle_destroy would mark the output es being destroyed and commit the
transaction. Committing the transaction results in the output being
freed, the output manager can not retrieve the server reference
afterwards, resulting in the following use-after-free:

==22746==ERROR: AddressSanitizer: heap-use-after-free on address 0x614000017088 at pc 0x560c1ac17136 bp 0x7ffeab146f20 sp 0x7ffeab146f10
READ of size 8 at 0x614000017088 thread T0
    #0 0x560c1ac17135 in handle_destroy ../sway/desktop/output.c:566
    #1 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
    #2 0x7f38af5d3dfc in drm_connector_cleanup ../subprojects/wlroots/backend/drm/drm.c:1448
    #3 0x7f38af5d2058 in scan_drm_connectors ../subprojects/wlroots/backend/drm/drm.c:1240
    #4 0x7f38af5c6a59 in drm_invalidated ../subprojects/wlroots/backend/drm/backend.c:135
    #5 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
    #6 0x7f38af5e827a in udev_event ../subprojects/wlroots/backend/session/session.c:52
    #7 0x7f38aef5d7f1 in wl_event_loop_dispatch (/usr/lib/libwayland-server.so.0+0xa7f1)
    #8 0x7f38aef5c39b in wl_display_run (/usr/lib/libwayland-server.so.0+0x939b)
    #9 0x560c1ac0afbe in server_run ../sway/server.c:225
    #10 0x560c1ac09382 in main ../sway/main.c:397
    #11 0x7f38aed35ce2 in __libc_start_main (/usr/lib/libc.so.6+0x23ce2)
    #12 0x560c1abea10d in _start (/usr/local/bin/sway+0x3910d)

0x614000017088 is located 72 bytes inside of 432-byte region [0x614000017040,0x6140000171f0)
freed by thread T0 here:
    #0 0x7f38af82df89 in __interceptor_free /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:66
    #1 0x560c1acbd1ed in output_destroy ../sway/tree/output.c:243
    #2 0x560c1ac23ce5 in transaction_destroy ../sway/desktop/transaction.c:66
    #3 0x560c1ac26b71 in transaction_progress_queue ../sway/desktop/transaction.c:348
    #4 0x560c1ac284ca in transaction_commit_dirty ../sway/desktop/transaction.c:539
    #5 0x560c1ac17110 in handle_destroy ../sway/desktop/output.c:564
    #6 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
    #7 0x7f38af5d3dfc in drm_connector_cleanup ../subprojects/wlroots/backend/drm/drm.c:1448
    #8 0x7f38af5d2058 in scan_drm_connectors ../subprojects/wlroots/backend/drm/drm.c:1240
    #9 0x7f38af5c6a59 in drm_invalidated ../subprojects/wlroots/backend/drm/backend.c:135
    #10 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
    #11 0x7f38af5e827a in udev_event ../subprojects/wlroots/backend/session/session.c:52
    #12 0x7f38aef5d7f1 in wl_event_loop_dispatch (/usr/lib/libwayland-server.so.0+0xa7f1)

previously allocated by thread T0 here:
    #0 0x7f38af82e5a1 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:95
    #1 0x560c1acbc228 in output_create ../sway/tree/output.c:91
    #2 0x560c1ac17ba2 in handle_new_output ../sway/desktop/output.c:656
    #3 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
    #4 0x7f38af5e4ce8 in new_output_reemit ../subprojects/wlroots/backend/multi/backend.c:143
    #5 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
    #6 0x7f38af5d26d4 in scan_drm_connectors ../subprojects/wlroots/backend/drm/drm.c:1294
    #7 0x7f38af5c6a59 in drm_invalidated ../subprojects/wlroots/backend/drm/backend.c:135
    #8 0x7f38af69330e in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
    #9 0x7f38af5e827a in udev_event ../subprojects/wlroots/backend/session/session.c:52
    #10 0x7f38aef5d7f1 in wl_event_loop_dispatch (/usr/lib/libwayland-server.so.0+0xa7f1)

SUMMARY: AddressSanitizer: heap-use-after-free ../sway/desktop/output.c:566 in handle_destroy
Shadow bytes around the buggy address:
  0x0c287fffadc0: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x0c287fffadd0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fffade0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fffadf0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fffae00: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
=>0x0c287fffae10: fd[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fffae20: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c287fffae30: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fa fa
  0x0c287fffae40: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c287fffae50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c287fffae60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Retrieve the reference before the output is destroyed and update the
output_management state with the saved reference.
2019-06-03 08:30:28 -04:00
.builds ci: enable all features 2019-04-25 10:00:55 -06:00
assets Recompressed PNG files 2017-01-05 21:49:28 -05:00
client swaybg: split into standalone project 2019-04-25 18:44:28 +03:00
common common/ipc-client: remove ipc recv timeout log 2019-06-03 08:30:28 -04:00
completions Add missing swaymsg completions 2019-03-08 15:28:35 -05:00
contrib A script to make inactive windows transparent 2018-10-20 21:58:00 +03:00
include Use parent get_root_coords in subsurfaces 2019-06-03 08:30:28 -04:00
protocols Implement pointer-constraints-unstable-v1 2019-01-30 19:53:59 +01:00
security.d delete references to swaygrab 2018-07-30 16:24:46 +01:00
sway desktop: output: fix use-after-free in destroy 2019-06-03 08:30:28 -04:00
swaybar swaybar: add multiseat support 2019-04-24 07:16:37 -06:00
swaymsg swaymsg: fix quiet error reporting 2019-05-03 11:09:49 -06:00
swaynag swaybg: split into standalone project 2019-04-25 18:44:28 +03:00
.clang-format Update .clang-format - not entirely usable yet 2017-01-10 23:30:34 -05:00
.editorconfig Create .editorconfig 2016-07-04 14:12:32 +02:00
.gitignore Allocate minimum size necessary in pango text functions. (#3473) 2019-01-20 15:03:30 +01:00
CONTRIBUTING.md CONTRIBUTING.md: mention tab width for line length 2019-01-14 19:46:54 +01:00
ISSUE_TEMPLATE.md issue template: add instructions for stack traces 2018-12-17 18:38:15 +01:00
LICENSE MIT license 2017-01-06 13:45:48 -05:00
README.de.md Add link to i3 in first mention of README 2019-04-27 17:28:24 -06:00
README.es.md Add link to i3 in first mention of README 2019-04-27 17:28:24 -06:00
README.fr.md Add link to i3 in first mention of README 2019-04-27 17:28:24 -06:00
README.ja.md Add link to i3 in first mention of README 2019-04-27 17:28:24 -06:00
README.md Add link to i3 in first mention of README 2019-04-27 17:28:24 -06:00
README.pl.md Add link to i3 in first mention of README 2019-04-27 17:28:24 -06:00
README.uk.md Add link to i3 in first mention of README 2019-04-27 17:28:24 -06:00
README.zh-CN.md Add link to i3 in first mention of README 2019-04-27 17:28:24 -06:00
config.in config.in: allow launch apps with args via dmenu 2019-03-12 08:16:45 -06:00
meson.build Bump required wlroots version 2019-05-03 13:10:53 -04:00
meson_options.txt Set version in project file 2019-02-05 14:32:05 +01:00
sway.desktop Update language in sway.desktop & sway(1) 2019-03-10 15:09:52 -04:00

README.md

sway

English - 日本語 - Français - Українська - Español - Polski - 中文-简体 - Deutsch

sway is an i3-compatible Wayland compositor. Read the FAQ. Join the IRC channel (#sway on irc.freenode.net).

If you'd like to support sway development, please contribute to SirCmpwn's Patreon page.

Release Signatures

Releases are signed with B22DA89A and published on GitHub.

Installation

From Packages

Sway is available in many distributions. Try installing the "sway" package for yours. If it's not available, check out this wiki page for information on installation for your distributions.

If you're interested in packaging sway for your distribution, stop by the IRC channel or shoot an email to sir@cmpwn.com for advice.

Compiling from Source

Install dependencies:

  • meson *
  • wlroots
  • wayland
  • wayland-protocols *
  • pcre
  • json-c
  • pango
  • cairo
  • gdk-pixbuf2 (optional: system tray)
  • scdoc (optional: man pages) *
  • git *

*Compile-time dep

Run these commands:

meson build
ninja -C build
sudo ninja -C build install

On systems without logind, you need to suid the sway binary:

sudo chmod a+s /usr/local/bin/sway

Sway will drop root permissions shortly after startup.

Configuration

If you already use i3, then copy your i3 config to ~/.config/sway/config and it'll work out of the box. Otherwise, copy the sample configuration file to ~/.config/sway/config. It is usually located at /etc/sway/config. Run man 5 sway for information on the configuration.

Running

Run sway from a TTY. Some display managers may work but are not supported by sway (gdm is known to work fairly well).