Skip to content

Commit 937a91c

Browse files
danglin44gregkh
authored andcommitted
parisc: Fix validity check of pointer size argument in new CAS implementation
commit 05f016d2ca7a4fab99d5d5472168506ddf95e74f upstream. As noted by Christoph Biedl, passing a pointer size of 4 in the new CAS implementation causes a kernel crash. The attached patch corrects the off by one error in the argument validity check. In reviewing the code, I noticed that we only perform word operations with the pointer size argument. The subi instruction intentionally uses a word condition on 64-bit kernels. Nullification was used instead of a cmpib instruction as the branch should never be taken. The shlw pseudo-operation generates a depw,z instruction and it clears the target before doing a shift left word deposit. Thus, we don't need to clip the upper 32 bits of this argument on 64-bit kernels. Tested with a gcc testsuite run with a 64-bit kernel. The gcc atomic code in libgcc is the only direct user of the new CAS implementation that I am aware of. Signed-off-by: John David Anglin <dave.anglin@bell.net> Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent aef7cdb commit 937a91c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

arch/parisc/kernel/syscall.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -688,15 +688,15 @@ cas_action:
688688
/* ELF32 Process entry path */
689689
lws_compare_and_swap_2:
690690
#ifdef CONFIG_64BIT
691-
/* Clip the input registers */
691+
/* Clip the input registers. We don't need to clip %r23 as we
692+
only use it for word operations */
692693
depdi 0, 31, 32, %r26
693694
depdi 0, 31, 32, %r25
694695
depdi 0, 31, 32, %r24
695-
depdi 0, 31, 32, %r23
696696
#endif
697697

698698
/* Check the validity of the size pointer */
699-
subi,>>= 4, %r23, %r0
699+
subi,>>= 3, %r23, %r0
700700
b,n lws_exit_nosys
701701

702702
/* Jump to the functions which will load the old and new values into

0 commit comments

Comments
 (0)