aboutsummaryrefslogtreecommitdiffstats
path: root/arch/tile/lib/usercopy_32.S
diff options
context:
space:
mode:
authorChris Metcalf <cmetcalf@tilera.com>2013-08-09 16:21:43 -0400
committerChris Metcalf <cmetcalf@tilera.com>2013-08-30 11:56:42 -0400
commitc0f060106000bafafc56ad2af147e541458eabdd (patch)
treeb76b78391f9e86d558f44640000e0589b5076431 /arch/tile/lib/usercopy_32.S
parent084fe6a0f53f61fd5f9b33391af1077addec0ce0 (diff)
tile: fix strncpy_from_user bug
In strncpy_from_user_asm, when the destination buffer length was the same as the actual string length, we were returning the size of the destination buffer. But since it's a NUL terminated string, we should return the length of the string instead. Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Diffstat (limited to 'arch/tile/lib/usercopy_32.S')
-rw-r--r--arch/tile/lib/usercopy_32.S11
1 files changed, 6 insertions, 5 deletions
diff --git a/arch/tile/lib/usercopy_32.S b/arch/tile/lib/usercopy_32.S
index bb4c127be6e9..1bc162224638 100644
--- a/arch/tile/lib/usercopy_32.S
+++ b/arch/tile/lib/usercopy_32.S
@@ -48,12 +48,13 @@ strnlen_user_fault:
48 */ 48 */
49STD_ENTRY(strncpy_from_user_asm) 49STD_ENTRY(strncpy_from_user_asm)
50 { bz r2, 2f; move r3, r0 } 50 { bz r2, 2f; move r3, r0 }
511: { lb_u r4, r1; addi r1, r1, 1; addi r2, r2, -1 } 511: { lb_u r4, r1; addi r1, r1, 1; addi r2, r2, -1 }
52 { sb r0, r4; addi r0, r0, 1 } 52 { sb r0, r4; addi r0, r0, 1 }
53 bz r2, 2f 53 bz r4, 2f
54 bnzt r4, 1b 54 bnzt r2, 1b
55 addi r0, r0, -1 /* don't count the trailing NUL */ 55 { sub r0, r0, r3; jrp lr }
562: { sub r0, r0, r3; jrp lr } 562: addi r0, r0, -1 /* don't count the trailing NUL */
57 { sub r0, r0, r3; jrp lr }
57 STD_ENDPROC(strncpy_from_user_asm) 58 STD_ENDPROC(strncpy_from_user_asm)
58 .pushsection .fixup,"ax" 59 .pushsection .fixup,"ax"
59strncpy_from_user_fault: 60strncpy_from_user_fault: