Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5901707pxb; Tue, 16 Feb 2021 10:17:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJyw5iU3siO+w/1ru8c3AdVp1llf+472J9HY5oRpHIWFBJhoMsdQIMOXz3EXKj9CmfKI3Acm X-Received: by 2002:a05:6402:34d2:: with SMTP id w18mr23075004edc.102.1613499454792; Tue, 16 Feb 2021 10:17:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613499454; cv=none; d=google.com; s=arc-20160816; b=IHMSA6hZoVbbRj9gpCVEDpglCEPXXHV3NIKTYhZNo1Y901dwFUmHglV4hzjwvPmqdj lNY6WFdARns7o8UnR+AgTsP9ngxXXyl97mQXVPwHvU7IIjR6+aE+Jul+3MMXFA4ZbirR o/5dTnUJFEXE1GFMBcSYDw5DgWn/n1oNICfR5ojkJZ3RNjjTB8CBMI0fRst8OmyiMRjM RgqFyzMfVi2I8TywS2/lgI3A6tDMnQSO90g3NjOjkiv3oE2KzcdAO5+vdopXyp66i6gH Psxej1CUoPCD3dirZeyG//CYDxs4+5wsFUzGJbe9Clv1WkH0l4xi0i07i4QcXGbsYx9L suzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=TIaOcjadSpBzzJCMnARKl1ZXAgu2yuZpBTm/4wzkXqs=; b=xfm2Ja8bmRpGA2qmmutfMErUU0mryDNLYWJ0KOPRU56UzVqq6WrVuhil3/uudlgsK9 /yP8k7Yo50dgdy/JAkegFRKETi+d59QGLuZpq/feUdRi6nfFsXPHL1AgwfYyH4ELbefh jkHXOAXpeD8Ym4qJIevtXsou1KsAIORzRyOnE52O+hoc7wZfh1tfWwYz224LVfZQSQNN jQfn3H0NR1xFVB1gkFQr004/AxayUwHBSIL4JOCJGGdyq5rExxLQsvHy4c5MBG/Au0QX mUQEIF6fwWPMwQACJ9yszCPQ7g+4Rk69fVhcOqezLA8X8d0G44DjfxdF2Nj1rmoQMrmr yNVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bUK55NBg; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hx7si14656022ejc.316.2021.02.16.10.17.10; Tue, 16 Feb 2021 10:17:34 -0800 (PST) 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=@google.com header.s=20161025 header.b=bUK55NBg; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230291AbhBPSP7 (ORCPT + 99 others); Tue, 16 Feb 2021 13:15:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229937AbhBPSP5 (ORCPT ); Tue, 16 Feb 2021 13:15:57 -0500 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7F25C06174A for ; Tue, 16 Feb 2021 10:15:16 -0800 (PST) Received: by mail-qk1-x72b.google.com with SMTP id r77so10263016qka.12 for ; Tue, 16 Feb 2021 10:15:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TIaOcjadSpBzzJCMnARKl1ZXAgu2yuZpBTm/4wzkXqs=; b=bUK55NBg5Uh81hVcSU2sx1CX7JZR04xf76FPXqIDHyXehqyY+Zi1t+aliIoc/R5e9n 1joKE4tLAiSsbda18uhNJUsQXDlVmCaDe5LQSoBHbUyMpg77caNQ5W1ra4dKhaDZBktx VPJxl8d9MSR5AiuIsbMihyOpi7z1uhO7E5X1FlIYnQEyqGxuwfODwFoLCYY0wiHDv0tZ BjGXEOU9v4skzIhJX/4FwlXpHP9O0gJaA1Nk1bip/oEhnJPqaCYK9wTYhui/kwJ2gMnB L3yPj7cgrwYoZzgVPIY8k4QeZN0B6q8nVoYwZMFUyo1dOlfxRk5zhJf9+y1OIl75SS9u 6Wmw== 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=TIaOcjadSpBzzJCMnARKl1ZXAgu2yuZpBTm/4wzkXqs=; b=n3xfuzuzRQ4iExiZ4npkwVJrIXyDrKwgoJg5TwbRxtVeOSPXvxq3jXJt2n0xPdhSRa EF72oga6KjKEpLlFkHPaSW9tOqVqYkIOlhR+rvaOmv9PuvaFZMkZ7i/rLQsnZrqiSxYI zs44RGR7+JLqC2QuqgERUmvbOBy6b/6UOmMyT/Wa+s/CNzbRbgOW9ckt4fXc6RkjK6hA TR6Y2jCZdsaJvHsG5ZDfhOwtp9SUDTRW0ZAjGp+dnSlGppS4CUxlEV6lnP9PwBUmeDQo ez1LSzmZTdvyrM73xvWYtqT010ORrpnCXnQi7BsnWBZah8/8qBfSl3vResIM4AfKC6cA +ROw== X-Gm-Message-State: AOAM531x2oslp3WgSkYsSkSKw08Ytze2hO3fTGlvmKmTgDdWqC7Ys6+4 wZE5lJcWAPCsV6CFpIvm+QN6/Lc01R4PLohyJLD8iQ== X-Received: by 2002:a05:620a:1351:: with SMTP id c17mr21197159qkl.350.1613499315616; Tue, 16 Feb 2021 10:15:15 -0800 (PST) MIME-Version: 1.0 References: <0000000000000be4d705bb68dfa7@google.com> <20210216172817.GA14978@arm.com> <20210216180143.GB14978@arm.com> In-Reply-To: <20210216180143.GB14978@arm.com> From: Dmitry Vyukov Date: Tue, 16 Feb 2021 19:15:04 +0100 Message-ID: Subject: Re: KASAN: invalid-access Write in enqueue_timer To: Catalin Marinas , Eric Dumazet Cc: "Jason A. Donenfeld" , Netdev , syzbot , Mark Brown , Kees Cook , linux-arm-kernel , LKML , Mark Rutland , mbenes@suse.cz, syzkaller-bugs , Will Deacon , Ard Biesheuvel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 16, 2021 at 7:01 PM Catalin Marinas wrote: > > On Tue, Feb 16, 2021 at 06:50:20PM +0100, Jason A. Donenfeld wrote: > > On Tue, Feb 16, 2021 at 6:46 PM Jason A. Donenfeld wrote: > > > On Tue, Feb 16, 2021 at 6:28 PM Catalin Marinas wrote: > > > > > hlist_add_head include/linux/list.h:883 [inline] > > > > > enqueue_timer+0x18/0xc0 kernel/time/timer.c:581 > > > > > mod_timer+0x14/0x20 kernel/time/timer.c:1106 > > > > > mod_peer_timer drivers/net/wireguard/timers.c:37 [inline] > > > > > wg_timers_any_authenticated_packet_traversal+0x68/0x90 drivers/net/wireguard/timers.c:215 > > > > > > The line of hlist_add_head that it's hitting is: > > > > > > static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h) > > > { > > > struct hlist_node *first = h->first; > > > WRITE_ONCE(n->next, first); > > > if (first) > > > > > > So that means it's the dereferencing of h that's a problem. That comes from: > > > > > > static void enqueue_timer(struct timer_base *base, struct timer_list *timer, > > > unsigned int idx, unsigned long bucket_expiry) > > > { > > > > > > hlist_add_head(&timer->entry, base->vectors + idx); > > > > > > That means it concerns base->vectors + idx, not the timer_list object > > > that wireguard manages. That's confusing. Could that imply that the > > > bug is in freeing a previous timer without removing it from the timer > > > lists, so that it winds up being in base->vectors? > > Good point, it's indeed likely that the timer list is messed up already, > just an unlucky encounter in the wireguard code. > > > Digging around on syzkaller, it looks like there's a similar bug on > > jbd2, concerning iptunnels's allocation: > > > > https://syzkaller.appspot.com/text?tag=CrashReport&x=13afb19cd00000 > [...] > > It might not actually be a wireguard bug? > > I wonder whether syzbot reported similar issues with > CONFIG_KASAN_SW_TAGS. It shouldn't be that different from the HW_TAGS > but at least we can rule out qemu bugs with the MTE emulation. +Eric