From: Ani Sinha <ani@arista.com>
To: Ani Sinha <ani@arista.com>, fruggeri <fruggeri@arista.com>,
David Miller <davem@davemloft.net>,
netdev@vger.kernel.org, fenner <fenner@arista.com>,
travisb <travisb@arista.com>,
Hannes Frederic Sowa <hannes@stressinduktion.org>,
"matthew.leach" <matthew.leach@arm.com>,
Eric Dumazet <eric.dumazet@gmail.com>
Subject: Re: [PATCH 1/1] net:socket: set msg_namelen to 0 if msg_name is passed as NULL in msghdr struct from userland.
Date: Tue, 9 Sep 2014 15:14:06 -0700 [thread overview]
Message-ID: <CAOxq_8OSR5hRM6ijtqwuEnYMc9cPUmdH8sWtFbr7MKRoDwc6GQ@mail.gmail.com> (raw)
In-Reply-To: <1410212999-11013-1-git-send-email-ani@arista.com>
Any feedback on this patch? Any concerns?
On Mon, Sep 8, 2014 at 2:49 PM, Ani Sinha <ani@arista.com> wrote:
> Linux manpage for recvmsg and sendmsg calls does not explicitly mention setting msg_namelen to 0 when
> msg_name passed set as NULL. When developers don't set msg_namelen member in msghdr, it might contain garbage
> value which will fail the validation check and sendmsg and recvmsg calls from kernel will return EINVAL. This will
> break old binaries and any code for which there is no access to source code.
> To fix this, we set msg_namelen to 0 when msg_name is passed as NULL from userland.
>
> Signed-off-by: Ani Sinha <ani@arista.com>
> ---
> net/socket.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/net/socket.c b/net/socket.c
> index 95ee7d8..457be6a 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -1997,6 +1997,9 @@ static int copy_msghdr_from_user(struct msghdr *kmsg,
> if (copy_from_user(kmsg, umsg, sizeof(struct msghdr)))
> return -EFAULT;
>
> + if (kmsg->msg_name == NULL)
> + kmsg->msg_namelen = 0;
> +
> if (kmsg->msg_namelen < 0)
> return -EINVAL;
>
> --
> 1.7.4.4
>
next prev parent reply other threads:[~2014-09-09 22:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-08 21:49 [PATCH 1/1] net:socket: set msg_namelen to 0 if msg_name is passed as NULL in msghdr struct from userland Ani Sinha
2014-09-09 22:14 ` Ani Sinha [this message]
2014-09-10 0:36 ` David Miller
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=CAOxq_8OSR5hRM6ijtqwuEnYMc9cPUmdH8sWtFbr7MKRoDwc6GQ@mail.gmail.com \
--to=ani@arista.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=fenner@arista.com \
--cc=fruggeri@arista.com \
--cc=hannes@stressinduktion.org \
--cc=matthew.leach@arm.com \
--cc=netdev@vger.kernel.org \
--cc=travisb@arista.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).