Redundant barrier_nospec() added by commit 74e19ef0ff80 ("uaccess: Add speculation barrier to copy_from_user()")

From: Christophe Leroy
Date: Thu Jun 19 2025 - 04:50:42 EST


Hello Dave,

In commit 74e19ef0ff80 ("uaccess: Add speculation barrier to copy_from_user()") you add barrier_nospec() to copy_from_user().

There is already a barrier_nospec() in allow_read_from_user() which is called by raw_copy_from_user(), see commit 8524e2e76441 ("powerpc/uaccess: Perform barrier_nospec() in KUAP allowance helpers"). Why do you need an additional one ?

And why only copy_from_user() and not also other places like copy_from_user_iter() for instance ?

Thanks
Christophe