Re: [PATCH v14 04/19] x86/uaccess: Add unsafe_copy_from_user() implementation
Steven Rostedt <[email protected]> Wed, 6 May 2026 11:05:57 -0400
| Newsgroups | dev.linux.lists.sashiko,org.kernel.vger.bpf |
|---|---|
| Message-ID | <20260506110557.46ee72c3@fedora> |
On Wed, 6 May 2026 16:13:25 +0200 Jens Remus <[email protected]> wrote: > > Regarding the variable naming in the updated unsafe_copy_to_user() and the > > new unsafe_copy_from_user() macros, is there a risk of variable shadowing? > > > > The macros declare local variables with very common names, specifically __dst, > > __src, and __len. If a caller passes an argument that happens to share one of > > these names, the local variable declaration will shadow the caller's argument. > > For instance, if a caller passes __len, the initialization size_t __len = > > (_len); will evaluate the right-hand side as the newly declared uninitialized > > local variable itself. Could this lead to the loop copying a random length of > > memory based on stack garbage instead of the intended length? The previous > > implementation seemed to avoid this by using uniquely prefixed names like > > __ucu_len. > > Please advise. There is an effort to get rid of common variable names in macros that start with underscores. But honestly, that can be dealt with later, as it's a problem with other macros in this header. Feel free to ignore this suggestion. -- Steve