Bug 1951905

Summary: pkttyagent dumps core when user hits Ctrl-D
Product: Red Hat Enterprise Linux 7 Reporter: Renaud Métrich <rmetrich>
Component: polkitAssignee: Jan Rybar <jrybar>
Status: NEW --- QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: medium    
Version: 7.9CC: tpopela
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Renaud Métrich 2021-04-21 07:22:20 UTC
Description of problem:

When the user hits Ctrl-D, pkttyagent gets a SIGTRAP and dumps core.
See also BZ #1898038 on RHEL8.

We can see pkttyagent send a "Got unexpected " message as "g_error()" level:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
286       else if (c == EOF)
287         {
288           tcsetattr (fileno (listener->tty), TCSAFLUSH, &ots);
289           g_error ("Got unexpected EOF while reading from controlling terminal.");
290           abort ();
291           break;
292         }
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

This ends up being a fatal error for glib2:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
 557 static void
 558 _g_log_abort (gboolean breakpoint)
 559 {
 560   gboolean debugger_present;
 :
 575   /* Assume GDB is attached. */
 576   debugger_present = TRUE;
 577 #endif /* !G_OS_WIN32 */
 578 
 579   if (debugger_present && breakpoint)
 580     G_BREAKPOINT ();
 581   else
 582     g_abort ();
 583 }
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Since "debugger_present" in glib2 is always set to TRUE, this causes a SIGTRAP to be generated, which dumps core.


pkttyagent backtrace:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
#0  _g_log_abort (breakpoint=1) at gmessages.c:583
#1  0x00007f69294ecb71 in g_log_default_handler (log_domain=log_domain@entry=0x0, log_level=log_level@entry=6, 
    message=message@entry=0x7f6914002930 "Got unexpected EOF while reading from controlling terminal.", 
    unused_data=unused_data@entry=0x0) at gmessages.c:3158
#2  0x00007f69294ecd61 in g_logv (log_domain=0x0, log_level=G_LOG_LEVEL_ERROR, format=<optimized out>, 
    args=args@entry=0x7f691fffe580) at gmessages.c:1370
#3  0x00007f69294ecfef in g_log (log_domain=log_domain@entry=0x0, log_level=log_level@entry=G_LOG_LEVEL_ERROR, 
    format=format@entry=0x7f6929a08da8 "Got unexpected EOF while reading from controlling terminal.")
    at gmessages.c:1432
#4  0x00007f6929a07acf in on_request (session=0x7f6918005300, request=<optimized out>, echo_on=<optimized out>, 
    user_data=<optimized out>) at polkitagenttextlistener.c:289
 :
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------



Version-Release number of selected component (if applicable):

glib2-2.56.1-8.el7.x86_64

How reproducible:

Always

Steps to Reproduce:
1. As a normal non-wheel user, perform a "systemctl restart rsyslog"
2. Prompt to choose a wheel user comes in, hit Ctrl-D

Actual results:

Coredump

Expected results:

No coredump