Bug 1858645 - GDB regression in gdb.base/corefile.exp due to kernel bug
Summary: GDB regression in gdb.base/corefile.exp due to kernel bug
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 32
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Kernel Maintainer List
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-07-19 21:50 UTC by Kevin Buettner
Modified: 2021-05-25 17:45 UTC (History)
22 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2021-05-25 17:45:35 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Kernel patch for GDB regression (1.72 KB, application/mbox)
2020-07-19 21:50 UTC, Kevin Buettner
no flags Details

Description Kevin Buettner 2020-07-19 21:50:26 UTC
Created attachment 1701683 [details]
Kernel patch for GDB regression

1. Please describe the problem:

I'm seeing a GDB regression when running gdb.base/corefile.exp.  This is NOT a GDB problem.  I have isolated the problem to a specific recent kernel patch and found a typo in that patch.  I have a fix for this problem.

2. What is the Version-Release number of the kernel:

Fedora 32: 5.6.16-300.fc32, 5.6.19-300.fc32, 5.7.8-200.fc32. (And, to the best of my knowledge, all versions in between the above listed versions too.)

Rawhide: 5.8.0-0.rc5.20200717git07a56bb875af.1.fc33

3. Did it work previously in Fedora? If so, what kernel version did the issue
   *first* appear?  Old kernels are available for download at
   https://koji.fedoraproject.org/koji/packageinfo?packageID=8 :

The GDB regression occurs in 5.6.16-300.fc32.

No GDB regression in 5.6.15-300.fc32.

4. Can you reproduce this issue? If so, please provide the steps to reproduce
   the issue below:

4a) Fetch upstream GDB sources from git:

git clone git://sourceware.org/git/binutils-gdb.git

4b) Build gdb:

cd binutils-gdb
mkdir inst
./configure --prefix=`pwd`/inst
make -j24 && make install

4c) Run gdb.base/corefile.exp test:

cd gdb
make check RUNTESTFLAGS="gdb.base/corefile.exp"

4d) Observe failure and summary output:

FAIL: gdb.base/corefile.exp: core-file warning-free

		=== gdb Summary ===

# of expected passes		27
# of unexpected failures	1

There should be no unexpected failures when running this test.

4e) Run gdb by hand to see problem when loading core file:

./gdb -q testsuite/outputs/gdb.base/corefile/corefile{,.core}

4f) Observe output from above command:

Reading symbols from testsuite/outputs/gdb.base/corefile/corefile...
[New LWP 64835]

warning: Unexpected size of section `.reg-xstate/64835' in core file.
Core was generated by `/mesquite2/scratch/binutils-gdb/gdb/testsuite/outputs/gdb.base/corefile/corefil'.
Program terminated with signal SIGABRT, Aborted.

warning: Unexpected size of section `.reg-xstate/64835' in core file.
#0  0x00007ff548f5ea25 in raise () from /lib64/libc.so.6
(gdb) 

4g) Discussion:

The problem in the above output is the warning:
  "warning: Unexpected size of section `.reg-xstate/64835' in core file."

The rest of the output is okay / expected.

5. Does this problem occur with the latest Rawhide kernel? To install the
   Rawhide kernel, run ``sudo dnf install fedora-repos-rawhide`` followed by
   ``sudo dnf update --enablerepo=rawhide kernel``:

Yes, I've tested on Rawhide using the latest kernel available at the time of this bug report: 5.8.0-0.rc5.20200717git07a56bb875af.1.fc33.  I see the same problem in that rawhide kernel.

6. Are you running any modules that not shipped with directly Fedora's kernel?:

No.

7. Please attach the kernel logs. You can get the complete kernel log
   for a boot with ``journalctl --no-hostname -k > dmesg.txt``. If the
   issue occurred on a previous boot, use the journalctl ``-b`` flag.

Kernel logs are not relevant for this problem.

I'm an upstream GDB developer.  I've investigated this regression to see where the problem lies.  The problem is *not* in GDB.

I found that the GDB regression goes away when I revert upstream commit 9e4636545933131de15e1ecd06733538ae939b2f :

https://github.com/torvalds/linux/commit/9e4636545933131de15e1ecd06733538ae939b2f

It's a patch by Al Viro titled "copy_xstate_to_kernel(): don't leave parts of destination uninitialized".  There is a bug/typo in this patch in accessing xstate_offsets[].  XFEATURE_MASK_SSE is used as an index, which is not correct; the index XFEATURE_SSE should have been used instead.

I've sent a patch fixing this problem to Al Viro <viro.org.uk> and the main linux kernel mailing list (linux-kernel.org).  (I don't do this very often; it's possible that some other list might have been more appropriate.)  Here's a link to my patch:

https://lkml.org/lkml/2020/7/18/96

I've added my patch as an attachment too.

I've tested my patch against 5.8.0-0.rc5.20200715gite9919e11e219.1 on rawhide and 5.7.8-200 on Fedora 32. In both cases, the GDB regression reported above has been fixed when using my patch.

Comment 1 Kevin Buettner 2020-07-20 15:50:52 UTC
Several additional remarks...

1) In order to see the test failure, it's necessary to run the following command as root:

echo core > /proc/sys/kernel/core_pattern

So this needs to be done at the beginning of step 4c in my initial bug report.  (I forgot about this because I have this permanently enabled on my development machines.)

2) Greg Kroah-Hartman has added my patch to the following trees: 4.14-stable, 4.19-stable, 5.4-stable, 5.7-stable.

3) Al Viro has added it to his vfs.git#fixes tree:

https://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git/commit/?h=fixes&id=8d95867c8610c515ffab2913b2cb19b2c7f7f6c1

Comment 2 Fedora Program Management 2021-04-29 17:04:51 UTC
This message is a reminder that Fedora 32 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 32 on 2021-05-25.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '32'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 32 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 3 Ben Cotton 2021-05-25 17:45:35 UTC
Fedora 32 changed to end-of-life (EOL) status on 2021-05-25. Fedora 32 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.