kernel/sys.c: fix prctl_set_auxv to use sizeof instead of user-supplied len
PATCH 1/1 kernel/sys.c: fix prctl_set_auxv to use sizeof instead of user-supplied len
prctl_set_auxv() passed the user-supplied 'len' to memcpy() when copying into mm->saved_auxv, instead of sizeof(user_auxv). Since user_auxv is already sized to the full auxv buffer, using 'len' risks a partial write if the caller supplies a smaller value. Use sizeof(user_auxv) to always copy the full buffer after validation.
--- kernel/sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sys.c +1 -1
@@ -2189,7 +2189,7 @@ static int prctl_set_auxv(struct mm_struct *mm, unsigned long addr,BUILD_BUG_ON (sizeof (user_auxv) !=sizeof (mm->saved_auxv));task_lock (current); -memcpy (mm->saved_auxv, user_auxv, len); +memcpy (mm->saved_auxv, user_auxv,sizeof (user_auxv));task_unlock (current);return 0 ;
base-commit: e43ffb69e0438cddd72aaa30898b4dc446f664f8
Signature · 1 line
2.54.0
Quoted 5 lines · On Mon, 1 Jun 2026 22:40:02 -0400 Aiden Bowling <[email protected]>…
prctl_set_auxv()passed the user-supplied 'len' tomemcpy()when copying intomm->saved_auxv, instead ofsizeof(user_auxv). Sinceuser_auxvis already sized to the full auxv buffer, using 'len' risks a partial write if the caller supplies a smaller value. Usesizeof(user_auxv)to always copy the full buffer after validation.
Is it possibly that the caller only wants to write the first few values?
-- David
Quoted 21 lines
Signed-off-by Aiden Bowling <[email protected]>--- kernel/sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/sys.c +1
-1@@ -2189,7 +2189,7 @@ static int prctl_set_auxv(struct mm_struct *mm, unsigned long addr,BUILD_BUG_ON (sizeof (user_auxv) !=sizeof (mm->saved_auxv));task_lock (current); -memcpy (mm->saved_auxv, user_auxv, len); +memcpy (mm->saved_auxv, user_auxv,sizeof (user_auxv));task_unlock (current);return 0 ;base-commit:
e43ffb69e0438cddd72aaa30898b4dc446f664f8
Quoted 5 lines · Aiden Bowling
prctl_set_auxv()passed the user-supplied 'len' tomemcpy()when copying intomm->saved_auxv, instead ofsizeof(user_auxv). Sinceuser_auxvis already sized to the full auxv buffer, using 'len' risks a partial write if the caller supplies a smaller value. Usesizeof(user_auxv)to always copy the full buffer after validation.
Hm, but would this be an issue? A user can specify only a partial write and get what they expect, I don't think there's any security issue here.
I also guess a user could specify a length that's not a multiple of sizeof(unsigned long) but again they'd get the results they might expect from doing something silly like that :)
And users might rely on this only doing a partial write for whatever weird reason so I don't think we can change this really?
Quoted 20 lines
Signed-off-by Aiden Bowling <[email protected]>--- kernel/sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/sys.c +1
-1@@ -2189,7 +2189,7 @@ static int prctl_set_auxv(struct mm_struct *mm, unsigned long addr,BUILD_BUG_ON (sizeof (user_auxv) !=sizeof (mm->saved_auxv));task_lock (current); -memcpy (mm->saved_auxv, user_auxv, len); +memcpy (mm->saved_auxv, user_auxv,sizeof (user_auxv));task_unlock (current);return 0 ;
Quoted 4 lines
base-commit:
e43ffb69e0438cddd72aaa30898b4dc446f664f8--
2.54.0
Cheers, Lorenzo
A message that is not in the archive (sent off-list or not yet received): CAGOa741UNr5DzK4vr8RBLvhZcCs9zdva6tqmMptQw5P8ooNEOA@mail.gmail.com
Quoted 5 lines · Aiden Bowling
The issue is that using the user-supplied 'len' risks a partial write into mm-
Quoted 1 line
saved_auxvif they pass something smaller than the actual buffer size, even ifthe buffer is validated. We should always copy the full buffer size after validation to maintain consistency and prevent accidental partial data exposure/ corruption.
Which partial data exposure?
Signature · 3 lines
Cheers, David
Quoted 9 lines · On Tue, 2 Jun 2026 19:25:56 +0200 "David Hildenbrand (Arm)" <[email protected]>…
Quoted 5 lines · Aiden Bowling
The issue is that using the user-supplied 'len' risks a partial write into mm-
Quoted 1 line
saved_auxvif they pass something smaller than the actual buffer size, even ifthe buffer is validated. We should always copy the full buffer size after validation to maintain consistency and prevent accidental partial data exposure/ corruption.
Which partial data exposure?
The one you don't get with the patch because of the previously unnecessary initialisation of the array :-)