From: Mat Martineau <mathew.j.martineau@linux.intel.com>
To: Florian Westphal <fw@strlen.de>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next 3/5] mptcp: add MPTCP_TCPINFO getsockopt support
Date: Thu, 12 Aug 2021 10:03:22 -0700 (PDT) [thread overview]
Message-ID: <265d1dc-7ea0-d55c-957f-8aa0eb53f094@linux.intel.com> (raw)
In-Reply-To: <20210811131523.6339-4-fw@strlen.de>
On Wed, 11 Aug 2021, Florian Westphal wrote:
> diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
> index eba294a071c8..ac8e6823db4f 100644
> --- a/net/mptcp/sockopt.c
> +++ b/net/mptcp/sockopt.c
> @@ -723,6 +723,96 @@ static int mptcp_getsockopt_info(struct mptcp_sock *msk, char __user *optval, in
>
> if (copy_to_user(optval, &m_info, len))
> return -EFAULT;
> + return 0;
> +}
> +
> +static int mptcp_get_subflow_data(struct mptcp_subflow_data *sfd,
> + char __user *optval, int __user *_u_optlen)
> +{
> +#define MIN_INFO_OPTLEN_SIZE 16
This caught my eye on my first quick review pass, I'm not accustomed to
seeing inline defines like this in the kernel unless it's part of some
macro magic. The style guide / checkpatch don't say anything, so I'll just
suggest it would fit better outside the function scope (but no big deal).
For the rest of the patch set, Paolo already covered the expanded test
cases, so I'll continue with a more in-depth review when you post v2.
This iteration of the API is looking like the right direction to me.
Thanks,
Mat
> + int len, copylen;
> +
> + if (get_user(len, _u_optlen))
> + return -EFAULT;
> +
> + if (len <= MIN_INFO_OPTLEN_SIZE)
> + return -EINVAL;
> +
> + memset(sfd, 0, sizeof(*sfd));
> +
> + copylen = min_t(unsigned int, len, sizeof(*sfd));
> + if (copy_from_user(sfd, optval, copylen))
> + return -EFAULT;
> +
> + /* size_subflow_data is u32, but len is signed */
> + if (sfd->size_subflow_data > INT_MAX ||
> + sfd->size_user > INT_MAX)
> + return -EINVAL;
> +
> + if (sfd->size_subflow_data < MIN_INFO_OPTLEN_SIZE ||
> + sfd->size_subflow_data > len)
> + return -EINVAL;
> +
> + if (sfd->num_subflows || sfd->size_kernel)
> + return -EINVAL;
> +
> + return len - sfd->size_subflow_data;
> +}
--
Mat Martineau
Intel
next prev parent reply other threads:[~2021-08-12 17:03 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-11 13:15 [PATCH mptcp-next 0/5] mptcp: add SOL_MPTCP getsockopt support Florian Westphal
2021-08-11 13:15 ` [PATCH mptcp-next 1/5] mptcp: add new mptcp_fill_diag helper Florian Westphal
2021-08-11 13:15 ` [PATCH mptcp-next 2/5] mptcp: add MPTCP_INFO getsockopt Florian Westphal
2021-08-12 16:46 ` Mat Martineau
2021-08-11 13:15 ` [PATCH mptcp-next 3/5] mptcp: add MPTCP_TCPINFO getsockopt support Florian Westphal
2021-08-12 17:03 ` Mat Martineau [this message]
2021-08-12 18:41 ` Florian Westphal
2021-08-11 13:15 ` [PATCH mptcp-next 4/5] mptcp: add MPTCP_SUBFLOW_ADDRS " Florian Westphal
2021-08-11 21:18 ` kernel test robot
2021-08-11 21:18 ` kernel test robot
2021-08-12 3:02 ` kernel test robot
2021-08-12 3:02 ` kernel test robot
2021-08-11 13:15 ` [PATCH mptcp-next 5/5] selftests: mptcp: add mptcp getsockopt test cases Florian Westphal
2021-08-12 11:14 ` Paolo Abeni
2021-08-12 11:28 ` Florian Westphal
2021-08-12 10:58 ` [PATCH mptcp-next 0/5] mptcp: add SOL_MPTCP getsockopt support Paolo Abeni
2021-08-12 11:07 ` Florian Westphal
-- strict thread matches above, loose matches on Subject: below --
2021-08-11 18:26 [PATCH mptcp-next 3/5] mptcp: add MPTCP_TCPINFO " kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=265d1dc-7ea0-d55c-957f-8aa0eb53f094@linux.intel.com \
--to=mathew.j.martineau@linux.intel.com \
--cc=fw@strlen.de \
--cc=mptcp@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.