On Tue, 9 Feb 2021 08:15:11 +0200 Leon Romanovsky wrote: > At least in my tree, we have the length check: > 4155 if (len > sizeof(zc)) { > 4156 len = sizeof(zc); > 4157 if (put_user(len, optlen)) > 4158 return -EFAULT; > 4159 } > > > Ad David wrote below, the "if (zc.reserved)" is enough. > > We have following options: > 1. Old kernel that have sizeof(sz) upto .reserved and old userspace > -> len <= sizeof(sz) - works correctly. > 2. Old kernel that have sizeof(sz) upto .reserved and new userspace that > sends larger struct -> "f (len > sizeof(zc))" will return -EFAULT
Based on the code you quoted? I don't see how. Maybe I need a vacation. put_user() just copies len back to user space after truncation. > 3. New kernel that have sizeof(sz) beyond reserved and old userspace > -> any new added field to struct sz should be checked and anyway it is the > same as item 1. > 4. New kernel and new userspace > -> standard flow.