Fix getsockopt() for IP_OPTIONS/IP_RETOPTS.

r336616 copies inp->inp_options using the m_dup() function.
However, this function expects an mbuf packet header at the beginning,
which is not true in this case.
Therefore, use m_copym() instead of m_dup().

This issue was found by syzkaller.
Reviewed by:		mmacy@
MFC after:		1 week
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D18753
This commit is contained in:
Michael Tuexen 2019-01-09 06:36:57 +00:00
parent d60f35d973
commit 10731c54b6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=342879

View File

@ -1263,7 +1263,8 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt)
if (inp->inp_options) {
struct mbuf *options;
options = m_dup(inp->inp_options, M_NOWAIT);
options = m_copym(inp->inp_options, 0,
M_COPYALL, M_NOWAIT);
INP_RUNLOCK(inp);
if (options != NULL) {
error = sooptcopyout(sopt,