From patchwork Mon Feb 3 09:54:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ivan Homoliak X-Patchwork-Id: 316102 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1A66E2C008F for ; Mon, 3 Feb 2014 20:54:26 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751566AbaBCJyY (ORCPT ); Mon, 3 Feb 2014 04:54:24 -0500 Received: from mail-pd0-f177.google.com ([209.85.192.177]:48360 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751520AbaBCJyX (ORCPT ); Mon, 3 Feb 2014 04:54:23 -0500 Received: by mail-pd0-f177.google.com with SMTP id x10so6593873pdj.8 for ; Mon, 03 Feb 2014 01:54:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=hWgUNsi0T55wSMLeE1qIXud1U4bgmhbCagfjvuW6PWE=; b=Medwm7VWRRh7m7gGvfdJEPtkdqGvDugyKLL787ov2cveukCji8Qo65Ikr4ZC4E9y+P HGHDfXDE54oQb2HaFdrcyKqy9MrZIQ4zipMZf3Q0JbK26oqUKoVJ0Q/3hjTnH2APCH8i kzLqF5Z7VaY0eNqFhjxXSjcgcfa4/bSlJWuOG54uiqeoa560qX2e3sXVLBLoE+xOu347 YK0n3O3k7yz/obBG2jUVxMZRw3TteuZA0mZ+/w1YN73U2XlnKRO2IB4PoBm5opq64Oex lpj8uwDpLS5Y2oNd0bFUye1rqSpFi+9MAns3f1GXdQHItP2njAYcPTlsKnmSESSBqhth 4fTw== MIME-Version: 1.0 X-Received: by 10.69.0.39 with SMTP id av7mr36146133pbd.4.1391421263262; Mon, 03 Feb 2014 01:54:23 -0800 (PST) Received: by 10.70.81.36 with HTTP; Mon, 3 Feb 2014 01:54:23 -0800 (PST) In-Reply-To: References: Date: Mon, 3 Feb 2014 10:54:23 +0100 Message-ID: Subject: Fwd: [PATCH]: libnetfilter_log: Uninitialized values in libnetfilter_log.c From: Ivan Homoliak To: netfilter-devel@vger.kernel.org Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Uninitialized values in libnetfilter.log.c which were discovered by valgrind and ulogd. Signed-off-by: Ivan Homoliak --- Valgrinds output: ==13821== Syscall param socketcall.sendto(msg) points to uninitialised byte(s) ==13821== at 0x3E93AF6E83: __sendto_nocancel (in /usr/lib64/libc-2.17.so) ==13821== by 0x5433E81: nfnl_send (libnfnetlink.c:391) ==13821== by 0x5435C0E: nfnl_query (libnfnetlink.c:1569) ==13821== by 0x522E4E6: __build_send_cfg_msg (libnetfilter_log.c:143) ==13821== by 0x522E87E: nflog_bind_group (libnetfilter_log.c:413) ==13821== by 0x5029F3B: start (ulogd_inppkt_NFLOG.c:573) ==13821== by 0x403E5D: create_stack_start_instances (ulogd.c:918) ==13821== by 0x4041B4: create_stack (ulogd.c:1010) ==13821== by 0x4078D6: config_parse_file (conffile.c:225) ==13821== by 0x404411: parse_conffile (ulogd.c:1088) ==13821== by 0x405478: main (ulogd.c:1573) ==13821== Address 0x7feffff69 is on thread 1's stack ==13821== Uninitialised value was created by a stack allocation ==13821== at 0x522E45B: __build_send_cfg_msg (libnetfilter_log.c:129) ==13821== ==13821== Syscall param socketcall.sendto(msg) points to uninitialised byte(s) ==13821== at 0x3E93AF6E83: __sendto_nocancel (in /usr/lib64/libc-2.17.so) ==13821== by 0x5433E81: nfnl_send (libnfnetlink.c:391) ==13821== by 0x5435C0E: nfnl_query (libnfnetlink.c:1569) ==13821== by 0x522E9A0: nflog_set_mode (libnetfilter_log.c:481) ==13821== by 0x5029FA2: start (ulogd_inppkt_NFLOG.c:581) ==13821== by 0x403E5D: create_stack_start_instances (ulogd.c:918) ==13821== by 0x4041B4: create_stack (ulogd.c:1010) ==13821== by 0x4078D6: config_parse_file (conffile.c:225) ==13821== by 0x404411: parse_conffile (ulogd.c:1088) ==13821== by 0x405478: main (ulogd.c:1573) ==13821== Address 0x7feffff9d is on thread 1's stack ==13821== Uninitialised value was created by a stack allocation ==13821== at 0x50293D0: ??? (in /usr/lib/ulogd/ulogd_inppkt_NFLOG.so) Version: libnetfilter_log-1.0.1 File: libnetfilter_log.c GCC: 4.8.2 20131212 (Red Hat 4.8.2-7) OS: Fedora release 19 (Schrödinger's Cat) Kernel: 3.12.5-200.fc19.x86_64 --- a/src/libnetfilter_log.c 2010-11-04 00:19:45.000000000 +0100 +++ b/src/libnetfilter_log.c 2014-01-03 10:48:34.592783388 +0100 @@ -133,6 +133,8 @@ __build_send_cfg_msg(struct nflog_handle struct nlmsghdr nmh; } u; struct nfulnl_msg_config_cmd cmd; + + memset(&u, 0, sizeof(u)); nfnl_fill_hdr(h->nfnlssh, &u.nmh, 0, pf, groupnum, NFULNL_MSG_CONFIG, NLM_F_REQUEST|NLM_F_ACK); @@ -469,12 +471,14 @@ int nflog_set_mode(struct nflog_g_handle struct nlmsghdr nmh; } u; struct nfulnl_msg_config_mode params; - + memset(&u, 0, sizeof(u)); + nfnl_fill_hdr(gh->h->nfnlssh, &u.nmh, 0, AF_UNSPEC, gh->id, NFULNL_MSG_CONFIG, NLM_F_REQUEST|NLM_F_ACK); params.copy_range = htonl(range); /* copy_range is short */ params.copy_mode = mode; + params._pad = (u_int8_t) 0; nfnl_addattr_l(&u.nmh, sizeof(u), NFULA_CFG_MODE, ¶ms, sizeof(params)); @@ -500,6 +504,8 @@ int nflog_set_timeout(struct nflog_g_han struct nlmsghdr nmh; } u; + memset(&u, 0, sizeof(u)); + nfnl_fill_hdr(gh->h->nfnlssh, &u.nmh, 0, AF_UNSPEC, gh->id, NFULNL_MSG_CONFIG, NLM_F_REQUEST|NLM_F_ACK); @@ -525,6 +531,8 @@ int nflog_set_qthresh(struct nflog_g_han struct nlmsghdr nmh; } u; + memset(&u, 0, sizeof(u)); + nfnl_fill_hdr(gh->h->nfnlssh, &u.nmh, 0, AF_UNSPEC, gh->id, NFULNL_MSG_CONFIG, NLM_F_REQUEST|NLM_F_ACK); @@ -553,8 +561,10 @@ int nflog_set_nlbufsiz(struct nflog_g_ha char buf[NFNL_HEADER_LEN+NFA_LENGTH(sizeof(u_int32_t))]; struct nlmsghdr nmh; } u; - int status; + int status = 0; + memset(&u, 0, sizeof(u)); + nfnl_fill_hdr(gh->h->nfnlssh, &u.nmh, 0, AF_UNSPEC, gh->id, NFULNL_MSG_CONFIG, NLM_F_REQUEST|NLM_F_ACK); @@ -588,6 +598,8 @@ int nflog_set_flags(struct nflog_g_handl struct nlmsghdr nmh; } u; + memset(&u, 0, sizeof(u)); + nfnl_fill_hdr(gh->h->nfnlssh, &u.nmh, 0, AF_UNSPEC, gh->id, NFULNL_MSG_CONFIG, NLM_F_REQUEST|NLM_F_ACK);