diff options
| author | Breno Leitao <leitao@debian.org> | 2026-07-29 02:29:47 -0700 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-08-03 16:55:23 -0700 |
| commit | 77e5eb0e192aec6710c03ca8144582fd2af36ca4 (patch) | |
| tree | 77c7534e19565fab64e9f744ef77b272c60e6e8d /net/phonet | |
| parent | 6cd4e6c0449e67661937e046851316fa726a873d (diff) | |
phonet: pep: do not write beyond optlen in getsockopt
pep_getsockopt() clamps the reported length to the caller's buffer with
min_t(), but then stores the value with put_user(val, (int __user *)
optval), which always writes sizeof(int) bytes. A getsockopt() call with
an optlen smaller than sizeof(int) thus reports the clamped length yet
writes a full int, one to three bytes past the user buffer.
Write the value with copy_to_user() bounded by len, so at most optlen
bytes are copied, matching the length reported back to userspace.
Fixes: 02a47617cdce ("Phonet: implement GPRS virtual interface over PEP socket")
Acked-by: Rémi Denis-Courmont <remi@remlab.net>
Reviewed-by: Joe Damato <joe@dama.to>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20260729-getsockopt_phase4-v4-4-c44576757c17@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/phonet')
| -rw-r--r-- | net/phonet/pep.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/phonet/pep.c b/net/phonet/pep.c index 31b29e3ca7bc..e188c563ee5b 100644 --- a/net/phonet/pep.c +++ b/net/phonet/pep.c @@ -1117,7 +1117,7 @@ static int pep_getsockopt(struct sock *sk, int level, int optname, len = min_t(unsigned int, sizeof(int), len); if (put_user(len, optlen)) return -EFAULT; - if (put_user(val, (int __user *) optval)) + if (copy_to_user(optval, &val, len)) return -EFAULT; return 0; } |
