From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wvttj-0001pW-8L for qemu-devel@nongnu.org; Sat, 14 Jun 2014 15:46:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wvttb-0003zM-P3 for qemu-devel@nongnu.org; Sat, 14 Jun 2014 15:45:55 -0400 Received: from toccata.ens-lyon.fr ([140.77.166.68]:60718 helo=toccata.ens-lyon.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wvttb-0003zI-Iy for qemu-devel@nongnu.org; Sat, 14 Jun 2014 15:45:47 -0400 Date: Sat, 14 Jun 2014 21:45:31 +0200 From: Samuel Thibault Message-ID: <20140614194531.GS5652@type.youpi.perso.aquilenet.fr> References: <1384700688-30377-1-git-send-email-samuel.thibault@ens-lyon.org> <1392124097-10618-1-git-send-email-samuel.thibault@ens-lyon.org> <1392124097-10618-2-git-send-email-samuel.thibault@ens-lyon.org> <20140611085553.GO31888@type> <53993EED.5040408@siemens.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <53993EED.5040408@siemens.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] slirp: goto bad in udp_input if sosendto fails List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: edgar.iglesias@gmail.com, qemu-devel@nongnu.org, Guillaume Subiron Jan Kiszka, le Thu 12 Jun 2014 07:47:25 +0200, a =E9crit : > On 2014-06-11 10:55, Samuel Thibault wrote: > > Before this patch, if sosendto fails, udp_input is executed as if the > > packet was sent. This could cause memory leak. >=20 > Cannot follow yet how this could leak (not saying I fully got what it > should NOT leak - nasty code). Can you elaborate on the before/after? I haven't worked on the patch, but can comment a bit. I'm not sure it's actually a memory leak, but the "before" situation is quite confusing actually :) Before, m->m_len +=3D iphlen and m->m_data -=3D iphlen would be done twic= e in the end, thus leaving m in an odd state. At any rate, letting udp_input put m into so->so_m does not make any sense: so->so_m is used by icmp_receive/sorecvfrom to know where to send back any errors from the outside for a packet that we have emitted. Here, since we haven't actually emitted the packet, there is not much sense in using it, and any error that we may get later would rather be related to the previous packet, not the one we haven't emitted. Samuel