From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Chen Gang <gang.chen@asianux.com>
Cc: kaber@trash.net, kuznet@ms2.inr.ac.ru, jmorris@namei.org,
yoshfuji@linux-ipv6.org, David Miller <davem@davemloft.net>,
netfilter-devel@vger.kernel.org, netfilter@vger.kernel.org,
coreteam@netfilter.org, netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH] ipv4: netfilter: always let NUL terminated string ended by '\0'
Date: Thu, 23 May 2013 13:49:50 +0200 [thread overview]
Message-ID: <20130523114950.GA4972@localhost> (raw)
In-Reply-To: <519DFFFB.40104@asianux.com>
On Thu, May 23, 2013 at 07:39:39PM +0800, Chen Gang wrote:
> On 05/23/2013 07:08 PM, Pablo Neira Ayuso wrote:
> > On Fri, May 17, 2013 at 04:39:15PM +0800, Chen Gang wrote:
> >> >
> >> > For NUL terminated string, better always be sure of ended by '\0'.
> >> >
> >> > 'pm' is 'struct ulog_packet_msg_t' which may be copied to user mode
> >> > (defined in "include/uapi/..."), so can not use strlcpy() instead of.
> > loginfo->prefix is always nul-terminated, as this is validated in
> > checkentry. I don't think the kernel will take a non nul-terminated
> > device name either.
>
> Really it is.
>
> And 'prefix' max length is 128 (NF_LOG_PREFIXLEN), and 'pm->prefix' max
> length is 32 (ULOG_PREFIX_LEN), so we still need this patch, but need
> improved.
Both are ULOG_PREFIX_LEN long.
From include/uapi/linux/netfilter_ipv4/ipt_ULOG.h:
/* private data structure for each rule with a ULOG target */
struct ipt_ulog_info {
unsigned int nl_group;
size_t copy_range;
size_t qthreshold;
char prefix[ULOG_PREFIX_LEN];
};
/* Format of the ULOG packets passed through netlink */
typedef struct ulog_packet_msg {
unsigned long mark;
long timestamp_sec;
long timestamp_usec;
unsigned int hook;
char indev_name[IFNAMSIZ];
char outdev_name[IFNAMSIZ];
size_t data_len;
char prefix[ULOG_PREFIX_LEN];
unsigned char mac_len;
unsigned char mac[ULOG_MAC_LEN;
unsigned char payload[0];
} ulog_packet_msg_t;
WARNING: multiple messages have this Message-ID (diff)
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Chen Gang <gang.chen@asianux.com>
Cc: kaber@trash.net, kuznet@ms2.inr.ac.ru, jmorris@namei.org,
yoshfuji@linux-ipv6.org, David Miller <davem@davemloft.net>,
netfilter-devel@vger.kernel.org, netfilter@vger.kernel.org,
coreteam@netfilter.org, netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH] ipv4: netfilter: always let NUL terminated string ended by '\0'
Date: Thu, 23 May 2013 13:49:50 +0200 [thread overview]
Message-ID: <20130523114950.GA4972@localhost> (raw)
In-Reply-To: <519DFFFB.40104@asianux.com>
On Thu, May 23, 2013 at 07:39:39PM +0800, Chen Gang wrote:
> On 05/23/2013 07:08 PM, Pablo Neira Ayuso wrote:
> > On Fri, May 17, 2013 at 04:39:15PM +0800, Chen Gang wrote:
> >> >
> >> > For NUL terminated string, better always be sure of ended by '\0'.
> >> >
> >> > 'pm' is 'struct ulog_packet_msg_t' which may be copied to user mode
> >> > (defined in "include/uapi/..."), so can not use strlcpy() instead of.
> > loginfo->prefix is always nul-terminated, as this is validated in
> > checkentry. I don't think the kernel will take a non nul-terminated
> > device name either.
>
> Really it is.
>
> And 'prefix' max length is 128 (NF_LOG_PREFIXLEN), and 'pm->prefix' max
> length is 32 (ULOG_PREFIX_LEN), so we still need this patch, but need
> improved.
Both are ULOG_PREFIX_LEN long.
>From include/uapi/linux/netfilter_ipv4/ipt_ULOG.h:
/* private data structure for each rule with a ULOG target */
struct ipt_ulog_info {
unsigned int nl_group;
size_t copy_range;
size_t qthreshold;
char prefix[ULOG_PREFIX_LEN];
};
/* Format of the ULOG packets passed through netlink */
typedef struct ulog_packet_msg {
unsigned long mark;
long timestamp_sec;
long timestamp_usec;
unsigned int hook;
char indev_name[IFNAMSIZ];
char outdev_name[IFNAMSIZ];
size_t data_len;
char prefix[ULOG_PREFIX_LEN];
unsigned char mac_len;
unsigned char mac[ULOG_MAC_LEN;
unsigned char payload[0];
} ulog_packet_msg_t;
next prev parent reply other threads:[~2013-05-23 11:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-17 8:39 [PATCH] ipv4: netfilter: always let NUL terminated string ended by '\0' Chen Gang
2013-05-23 11:08 ` Pablo Neira Ayuso
2013-05-23 11:39 ` Chen Gang
2013-05-23 11:49 ` Pablo Neira Ayuso [this message]
2013-05-23 11:49 ` Pablo Neira Ayuso
2013-05-23 11:59 ` Chen Gang
2013-05-23 11:50 ` [PATCH v2] " Chen Gang
2013-05-23 12:26 ` Pablo Neira Ayuso
2013-05-24 1:11 ` Chen Gang
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=20130523114950.GA4972@localhost \
--to=pablo@netfilter.org \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=gang.chen@asianux.com \
--cc=jmorris@namei.org \
--cc=kaber@trash.net \
--cc=kuznet@ms2.inr.ac.ru \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=netfilter@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.