From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754969AbdKBM0A (ORCPT ); Thu, 2 Nov 2017 08:26:00 -0400 Received: from Chamillionaire.breakpoint.cc ([146.0.238.67]:58300 "EHLO Chamillionaire.breakpoint.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752377AbdKBMZ7 (ORCPT ); Thu, 2 Nov 2017 08:25:59 -0400 Date: Thu, 2 Nov 2017 13:25:28 +0100 From: Florian Westphal To: Steffen Klassert Cc: Florian Westphal , syzbot , davem@davemloft.net, herbert@gondor.apana.org.au, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com, thomas.egerer@secunet.com Subject: Re: KASAN: stack-out-of-bounds Read in xfrm_state_find (2) Message-ID: <20171102122528.GB9424@breakpoint.cc> References: <20171101220608.GA9424@breakpoint.cc> <20171102103237.GL11292@secunet.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171102103237.GL11292@secunet.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Steffen Klassert wrote: > On Wed, Nov 01, 2017 at 11:06:08PM +0100, Florian Westphal wrote: > > I also don't understand how address comparision is supposed to work in this case, > > it seems that if saddr/daddr are v4 and template v6 we compare full ipv6 addresses > > (how would that succeed...?) and, if saddr/daddr is v6 add template is v4 we just > > compare the first 32bit of the ipv6 addresses...? > > When we do tunnel or beet mode, we pass saddr and daddr from the > template to xfrm_state_find(), this should be ok. On transport > mode, we pass the addresses from the flowi, assuming that the > IP addresses (and address family) don't change during transformation. > This assumption is wrong in the IPv4 mapped IPv6 case, packet > is IPv4 and template is IPv6. Right, sendto() uses ipv4 address on ipv6 socket. > I'd propose to use the addresses from the template unconditionally, > like the (untested) patch below does. > > Unfortunalely the reproducer does not work with my config, > sendto returns EAGAIN. Could anybody try this patch? The reproducer no longer causes KASAN spew with your patch, but i don't have a test case that actually creates/uses a tunnel.