lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 23 May 2013 19:59:19 +0800
From:	Chen Gang <gang.chen@...anux.com>
To:	Pablo Neira Ayuso <pablo@...filter.org>
CC:	kaber@...sh.net, kuznet@....inr.ac.ru, jmorris@...ei.org,
	yoshfuji@...ux-ipv6.org, David Miller <davem@...emloft.net>,
	netfilter-devel@...r.kernel.org, netfilter@...r.kernel.org,
	coreteam@...filter.org, netdev <netdev@...r.kernel.org>
Subject: Re: [PATCH] ipv4: netfilter: always let NUL terminated string ended
 by '\0'

On 05/23/2013 07:49 PM, Pablo Neira Ayuso wrote:
> 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;
> 
> 

Yes, for 'loginfo->prefix', really it is.

But for 'prefix', it is 128. the call work flow is:

  nf_log_packet() ->  "char prefix[NF_LOG_PREFIXLEN];"
    logger->logfn() -> "prefix as last parameter"
      ipt_logfn() ->   "prefix as last parameter"
        ipt_ulog_packet() "prefix as last parameter"

  netfilter/nf_log.c:16:#define NF_LOG_PREFIXLEN		128


Thanks.
-- 
Chen Gang

Asianux Corporation
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ