netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, stable@vger.kernel.org
Subject: [PATCH -stable-3.9 02/15] netfilter: ipt_ULOG: fix non-null terminated string in the nf_log path
Date: Tue,  2 Jul 2013 16:50:52 +0200	[thread overview]
Message-ID: <1372776665-6795-2-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1372776665-6795-1-git-send-email-pablo@netfilter.org>

From: Chen Gang <gang.chen@asianux.com>

If nf_log uses ipt_ULOG as logging output, we can deliver non-null
terminated strings to user-space since the maximum length of the
prefix that is passed by nf_log is NF_LOG_PREFIXLEN but pm->prefix
is 32 bytes long (ULOG_PREFIX_LEN).

This is actually happening already from nf_conntrack_tcp if ipt_ULOG
is used, since it is passing strings longer than 32 bytes.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
Cherry-pick: 4f36ea6eed2081340c7a7aa98c73187ecfccebff

 net/ipv4/netfilter/ipt_ULOG.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
index 7d168dc..3202b7d 100644
--- a/net/ipv4/netfilter/ipt_ULOG.c
+++ b/net/ipv4/netfilter/ipt_ULOG.c
@@ -215,8 +215,10 @@ static void ipt_ulog_packet(unsigned int hooknum,
 	put_unaligned(tv.tv_usec, &pm->timestamp_usec);
 	put_unaligned(skb->mark, &pm->mark);
 	pm->hook = hooknum;
-	if (prefix != NULL)
-		strncpy(pm->prefix, prefix, sizeof(pm->prefix));
+	if (prefix != NULL) {
+		strncpy(pm->prefix, prefix, sizeof(pm->prefix) - 1);
+		pm->prefix[sizeof(pm->prefix) - 1] = '\0';
+	}
 	else if (loginfo->prefix[0] != '\0')
 		strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
 	else
-- 
1.7.10.4

  reply	other threads:[~2013-07-02 14:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-02 14:50 [PATCH -stable-3.9 01/15] netfilter: xt_TCPOPTSTRIP: fix possible mangling beyond packet boundary Pablo Neira Ayuso
2013-07-02 14:50 ` Pablo Neira Ayuso [this message]
2013-07-02 14:50 ` [PATCH -stable-3.9 03/15] netfilter: add nf_ipv6_ops hook to fix xt_addrtype with IPv6 Pablo Neira Ayuso
2013-07-02 14:50 ` [PATCH -stable-3.9 04/15] ipvs: Fix reuse connection if real server is dead Pablo Neira Ayuso
2013-07-02 14:50 ` [PATCH -stable-3.9 05/15] netfilter: xt_LOG: fix mark logging for IPv6 packets Pablo Neira Ayuso
2013-07-02 14:50 ` [PATCH -stable-3.9 06/15] ipvs: info leak in __ip_vs_get_dest_entries() Pablo Neira Ayuso
2013-07-02 14:50 ` [PATCH -stable-3.9 07/15] netfilter: nfnetlink_cttimeout: fix incomplete dumping of objects Pablo Neira Ayuso
2013-07-02 14:50 ` [PATCH -stable-3.9 08/15] netfilter: nfnetlink_acct: " Pablo Neira Ayuso
2013-07-02 14:50 ` [PATCH -stable-3.9 09/15] netfilter: xt_TCPMSS: Fix violation of RFC879 in absence of MSS option Pablo Neira Ayuso
2013-07-02 14:51 ` [PATCH -stable-3.9 10/15] netfilter: xt_TCPOPTSTRIP: don't use tcp_hdr() Pablo Neira Ayuso
2013-07-02 14:51 ` [PATCH -stable-3.9 11/15] netfilter: xt_TCPMSS: Fix missing fragmentation handling Pablo Neira Ayuso
2013-07-02 14:51 ` [PATCH -stable-3.9 12/15] netfilter: xt_TCPMSS: Fix IPv6 default MSS too Pablo Neira Ayuso
2013-07-02 14:51 ` [PATCH -stable-3.9 13/15] ipvs: SCTP ports should be writable in ICMP packets Pablo Neira Ayuso
2013-07-02 14:51 ` [PATCH -stable-3.9 14/15] netfilter: nf_nat_sip: fix mangling Pablo Neira Ayuso
2013-07-02 14:51 ` [PATCH -stable-3.9 15/15] netfilter: ctnetlink: send event when conntrack label was modified Pablo Neira Ayuso
2013-07-04 14:59 ` [PATCH -stable-3.9 01/15] netfilter: xt_TCPOPTSTRIP: fix possible mangling beyond packet boundary Luis Henriques
2013-07-05  5:01   ` Pablo Neira Ayuso
2013-07-05  8:36     ` Luis Henriques

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=1372776665-6795-2-git-send-email-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=stable@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).