From patchwork Sat Apr 29 16:47:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 756757 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wFc8V0Y5jz9s3w for ; Sun, 30 Apr 2017 02:48:49 +1000 (AEST) Received: from localhost ([::1]:41715 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d4VY5-0006tL-6T for incoming@patchwork.ozlabs.org; Sat, 29 Apr 2017 12:48:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d4VXH-0006ry-OD for qemu-devel@nongnu.org; Sat, 29 Apr 2017 12:47:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d4VXG-0001L2-UN for qemu-devel@nongnu.org; Sat, 29 Apr 2017 12:47:55 -0400 Received: from hera.aquilenet.fr ([2a01:474::1]:55403) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d4VXG-0001Kg-NN for qemu-devel@nongnu.org; Sat, 29 Apr 2017 12:47:54 -0400 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 30A7DBA86; Sat, 29 Apr 2017 18:47:54 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3JNV_wVh3VZ9; Sat, 29 Apr 2017 18:47:53 +0200 (CEST) Received: from var.youpi.perso.aquilenet.fr (unknown [IPv6:2a01:cb19:181:c200:3602:86ff:fe2c:6a19]) by hera.aquilenet.fr (Postfix) with ESMTPSA id EB49FBB2F; Sat, 29 Apr 2017 18:47:51 +0200 (CEST) Received: from samy by var.youpi.perso.aquilenet.fr with local (Exim 4.89) (envelope-from ) id 1d4VXD-0004Xm-2t; Sat, 29 Apr 2017 18:47:51 +0200 From: Samuel Thibault To: qemu-devel@nongnu.org Date: Sat, 29 Apr 2017 18:47:44 +0200 Message-Id: <20170429164750.17414-4-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170429164750.17414-1-samuel.thibault@ens-lyon.org> References: <20170429164750.17414-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:474::1 Subject: [Qemu-devel] [PULL 3/9] slirp: tftp, copy sockaddr_size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Samuel Thibault , stefanha@redhat.com, jan.kiszka@siemens.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau ASAN detects an "unknown-crash" when running pxe-test: /ppc64/pxe/spapr-vlan: ================================================================= ==7143==ERROR: AddressSanitizer: unknown-crash on address 0x7f6dcd298d30 at pc 0x55e22218830d bp 0x7f6dcd2989e0 sp 0x7f6dcd2989d0 READ of size 128 at 0x7f6dcd298d30 thread T2 #0 0x55e22218830c in tftp_session_allocate /home/elmarco/src/qq/slirp/tftp.c:73 #1 0x55e22218a1f8 in tftp_handle_rrq /home/elmarco/src/qq/slirp/tftp.c:289 #2 0x55e22218b54c in tftp_input /home/elmarco/src/qq/slirp/tftp.c:446 #3 0x55e2221833fe in udp6_input /home/elmarco/src/qq/slirp/udp6.c:82 #4 0x55e222137b17 in ip6_input /home/elmarco/src/qq/slirp/ip6_input.c:67 Address 0x7f6dcd298d30 is located in stack of thread T2 at offset 96 in frame #0 0x55e222182420 in udp6_input /home/elmarco/src/qq/slirp/udp6.c:13 This frame has 3 object(s): [32, 48) '' [96, 124) 'lhost' <== Memory access at offset 96 partially overflows this variable [160, 200) 'save_ip' <== Memory access at offset 96 partially underflows this variable The sockaddr_storage pointer is the sockaddr_in6 lhost on the stack. Copy only the source addr size. Signed-off-by: Marc-André Lureau Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Samuel Thibault --- slirp/tftp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slirp/tftp.c b/slirp/tftp.c index 50e714807d..a9bc4bb1b6 100644 --- a/slirp/tftp.c +++ b/slirp/tftp.c @@ -70,7 +70,7 @@ static int tftp_session_allocate(Slirp *slirp, struct sockaddr_storage *srcsas, found: memset(spt, 0, sizeof(*spt)); - spt->client_addr = *srcsas; + memcpy(&spt->client_addr, srcsas, sockaddr_size(srcsas)); spt->fd = -1; spt->block_size = 512; spt->client_port = tp->udp.uh_sport;