From: Dan Carpenter <dan.carpenter@oracle.com>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: "David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, security@kernel.org,
"Jüri Aedla" <juri.aedla@gmail.com>
Subject: Re: [patch] net: heap overflow in __audit_sockaddr()
Date: Thu, 3 Oct 2013 00:26:04 +0300 [thread overview]
Message-ID: <20131002212603.GQ6247@mwanda> (raw)
In-Reply-To: <1380748306.1795.67.camel@bwh-desktop.uk.level5networks.com>
On Wed, Oct 02, 2013 at 10:11:46PM +0100, Ben Hutchings wrote:
> On Wed, 2013-10-02 at 21:58 +0300, Dan Carpenter wrote:
> > We need to cap ->msg_namelen or it leads to a buffer overflow when we
> > to the memcpy() in __audit_sockaddr(). It requires CAP_AUDIT_CONTROL to
> > exploit this bug.
> >
> > The call tree is:
> > ___sys_recvmsg()
> > move_addr_to_user()
> > audit_sockaddr()
> > __audit_sockaddr()
> >
> > Reported-by: Jüri Aedla <juri.aedla@gmail.com>
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/net/socket.c b/net/socket.c
> > index ebed4b6..c226ace 100644
> > --- a/net/socket.c
> > +++ b/net/socket.c
> > @@ -1964,6 +1964,16 @@ struct used_address {
> > unsigned int name_len;
> > };
> >
> > +static int copy_msghdr_from_user(struct msghdr *kmsg,
> > + struct msghdr __user *umsg)
> > +{
> > + if (copy_from_user(kmsg, umsg, sizeof(struct msghdr)))
> > + return -EFAULT;
> > + if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
> > + return -EINVAL;
> > + return 0;
> > +}
> > +
> > static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
> > struct msghdr *msg_sys, unsigned int flags,
> > struct used_address *used_address)
> > @@ -1982,8 +1992,11 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
> > if (MSG_CMSG_COMPAT & flags) {
> > if (get_compat_msghdr(msg_sys, msg_compat))
> > return -EFAULT;
> > - } else if (copy_from_user(msg_sys, msg, sizeof(struct msghdr)))
> > - return -EFAULT;
> > + } else {
> > + err = copy_msghdr_from_user(msg_sys, msg);
> > + if (err)
> > + return err;
> > + }
> [...]
>
> This doesn't cover compat tasks, since get_compat_msghdr() has no such
> check.
>
Oops. Gar... Thanks for catching that. I forgot to add that chunk to
the commit.
regards,
dan carpenter
next prev parent reply other threads:[~2013-10-02 21:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-18 10:10 question about klen in move_addr_to_user() Dan Carpenter
2013-03-19 13:55 ` David Miller
2013-10-02 18:58 ` [patch] net: heap overflow in __audit_sockaddr() Dan Carpenter
2013-10-02 21:11 ` Ben Hutchings
2013-10-02 21:26 ` Dan Carpenter [this message]
2013-10-02 21:27 ` [patch v2] " Dan Carpenter
2013-10-03 20:06 ` David Miller
2013-11-27 11:32 ` Eric Wong
2013-11-27 11:51 ` Hannes Frederic Sowa
2013-11-27 12:40 ` [patch] net: clamp ->msg_namelen instead of returning an error Dan Carpenter
2013-11-27 19:42 ` Eric Wong
2013-11-27 21:27 ` Eric Dumazet
2013-11-29 21:13 ` David Miller
2013-11-27 20:24 ` [patch v2] net: heap overflow in __audit_sockaddr() Linus Torvalds
2013-11-27 21:18 ` Hannes Frederic Sowa
2013-11-27 13:56 ` David Laight
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=20131002212603.GQ6247@mwanda \
--to=dan.carpenter@oracle.com \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=juri.aedla@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=security@kernel.org \
/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).