Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp138640ybg; Sat, 25 Jul 2020 23:13:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+NSEbK+k4T8nfG5S/AelRXZ4+ft4YIbfyb22UZMIqmjZq27cFKzLRdfv4ObqwAKUJjNwR X-Received: by 2002:a05:6402:359:: with SMTP id r25mr15687109edw.177.1595744017443; Sat, 25 Jul 2020 23:13:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595744017; cv=none; d=google.com; s=arc-20160816; b=eXlDzXz9lzKrJfosmh3xsvn9HXMR3M7n1ZLuTUBQ/QXz8bcjDBOJnWzvnBpVun6r/g 2NiXBx9teUuCJaOvDKH2Ti26tCyf/i5OTylWCgn0C324hqmZ3JB+sWpqBv6CIbFNGGLY lf2AhNP9CYGL/s34VpzwrOp0T3jaQzSm5IfUMMmBBrd93YdeY5zfYJrJmZV9LpqXjXAR QWdwevojwXbR1CJ9p7ukr4GZWkzd1eAkqeqHyztObppeiD3qkFYm5XPmTR9HK+de5HeI ok4+798xCmJJLIAxyZVAiEaloUraQaX3Q1JGzrOFyrfxinIUxNyAvqWJhe3PgpByg/09 9L8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=mjFcFPkYV6UQ15e1Sw/cnOMTT80K9lOv0sYuMsnpbg8=; b=BL03qYLbaBWD1lZl+Tlv0zeK2YOGTmVuL6ecoVLB1zQG2V84aJPsAj3kQ9o4xI6Slt lzTiEQumV8qFNcMNxWLiaojGNPObJHKBKBmomwB5HFUXUsjIDjsMbxl5Ua+zqGeFa6mn oByye/GbFjKw9tBcTpfqIYyhjxcCuvjloRE8shkpfSCONwIzAifTI9+r0WvLuEDTzu30 +fgDr7KGlZIJ7HNlATZuYxcyHkMQFKag0pNGvtyKb5Sia3f1jyc0D2z/6qRbkBKYCqNb /qpDtdUwvW2VdFz2htj9pLpotVJj7vZUq6zCNbU/oAL9JejtRnddKmYXAkYUwmBGPJDh 7vFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pesu-pes-edu.20150623.gappssmtp.com header.s=20150623 header.b="Oq/JKnUl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=pes.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 7si3370864edh.348.2020.07.25.23.13.12; Sat, 25 Jul 2020 23:13:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@pesu-pes-edu.20150623.gappssmtp.com header.s=20150623 header.b="Oq/JKnUl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=pes.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726072AbgGZGM5 (ORCPT + 99 others); Sun, 26 Jul 2020 02:12:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725810AbgGZGM4 (ORCPT ); Sun, 26 Jul 2020 02:12:56 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38290C0619D2 for ; Sat, 25 Jul 2020 23:12:56 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id v4so4212714ljd.0 for ; Sat, 25 Jul 2020 23:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pesu-pes-edu.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mjFcFPkYV6UQ15e1Sw/cnOMTT80K9lOv0sYuMsnpbg8=; b=Oq/JKnUlAX9SgNCIN2rS3ntngRStgdIT5wRDVT1qa5YLa6Xljk4gSLakcYqNbwrf4A rNXx4HHTqH0Jh2YjKKQi/eGniW+FMfKa74XyMOhhUKiBGr82wanEaf2ej/YPHZ84/MW5 IHBmbmbvb1UHIJB1PK9YIzeRm6OE5HEoJJgJ8zslayrKOxWXPkl+goJIUta9pEsJw4PF gl3g15nkqfCCvCDV2tY9EKe6VG/4n5Fgzyi8abxE7bayEIU9QrSCUWM1V+jBAqIWoaYx jGT5pKGDbSu1KJX+0PtRUxOKXmPipyez2I/Qew4fXGDxujA6P6TVWTEg0HHlL3Q2D3DE P06Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mjFcFPkYV6UQ15e1Sw/cnOMTT80K9lOv0sYuMsnpbg8=; b=jU5Rt1+10QH241yFGe46i3r5US+pjgffdlk7xmnwXoRWSu0Cuk5eRzg3TRWRQZAz8B FRwfQuVSbUnlyUXH9ZqG9CCEiIpvSoAUEovKzkU8Un4oQ8gr1UAoQPp2qgz83WEOdSIK c1xYQ6BkRDvm7Cq+ls6DeOsoOI5UmUIN8Rrbrvimg6LSdirfxFZoK0F7WlVftI9v5brU NXNa+7M358607A2BXQbnvgkmS27rmHwRJwtaq9sZj3suMIgDeVzl/8qOrwe/wZx1PcUh PFOX5bN8ASqvZ2D4m1EkYOJv9wmFFPJhg8NPdms53DSsuwlEB57WZmBeW68a+OV+B1FG aOEQ== X-Gm-Message-State: AOAM533P6pBRESwqKL3CLcF44n1vrldsAHDOPWqXS6llOUwMCzuhkwem FMojRht4fWSx+BtpAiV3AKn1P7TvcmZymrT8FYdByg== X-Received: by 2002:a2e:9c59:: with SMTP id t25mr7286391ljj.402.1595743974346; Sat, 25 Jul 2020 23:12:54 -0700 (PDT) MIME-Version: 1.0 References: <20200726030855.q6dfjekazfzl5usw@pesu.pes.edu> In-Reply-To: From: B K Karthik Date: Sun, 26 Jul 2020 11:42:43 +0530 Message-ID: Subject: Re: [PATCH v2] net: ipv6: fix use-after-free Read in __xfrm6_tunnel_spi_lookup To: Cong Wang Cc: Steffen Klassert , Herbert Xu , "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Jakub Kicinski , Linux Kernel Network Developers , LKML , Greg KH , Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jul 26, 2020 at 11:05 AM Cong Wang wrote: > > On Sat, Jul 25, 2020 at 8:09 PM B K Karthik wrote: > > @@ -103,10 +103,10 @@ static int __xfrm6_tunnel_spi_check(struct net *net, u32 spi) > > { > > struct xfrm6_tunnel_net *xfrm6_tn = xfrm6_tunnel_pernet(net); > > struct xfrm6_tunnel_spi *x6spi; > > - int index = xfrm6_tunnel_spi_hash_byspi(spi); > > + int index = xfrm6_tunnel_spi_hash_byaddr((const xfrm_address_t *)spi); > > > > hlist_for_each_entry(x6spi, > > - &xfrm6_tn->spi_byspi[index], > > + &xfrm6_tn->spi_byaddr[index], > > list_byspi) { > > if (x6spi->spi == spi) > > How did you convince yourself this is correct? This lookup is still > using spi. :) I'm sorry, but my intention behind writing this patch was not to fix the UAF, but to fix a slab-out-of-bound. If required, I can definitely change the subject line and resend the patch, but I figured this was correct for https://syzkaller.appspot.com/bug?id=058d05f470583ab2843b1d6785fa8d0658ef66ae . since that particular report did not have a reproducer, Dmitry Vyukov suggested that I test this patch on other reports for xfrm/spi . Forgive me if this was the wrong way to send a patch for that particular report, but I guessed since the reproducer did not trigger the crash for UAF, I would leave the subject line as 'fix UAF' :) xfrm6_spi_hash_by_hash seemed more convincing because I had to prevent a slab-out-of-bounds because it uses ipv6_addr_hash. It would be of great help if you could help me understand how this was able to fix a UAF. > > More importantly, can you explain how UAF happens? Apparently > the syzbot stack traces you quote make no sense at all. I also > looked at other similar reports, none of them makes sense to me. Forgive me, but I do not understand what you mean by the stack traces (this or other similar reports) "make no sense". I apologise if this message was hurtful / disrespectful in any manner. thanks, karthik