netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mathias Krause <minipli@googlemail.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org,
	Allan Stephens <allan.stephens@windriver.com>,
	Aloisio Almeida Jr <aloisio.almeida@openbossa.org>,
	Andy King <acking@vmware.com>,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	Dmitry Torokhov <dtor@vmware.com>,
	George Zhang <georgezhang@vmware.com>,
	Gustavo Padovan <gustavo@padovan.org>,
	Johan Hedberg <johan.hedberg@gmail.com>,
	Jon Maloy <jon.maloy@ericsson.com>,
	Lauro Ramos Venancio <lauro.venancio@openbossa.org>,
	Marcel Holtmann <marcel@holtmann.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Samuel Ortiz <samuel@sortiz.org>,
	Sjur Braendeland <sjur.brandeland@stericsson.com>,
	Ursula Braun <ursula.braun@de.ibm.com>,
	Brad Spengler <spender@grsecurity.net>,
	Mathias Krause <minipli@googlemail.com>
Subject: [PATCH 12/16] NFC: llcp: fix info leaks via msg_name in llcp_sock_recvmsg()
Date: Sun,  7 Apr 2013 13:51:58 +0200	[thread overview]
Message-ID: <1365335522-29931-13-git-send-email-minipli@googlemail.com> (raw)
In-Reply-To: <1365335522-29931-1-git-send-email-minipli@googlemail.com>

The code in llcp_sock_recvmsg() does not initialize all the members of
struct sockaddr_nfc_llcp when filling the sockaddr info. Nor does it
initialize the padding bytes of the structure inserted by the compiler
for alignment.

Also, if the socket is in state LLCP_CLOSED or is shutting down during
receive the msg_namelen member is not updated to 0 while otherwise
returning with 0, i.e. "success". The msg_namelen update is also
missing for stream and seqpacket sockets which don't fill the sockaddr
info.

Both issues lead to the fact that the code will leak uninitialized
kernel stack bytes in net/socket.c.

Fix the first issue by initializing the memory used for sockaddr info
with memset(0). Fix the second one by setting msg_namelen to 0 early.
It will be updated later if we're going to fill the msg_name member.

Cc: Lauro Ramos Venancio <lauro.venancio@openbossa.org>
Cc: Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
 net/nfc/llcp/sock.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/nfc/llcp/sock.c b/net/nfc/llcp/sock.c
index 5c7cdf3..4741adc 100644
--- a/net/nfc/llcp/sock.c
+++ b/net/nfc/llcp/sock.c
@@ -646,6 +646,8 @@ static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
 
 	pr_debug("%p %zu\n", sk, len);
 
+	msg->msg_namelen = 0;
+
 	lock_sock(sk);
 
 	if (sk->sk_state == LLCP_CLOSED &&
@@ -691,6 +693,7 @@ static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
 
 		pr_debug("Datagram socket %d %d\n", ui_cb->dsap, ui_cb->ssap);
 
+		memset(sockaddr, 0, sizeof(*sockaddr));
 		sockaddr->sa_family = AF_NFC;
 		sockaddr->nfc_protocol = NFC_PROTO_NFC_DEP;
 		sockaddr->dsap = ui_cb->dsap;
-- 
1.7.10.4

  parent reply	other threads:[~2013-04-07 11:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-07 11:51 [PATCH 00/16] info leak fixes in recvmsg Mathias Krause
2013-04-07 11:51 ` [PATCH 01/16] atm: update msg_namelen in vcc_recvmsg() Mathias Krause
2013-04-07 11:51 ` [PATCH 02/16] ax25: fix info leak via msg_name in ax25_recvmsg() Mathias Krause
2013-04-07 11:51 ` [PATCH 03/16] Bluetooth: fix possible info leak in bt_sock_recvmsg() Mathias Krause
2013-04-07 11:51 ` [PATCH 04/16] Bluetooth: RFCOMM - Fix missing msg_namelen update in rfcomm_sock_recvmsg() Mathias Krause
2013-04-07 11:51 ` [PATCH 05/16] Bluetooth: SCO - Fix missing msg_namelen update in sco_sock_recvmsg() Mathias Krause
2013-04-07 11:51 ` [PATCH 06/16] caif: Fix missing msg_namelen update in caif_seqpkt_recvmsg() Mathias Krause
2013-04-07 11:51 ` [PATCH 07/16] irda: Fix missing msg_namelen update in irda_recvmsg_dgram() Mathias Krause
2013-04-07 11:51 ` [PATCH 08/16] iucv: Fix missing msg_namelen update in iucv_sock_recvmsg() Mathias Krause
2013-04-08 11:14   ` Ursula Braun
2013-04-07 11:51 ` [PATCH 09/16] l2tp: fix info leak in l2tp_ip6_recvmsg() Mathias Krause
2013-04-07 11:51 ` [PATCH 10/16] llc: Fix missing msg_namelen update in llc_ui_recvmsg() Mathias Krause
2013-04-07 11:51 ` [PATCH 11/16] netrom: fix info leak via msg_name in nr_recvmsg() Mathias Krause
2013-04-07 11:51 ` Mathias Krause [this message]
2013-04-07 11:51 ` [PATCH 13/16] rose: fix info leak via msg_name in rose_recvmsg() Mathias Krause
2013-04-07 11:52 ` [PATCH 14/16] tipc: fix info leaks via msg_name in recv_msg/recv_stream Mathias Krause
2013-04-07 11:52 ` [PATCH 15/16] VSOCK: vmci - fix possible info leak in vmci_transport_dgram_dequeue() Mathias Krause
2013-04-07 11:52 ` [PATCH 16/16] VSOCK: Fix missing msg_namelen update in vsock_stream_recvmsg() Mathias Krause
2013-04-07 20:31 ` [PATCH 00/16] info leak fixes in recvmsg 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=1365335522-29931-13-git-send-email-minipli@googlemail.com \
    --to=minipli@googlemail.com \
    --cc=acking@vmware.com \
    --cc=acme@ghostprotocols.net \
    --cc=allan.stephens@windriver.com \
    --cc=aloisio.almeida@openbossa.org \
    --cc=davem@davemloft.net \
    --cc=dtor@vmware.com \
    --cc=georgezhang@vmware.com \
    --cc=gustavo@padovan.org \
    --cc=johan.hedberg@gmail.com \
    --cc=jon.maloy@ericsson.com \
    --cc=lauro.venancio@openbossa.org \
    --cc=marcel@holtmann.org \
    --cc=netdev@vger.kernel.org \
    --cc=ralf@linux-mips.org \
    --cc=sameo@linux.intel.com \
    --cc=samuel@sortiz.org \
    --cc=sjur.brandeland@stericsson.com \
    --cc=spender@grsecurity.net \
    --cc=ursula.braun@de.ibm.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).