Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4589934rwd; Tue, 23 May 2023 09:34:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7mCVMbeXh3cNfwGjuS7yK5/fNkAEaKLVe4rcRUo3vs/L4jbNUOOCZH3S+XlxW6AMgsjCn9 X-Received: by 2002:a17:902:eb45:b0:1ae:57d4:efbc with SMTP id i5-20020a170902eb4500b001ae57d4efbcmr14776264pli.13.1684859679068; Tue, 23 May 2023 09:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684859679; cv=none; d=google.com; s=arc-20160816; b=DdeOLLcqnl5cyQHfm3LDJDOBr8D0bIU8NbJwlqPzPg/VCoF4MybJnLXNQCHaAOt27l Px5RRyDn0xGiFJmkCY1fwlQoODsIuYjnxKg8kx3Ggje+ChpSoAmqBzrAZOaQxUZVrCKH feDAoESLFo86EMVoitpz2sj26pYLLomM9CO8KW7oTXTG93dnRjjnHm6wr38YDtDshGUe eiWVLg681m3NrqDr25IcDU2u7IObD1czc5tWGZ0Skxuhu0agpCY2cIq51/pXbMRrBd3E iYDlmx0zeYiRWrnqcLhJmLybloLB5bjlu+pXyGL67sT5dqFhIeSsXBIThkkJgXdua68l 8u+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=03lmNUAB17A9ca+oGO7O4py68GtfGLSGU69TNAskS4o=; b=PodssrTIQVUCTO2Hb7shUA5yHgR49fhsshB2GP0LxkkZ0kWBTFqiPj9HXUO6kpXflk /D1sxQ3es8Wfmppq39z7a3mvznvM2urzySbr1ILlDgxi3NY2NnC0rDvxH5SNXAYabFIM SmAsmhsGmmHSkU2dPuemg8XRcezCNxaF2I1ndbAU6DN/TmUg83y9A5jK0vzZs8fxYURy aM779ETgbRsLjfV5Gng6IAsx9b6k4k0XSeltxdXudA4s99MQFmAHRgLfo8kXNkSuf3XO e5jbRAkFJWA9dA9RdwaYnKNzIIo1N0CKbje9xsDe/a2TvFYzTGg04wP+iFzL0SNHr76N 4XEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=ho9GhgHN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v4-20020a170902b7c400b001ade5e66c3bsi265339plz.118.2023.05.23.09.34.26; Tue, 23 May 2023 09:34:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=ho9GhgHN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237096AbjEWQOa (ORCPT + 99 others); Tue, 23 May 2023 12:14:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236660AbjEWQO1 (ORCPT ); Tue, 23 May 2023 12:14:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 819E4E5 for ; Tue, 23 May 2023 09:14:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1D8B662987 for ; Tue, 23 May 2023 16:14:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66727C433D2; Tue, 23 May 2023 16:14:23 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="ho9GhgHN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1684858461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=03lmNUAB17A9ca+oGO7O4py68GtfGLSGU69TNAskS4o=; b=ho9GhgHN5EnNp5DUHniUPEBPl6Kqd2MJACQhBAZKWYh9S9hKPioKW4g69yu94yVedbEl6C vj9ET3YZpLf3MWvN+6ydsNB2gLMmUqwQfG2FVNh69dlW3amnHINuZ4Sbd7N2d8T8LldRce y1D3SRzJrxN6QvVk+rSb93V1fl0+h/c= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id f9d47816 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 23 May 2023 16:14:21 +0000 (UTC) Date: Tue, 23 May 2023 18:14:18 +0200 From: "Jason A. Donenfeld" To: Jakub Kicinski Cc: edumazet@google.com, syzbot , netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com, davem@davemloft.net, linux-kernel@vger.kernel.org, pabeni@redhat.com, wireguard@lists.zx2c4.com, jann@thejh.net Subject: Re: [syzbot] [wireguard?] KASAN: slab-use-after-free Write in enqueue_timer Message-ID: References: <000000000000c0b11d05fa917fe3@google.com> <20230523090512.19ca60b6@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230523090512.19ca60b6@kernel.org> X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 23, 2023 at 09:05:12AM -0700, Jakub Kicinski wrote: > On Tue, 23 May 2023 17:46:20 +0200 Jason A. Donenfeld wrote: > > > Freed by task 41: > > > __kmem_cache_free+0x264/0x3c0 mm/slub.c:3799 > > > device_release+0x95/0x1c0 > > > kobject_cleanup lib/kobject.c:683 [inline] > > > kobject_release lib/kobject.c:714 [inline] > > > kref_put include/linux/kref.h:65 [inline] > > > kobject_put+0x228/0x470 lib/kobject.c:731 > > > netdev_run_todo+0xe5a/0xf50 net/core/dev.c:10400 > > > > So that means the memory in question is actually the one that's > > allocated and freed by the networking stack. Specifically, dev.c:10626 > > is allocating a struct net_device with a trailing struct wg_device (its > > priv_data). However, wg_device does not have any struct timer_lists in > > it, and I don't see how net_device's watchdog_timer would be related to > > the stacktrace which is clearly operating over a wg_peer timer. > > > > So what on earth is going on here? > > Your timer had the pleasure of getting queued _after_ a dead watchdog > timer, no? IOW it tries to update the ->next pointer of a queued > watchdog timer. Ahh, you're right! Specifically, > hlist_add_head include/linux/list.h:945 [inline] > enqueue_timer+0xad/0x560 kernel/time/timer.c:605 The write on line 945 refers to the side of the timer base, not the peer's timer_list being queued. So indeed, the wireguard netdev is still alive at this point, but it's being queued to a timer in a different netdev that's already been freed (whether watchdog or otherwise in some privdata). So, IOW, not a wireguard bug, right? Jason