netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: dan.carpenter@oracle.com
Cc: netdev@vger.kernel.org
Subject: Re: question about klen in move_addr_to_user()
Date: Tue, 19 Mar 2013 09:55:47 -0400 (EDT)	[thread overview]
Message-ID: <20130319.095547.1333124517060824574.davem@davemloft.net> (raw)
In-Reply-To: <20130318101007.GO9189@mwanda>

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Mon, 18 Mar 2013 13:10:07 +0300

> The call tree is this:
> 
> __sys_recvmsg() gets the msg->msg_namelen from the user.
> 
> Normally the network protocols set msg->msg_namelen in their
> ->recvmsg() function but some don't like caif_seqpkt_recvmsg() and
> recv_msg() for tipc.

In fact, even TCP will just leave the msg->msg_namelen alone.

I think the best thing to do is to cap the klen to the size of
sockaddr_storage in verify_iovec() when mode is not VERIFY_READ.

But actually, it looks like sendmsg() has a similar problem.
We use m->msg_namelen as-is in verify_iovec() via __sys_sendmsg()
when mode is VERIFY_READ.

This makes me think that we should cap this at the precise moment
we import the user's msghdr.  Which means:

1) Create a helper function copy_msghdr_from_user() and use
   it everywhere we do the straight copy_from_user(msg_sys, ...)

2) In both copy_msghdr_from_user() and get_compat_msghdr(), cap
   the msg_namelen to sizeof(struct sockaddr_storage).

That should eliminate any and all problems in this area.

Thanks Dan.

  reply	other threads:[~2013-03-19 13:55 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 [this message]
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
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=20130319.095547.1333124517060824574.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=dan.carpenter@oracle.com \
    --cc=netdev@vger.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).