#882055 gedit aborts when writing to a file with setuid bit

Package:
gedit
Source:
gedit
Description:
popular text editor for the GNOME desktop environment
Submitter:
Narcis Garcia
Date:
2017-11-25 12:18:06 UTC
Severity:
normal
#882055#5
Date:
2017-11-18 09:16:27 UTC
From:
To:
(reproduced with amd64 architecture, Gnome desktop)
Problem occurs on 30% of tries

1. Open an existing file with Gedit
2. Modify something
3. Save (i.e. pressing Ctrl+S)

Results:

- Gedit breaks with message:
GLib-GIO:ERROR:/build/glib2.0-B1uXKV/glib2.0-2.50.3/./gio/glocalfilemonitor.c:433:g_file_monitor_source_handle_event:
code should not be reached

- Text file is truncated to 0 bytes. No backup. Unrecoverable content.

#882055#10
Date:
2017-11-18 10:15:43 UTC
From:
To:
Nautilus seems to break at same time.
Circumstance can be that files to write has r+w permission for
everybody, but aren't owned by current user (i.e.: root:users)

#882055#15
Date:
2017-11-23 12:28:02 UTC
From:
To:
Worked fine, with no error, on Gedit version 3.10

The problem seems to be, although text file is readable and writable to
owner & group & others, when saving from another user different to file
owner.

#882055#20
Date:
2017-11-25 10:32:34 UTC
From:
To:
Control: tags -1 moreinfo unreproducible

Problem is not reproducible here
I've created a file (userA:userA owned), then ran chmod 646 file.txt.
Gedit will write to the file just fine.

Please install dbgsym packages for gedit and create a proper backtrace.

#882055#27
Date:
2017-11-25 11:17:14 UTC
From:
To:
Sorry, I forgot to test with and without setuid bit:

$ id -un
userA
$ echo "Content text" > file.txt
$ sudo chown userB file.txt
$ sudo chmod u+s,g+rw file.txt

$ nano file.txt
# Modyfy and save: Fine.

$ gedit file.txt
# Modify and save:
GLib-GIO:ERROR:/build/glib2.0-B1uXKV/glib2.0-2.50.3/./gio/glocalfilemonitor.c:433:g_file_monitor_source_handle_event:
code should not be reached

#882055#32
Date:
2017-11-25 11:29:15 UTC
From:
To:
Am 25.11.2017 um 12:17 schrieb Narcis Garcia:

Given the special circumstances which are needed to trigger this issue,
I'm downgrading the severity.

#882055#41
Date:
2017-11-25 11:36:37 UTC
From:
To:
Have present that this bug does not make Gedit "completely unusable to
everyone" (important), but "causes data loss" (grave), and it's a grave
problem when someone uses Gedit to edit configuration files, source code
files or script files:

https://www.debian.org/Bugs/Developer#severities

(Gedit is not used by most of people as a common word processor)

#882055#48
Date:
2017-11-25 12:14:09 UTC
From:
To:
Am 25.11.2017 um 12:36 schrieb Narcis Garcia:

I'm well aware of the different bug severities, thank you.

That said, having the setuid bit set for a text file simply doesn't make
any sense so I doubt anyone will be actually affected by this in
practice as no such files should exist.

The setuid bit only makes sense in the context of binaries which can be
executed.