Bug 700

Summary: PPC64 set/swapcontext do not restore the CCR
Product: glibc Reporter: Steven Munroe <sjmunroe>
Component: libcAssignee: Steven Munroe <sjmunroe>
Status: RESOLVED FIXED    
Severity: critical CC: drepper.fsp, fweimer, glibc-bugs
Priority: P2 Flags: fweimer: security-
Version: 2.3.4   
Target Milestone: ---   
Host: powerpc64-linux Target: powerpc64-linux
Build: powerpc64-linux Last reconfirmed:
Project(s) to access: ssh public key:
Bug Depends on:    
Bug Blocks: 724    
Attachments: Patch for PPC64 set/swapcontext CCR restore bug
Improved patch per Jakub
Newer more improved patch per Jakub

Description Steven Munroe 2005-01-31 23:35:04 UTC
The powerpc64 set/swap context function do not restore the Condition Code
Register  (CCR) due to a typo where the mnemonic for Move from Condition
Register (mfcr) instead of the correct mnemonic mtcr.

Also noticed that the MSR field was being loaded as a word. Should be double
word for 64-bit.
Comment 1 Steven Munroe 2005-01-31 23:37:52 UTC
Created attachment 391 [details]
Patch for PPC64 set/swapcontext CCR restore bug
Comment 2 Steven Munroe 2005-01-31 23:40:43 UTC
This should also be applied to the 2-3-branch
Comment 3 Jakub Jelinek 2005-02-07 09:02:43 UTC
I don't think this should be RESOLVED/FIXED, given that it has not been
applied to CVS.
Anyway, there are grep lwz.*MSR sysdeps/unix/sysv/linux/powerpc64/*.S
shows 2 occurrences in setcontext.S and 2 in swapcontext.S.  Are you sure you
want to patch just one and not the other one in each of those files?
Comment 4 Steven Munroe 2005-02-07 14:55:10 UTC
Created attachment 396 [details]
Improved patch per Jakub
Comment 5 Steven Munroe 2005-02-07 14:56:42 UTC
Sorry different bugzilla's have different rules. Improved patch above per
Jakub's comments.
Comment 6 Steven Munroe 2005-02-07 14:58:51 UTC
Is it appropriate to assign this bug to myself at thsi point as I am supplying
the fix?
Comment 7 Jakub Jelinek 2005-02-07 15:05:04 UTC
Looks good to me, except the ChangeLog entry:
1) setcontext.S contains {__novec_,__}setcontext, not *getcontext
2) updating of Copyright year does not belong to ChangeLog, unless the year 
   change is e.g. in the messages printed by some program or library
3) When the description is identical for multiple functions and/or files,
   you should just write it for the first one and use Likewise. for the rest.
So IMHO you want something like:

2005-02-07  Steven Munroe  <sjmunroe@us.ibm.com>

        [BZ #700]
        * sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S
        (__novec_setcontext, __setcontext): Fix a typo so CCR is restored.
        Load MSR as a doubleword.
        * sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S
        (__novec_swapcontext, __swapcontext): Likewise.

Surely you can assign the bug to yourself, even already when you start
working on the fix to prevent others from duplicating the work.
Comment 8 Steven Munroe 2005-02-07 15:17:40 UTC
Created attachment 397 [details]
Newer more improved patch per Jakub

Dyslexics R us... Also may be time for new bifocals ;-)
Comment 9 Ulrich Drepper 2005-02-07 23:26:01 UTC
Applied.
Comment 10 Sourceware Commits 2005-02-16 11:19:02 UTC
Subject: Bug 700

CVSROOT:	/cvs/glibc
Module name:	libc
Branch: 	glibc-2_3-branch
Changes by:	roland@sources.redhat.com	2005-02-16 11:18:21

Modified files:
	sysdeps/unix/sysv/linux/powerpc/powerpc64: setcontext.S 
	                                           swapcontext.S 

Log message:
	2005-02-07  Steven Munroe  <sjmunroe@us.ibm.com>
	
	[BZ #700]
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S
	(__novec_setcontext, __setcontext): Fix typo so CCR is restored.
	Load MSR as a doubleword.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S
	(__novec_swapcontext, __swapcontext): Likewise.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S.diff?cvsroot=glibc&only_with_tag=glibc-2_3-branch&r1=1.9&r2=1.9.2.1
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S.diff?cvsroot=glibc&only_with_tag=glibc-2_3-branch&r1=1.12&r2=1.12.2.1

Comment 11 Florian Weimer 2019-04-10 08:49:46 UTC
No documented application impact, so flagging as security-.