From patchwork Wed Jan 2 13:13:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 906E791E for ; Wed, 2 Jan 2019 13:15:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FACA28848 for ; Wed, 2 Jan 2019 13:15:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7396928857; Wed, 2 Jan 2019 13:15:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2775028848 for ; Wed, 2 Jan 2019 13:15:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729924AbfABNPK (ORCPT ); Wed, 2 Jan 2019 08:15:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53932 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728111AbfABNPJ (ORCPT ); Wed, 2 Jan 2019 08:15:09 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C206B46233; Wed, 2 Jan 2019 13:15:09 +0000 (UTC) Received: from localhost (ovpn-12-97.pek2.redhat.com [10.72.12.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA9495D75E; Wed, 2 Jan 2019 13:15:08 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 23/23] sim_mad.c: Fix accessing of uninitialised memory in send_trap Date: Wed, 2 Jan 2019 21:13:18 +0800 Message-Id: <20190102131318.5765-23-honli@redhat.com> In-Reply-To: <20190102131318.5765-1-honli@redhat.com> References: <20190102131318.5765-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 02 Jan 2019 13:15:09 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ==11780== 4 errors in context 1 of 1: ==11780== Syscall param write(buf) points to uninitialised byte(s) ==11780== at 0x5349F34: write (in /usr/lib64/libc-2.27.so) ==11780== by 0x40CA7E: send_trap (sim_mad.c:2014) ==11780== by 0x407D57: do_portinfo (sim_mad.c:672) ==11780== by 0x40C2CD: process_packet (sim_mad.c:1887) ==11780== by 0x41254B: sim_read_pkt (ibsim.c:484) ==11780== by 0x412D49: sim_run (ibsim.c:601) ==11780== by 0x4135B3: main (ibsim.c:783) ==11780== Address 0x1ffeffed44 is on thread 1's stack ==11780== in frame #1, created by send_trap (sim_mad.c:1971) ==11780== Uninitialised value was created by a stack allocation ==11780== at 0x40C832: send_trap (sim_mad.c:1971) Signed-off-by: Honggang Li --- ibsim/sim_mad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c index 5ef1d0a6dbeb..dfd1a31e178e 100644 --- a/ibsim/sim_mad.c +++ b/ibsim/sim_mad.c @@ -1982,7 +1982,7 @@ int send_trap(Port * port, unsigned trapnum) } encode_trapfn = encodetrap[trapnum]; - memset(req.mad, 0, sizeof(req.mad)); + memset(&req, 0, sizeof(req)); encode_trap_header(req.mad); if (encode_trapfn(port, data) < 0) return -1;