LTP sigaltstack02 test failure -- MINSIGSTKSZ in userspace missmatches kernel (was: sigaltstack system call unable to send proper return code (error12))

Bug #1267062 reported by U JAGAN MOHAN
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
eglibc (Ubuntu)
New
Undecided
Unassigned
linux (Ubuntu)
Invalid
High
Andy Whitcroft

Bug Description

9.3.189.114 (root/.pasroot) (Host Machine)
Run the follwoing command to go to the guest victim machine from (/var/lib/libvirt/images/jagan/new_ubuntu_alpha1)

qemu-system-ppc64 -enable-kvm -M pseries -cpu POWER8 -smp 1 -m 10G -nographic -nodefaults -monitor stdio -serial pty -append "root=/dev/sda" -kernel trusty-server-cloudimg-ppc64el-vmlinuz-generic -device spapr-vscsi -device spapr-vlan,netdev=net0,mac=6c:ae:8b:69:16:15 -netdev bridge,br=virbr0,id=net0 -drive file=trusty-server-cloudimg-ppc64el.img.qcow2

after this command you will get the screen number.
example:

QEMU 1.6.0 monitor - type 'help' for more information
(qemu) char device redirected to /dev/pts/16 (label serial0)

Then open another host session and execute the below command

# screen /dev/pts/16
(qemu)

Here the screen number is /dev/pts/16

-->>Then you will get a blank screen so press ENTER key.

The guest machine login: ubuntu/passw0rd

Then do --->sudo -i

Environment:
===========
Host: Power8
Guest : ubuntu hosted on Power8
The issue:
======
sigaltstack system call unable send proper return value.

How to run :
========
-->cd /root/ltp-full-20130904/testcases/kernel/syscalls/sigaltstack

--> ./sigaltstack02 ==> Getting the below error

sigaltstack02 1 TPASS : stgaltstack() fails, Invalid Flag value, errno:22
sigaltstack02 2 TFAIL : sigaltstack() returned 0, expected -1, errno:12 =====>> FAIL

<<<test_start>>>
tag=sigaltstack02 stime=1386653793
cmdline="sigaltstack02"
contacts=""
analysis=exit
<<<test_output>>>
sigaltstack02 1 TPASS : stgaltstack() fails, Invalid Flag value, errno:22
sigaltstack02 2 TFAIL : sigaltstack() returned 0, expected -1, errno:12
<<<execution_status>>>
initiation_status="ok"
duration=0 termination_type=exited termination_id=1 corefile=no
cutime=0 cstime=0
<<<test_end>>>

sigaltstack() should fail and set errno to ENOMEM when the size of alternate stack area is less than MINSIGSTKSZ.
But here its sigaltstack() is returning 0.

Revision history for this message
Brad Figg (brad-figg) wrote : Missing required logs.

This bug is missing log files that will aid in diagnosing the problem. From a terminal window please run:

apport-collect 1267062

and then change the status of the bug to 'Confirmed'.

If, due to the nature of the issue you have encountered, you are unable to run this command, please add a comment stating that fact and change the bug status to 'Confirmed'.

This change has been made by an automated script, maintained by the Ubuntu Kernel Team.

Changed in linux (Ubuntu):
status: New → Incomplete
U JAGAN MOHAN (jamohan2)
Changed in linux (Ubuntu):
status: Incomplete → Confirmed
Changed in linux (Ubuntu):
importance: Undecided → High
tags: added: kernel-da-key trusty
Revision history for this message
Joseph Salisbury (jsalisbury) wrote : Re: sigaltstack system call unable to send proper return code (error12)

The Ubuntu-3.13.0-0.15 kernel has been copied into the bootstrap archive and should be available for update. This kernel is based on the v3.13-rc7 kernel. If we could retest with that kernel that would help. Please report any testing here.

Changed in linux (Ubuntu):
assignee: nobody → Andy Whitcroft (apw)
Revision history for this message
Andy Whitcroft (apw) wrote :

Ok I have tried this out on postal02, configured LTP as below:

    ./configure --build powerpc64le-linux-gnu --target powerpc64le-linux-gnu

The test fails as indicated. I have fiddled with the parameters and using 2048-1 as the limit triggers the test correctly, though MINSIGSTKSZ is 4096. The limit seems to correspond to the limit as expressed by the kernel:

    arch/powerpc/include/uapi/asm/signal.h:#define MINSIGSTKSZ 2048

This accounts for the test failure. It is arguable that the MINSIGSTKSZ should match the kernel limit exactly but as the limit is greater than the kernel limit it is equally arguable it is valid minimum.

That said the eglibc is offering this constant:

    +/* Minimum stack size for a signal handler. */
    +#define MINSIGSTKSZ 4096

This is part of the ppc64el delta for this package.

Revision history for this message
Adam Conrad (adconrad) wrote :

This constant selection in glibc seems quite deliberate, according to Alan's commit message upstream:

https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=f7c399cff5bd04ee9dc117fb6b0f39597dc047c6

This leads one to wonder if perhaps the kernel is wrong here, or if ltp's just being silly. I'm not sure which.

Andy Whitcroft (apw)
summary: - sigaltstack system call unable to send proper return code (error12)
+ LTP sigaltstack02 test failure -- MINSIGSTKSZ in userspace missmatches
+ kernel (was: sigaltstack system call unable to send proper return code
+ (error12))
Revision history for this message
Anasuya M Shankar (anasuyams) wrote :

Continue to see it ubuntu_alpha2 build:

root@anasuya:~/ltp-full-20140115/testcases/kernel/syscalls/sigaltstack# uname -a
Linux anasuya 3.13.0-10-generic #30-Ubuntu SMP Tue Feb 18 23:06:18 UTC 2014 ppc64le ppc64le ppc64le GNU/Linux
root@anasuya:~/ltp-full-20140115/testcases/kernel/syscalls/sigaltstack#

root@anasuya:~/ltp-full-20140115/testcases/kernel/syscalls/sigaltstack# ./sigaltstack02
sigaltstack02 1 TPASS : stgaltstack() fails, Invalid Flag value, errno:22
sigaltstack02 2 TFAIL : sigaltstack() returned 0, expected -1, errno:12

Revision history for this message
Anasuya M Shankar (anasuyams) wrote :

Hi Andy, Any update on this defect?

Revision history for this message
Andy Whitcroft (apw) wrote :

@Anasuya -- the failure here is triggered by what I would think of as an invalid assumption in the LTP test in this case. The value MINSIGSTKSZ says that you should have your stack bigger than this to be valid. It does not actually say that if it is one byte fewer than the limit it will not work. The libc lower limit differs from the kernel absolute limit for this case which is why the test fails on this architecture. But the value libc recommends is bigger and therefore valid.

I don't believe anything is wrong as such, just the test's assumption is wrong.

Revision history for this message
Kalpana S Shetty (kalshett) wrote :

Anasuya, can you please check what is the #define for "MINSIGSTKSZ" and take appropriate correction in the test suites. Hopefully it should match all distros not just Ubuntu.

Revision history for this message
Kalpana S Shetty (kalshett) wrote :

Please lower the severity to lower say medium not high.

Revision history for this message
Kalpana S Shetty (kalshett) wrote :

Here is my analysis with a small code:

Summary:
If we include signal.h from usr/include: MINSIGSTKSZ -----> 4096 ###TC case FAIL
If we explicitly include signal.h from ppc64le : MINSIGSTKSZ -----> 4096 ###TC case PASS

In my opinion glibc should be taken care to point to right signal.h when an appln includes signal.h, in this case when appln include "signal.h" it should be taken from --> "/usr/include/powerpc64le-linux-gnu/asm/signal.h" NOT from "/usr/include/signal.h".

Conclusion: I do not see this is a test case issue.

root@ubuntuk60:~# cat s1.c
/*
 * TC1:
 * sigaltstack() should fails and sets errno to ENOMEM when the size of alternate
 * stack area is less than MINSIGSTKSZ.
*/
#include <stdio.h>
//#include <signal.h>
#include "/usr/include/powerpc64le-linux-gnu/asm/signal.h"
#include <errno.h>

int main()
{
 stack_t sigstk; /* signal stack storing struct. */
 int rc;

 sigstk.ss_size = MINSIGSTKSZ - 1;
 sigstk.ss_flags = 0;

 printf ("MINSTKSZ = %d\n", MINSIGSTKSZ);
 /* Verify sigaltstack() fails and sets errno */
 rc = sigaltstack(&sigstk, (stack_t *) 0);
 if (rc < 0)
 {
  // TC pass if rc < 0
  printf ("FAILED: rc = %d, errono = %d\n", rc, errno);
 }
 else {
  printf ("PASS: rc = %d, errono = %d\n", rc, errno);
 }
}

output TC PASS: used with "#include "/usr/include/powerpc64le-linux-gnu/asm/signal.h"
root@ubuntuk60:~# ./a.out
MINSTKSZ = 2048
FAILED: rc = -1, errono = 12

output TC FAILED: used with #include <signal.h>
root@ubuntuk60:~# ./a.out
MINSTKSZ = 4096
PASS: rc = 0, errono = 0

Revision history for this message
Alan Modra (amodra) wrote :

This is a stupid testcase, the failure should be ignored.

The glibc values for MINSIGSTKSZ and SIGSTKSZ must be large enough to cover all known kernels, so that user programs will run on any kernel and with any usage of vmx, htm and whatever else changes context size.

The values in the kernel on the other hand are for testing whether a given binary will run on that kernel. In the absence of knowledge regarding whether a binary makes use of htm or vsx, the kernel values must be the minimum allowed on all known kernels. Otherwise an old binary that doesn't make use of vsx or htm will no longer run on a new kernel.

Changed in linux (Ubuntu):
status: Confirmed → Invalid
Revision history for this message
Kalpana S Shetty (kalshett) wrote :

My question is which header file to include in application code for "signal.h"?

Since each of these header file include in the application code seems different definiation.

With the sample code I include in #10 if we include <signal.h> I see MINSIGSTKSZ ----> 4096

and

If #include "/usr/include/powerpc64le-linux-gnu/asm/signal.h" I see MINSIGSTKSZ ----> 2048

It would be good if you can give suggestion/input on which header file to include in appln. code for signal.h

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.