Bug 1896309

Summary: spausedd crashes with a segmentation fault if log_perror is called [RHEL 8]
Product: Red Hat Enterprise Linux 8 Reporter: Reid Wahl <nwahl>
Component: corosyncAssignee: Jan Friesse <jfriesse>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: high Docs Contact:
Priority: high    
Version: 8.3CC: ccaulfie, cluster-maint, phagara, sfoucek
Target Milestone: rc   
Target Release: 8.4   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: corosync-3.1.0-2.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1896311 (view as bug list) Environment:
Last Closed: 2021-05-18 15:26:09 UTC 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:
Bug Depends On:    
Bug Blocks: 1896311, 1901560    

Description Reid Wahl 2020-11-10 09:23:41 UTC
Description of problem:

spausedd fails with a segmentation fault if the log_perror() function is run. This function's call to log_printf() is missing a format argument. Its format string has three format specifiers but only two arguments in its VA list.

```
static void
log_perror(int priority, const char *s)
{
        int stored_errno;

        stored_errno = errno;

        log_printf(priority, "%s (%u): %s", stored_errno, strerror(stored_errno));
}
```

Running spausedd as a non-root user (thanks honzaf) is an easy way to reproduce the issue, but other error conditions can lead to the same issue in practice. If this happens, spausedd crashes immediately without printing a meaningful error or warning message.

-----

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

spausedd-3.0.3-4.el8

-----

How reproducible:

Always

-----

Steps to Reproduce:

1. Run spausedd as a non-root user.

-----

Actual results:

[testuser@fastvm-rhel-8-0-23 ~]$ spausedd
Nov 10 01:19:49 spausedd: Could not mlockall
Nov 10 01:19:49 spausedd: Segmentation fault (core dumped)

-----

Expected results:

No segmentation fault. Another error message such as "Can't get maximum SCHED_RR priority" or "Can't set SCHED_RR".

Comment 1 Reid Wahl 2020-11-10 09:25:35 UTC
Fixed upstream by commit cbb46dcc.

Comment 2 Jan Friesse 2020-11-10 09:38:36 UTC
Upstream patch:
https://github.com/jfriesse/spausedd/commit/cbb46dccb2804be3db142f5eb37acf2c0fa7e2b8

Fo QA: Reproducer is easy. Just run spausedd as a regular (non-root) user and it should crash.

Comment 6 Simon Foucek 2020-12-02 16:29:58 UTC
Before fix:
>[root@virt-020 ~]# useradd sfoucek
>[root@virt-020 ~]# su sfoucek
>[sfoucek@virt-020 root]$ rpm -q corosync
> corosync-3.0.3-4.el8.x86_64
>[sfoucek@virt-020 root]$ spausedd
>Dec 02 17:18:50 spausedd: Could not mlockall
>Dec 02 17:18:50 spausedd: Segmentation fault (core dumped)

Result before fix: Segmentation fault as described in the first post.

After fix:
>[root@virt-030 ~]# useradd sfoucek
>[root@virt-030 ~]# su sfoucek
>[sfoucek@virt-030 root]$ rpm -q corosync
>corosync-3.1.0-3.el8.x86_64
>[sfoucek@virt-030 root]$ spausedd
>Dec 02 17:13:46 spausedd: Could not mlockall
>Dec 02 17:13:46 spausedd: Can't open cgroups tasks file for writing
>Dec 02 17:13:46 spausedd: Can't set SCHED_RR (1): Operation not permitted
>Dec 02 17:13:46 spausedd: Running main poll loop with maximum timeout 200 and steal threshold 10%

Result after fix: No segmentation fault, "Can't set SCHED_RR" error occurs as described in the first post.

Comment 8 errata-xmlrpc 2021-05-18 15:26:09 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (corosync bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:1780