Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2642165pxj; Mon, 14 Jun 2021 03:50:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyj6+Se99BIg2HCkpAnrlkGB4J7guBsHx2ILZTu+A7h/9iotlsWT8hnVOiXqHqzYSvO9WY X-Received: by 2002:a05:6402:40c3:: with SMTP id z3mr16094278edb.187.1623667805801; Mon, 14 Jun 2021 03:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623667805; cv=none; d=google.com; s=arc-20160816; b=Afxj/7YUFnb7YRhbXHXMuIAzqImAyEMkksrKJmMsb0aZITyoFIooOPMqY2dE0IvWxv EWD6EgmqW9l4GuAWTOKDChZSvLG5qgcJaPaGTqsQbMjVee+b9u3JF3s81JCBnvUQXFwJ Qq2kTdFpO10lgyK7zOaINCOAwTY805fmd5SKTP5IF2KL1EeUGdOB0Z6D4amm4EsVDZRz YmpVwOC5FN5iuSa68i5QuJ4vPNBqcMEPB+IuiqJHK3DieEJZiff8m1Ar84r6mrQ+Llo3 g+/kPKIJs0O1A9rmQp3faQSBbAUmdTiD5/0+fULfrQaJeJqTA7YxxHvf7Zq5JMn9P2b8 bm2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AxuLvYwWFmD10h29a4xff38VOnqfJAPjjgYgVcraoLs=; b=tF/b2BFwe6DSCAD1kN2CiPxshnqEZ+OZBim/ZEHA8rM0MZWyVWPcurnPAeV2qG/p8O xrqk/cGrc+mPMMy2pxKPJFN+9Gzai/45p5iEjO617pkcNq601rQ5baV3Ze1Y236WGlHW VuJ50M8A4NnKl5CWVMiG16G7ezKNlYZNx1GlBDBAH1I466QEOW0C7TvQaeCD5aCIh9hc iUZ6Yt8gtvtrpk/O7BjhdcNdjZ/lpojQAwYzJZI4HK7X3D4fXFqDg6DiGoDMQchG5N3D xdyAmXjCxFmB8OpVLjyuwkncsSUhGymjrC4IZy/4ZRXzDhqFC5mc2N3iquYqcdPQGfJd Q3zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=clHk+aZa; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q4si10521165edr.469.2021.06.14.03.49.43; Mon, 14 Jun 2021 03:50:05 -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=@linuxfoundation.org header.s=korg header.b=clHk+aZa; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233396AbhFNKtw (ORCPT + 99 others); Mon, 14 Jun 2021 06:49:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:46850 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233738AbhFNKnS (ORCPT ); Mon, 14 Jun 2021 06:43:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9D94261241; Mon, 14 Jun 2021 10:35:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623666954; bh=QjZL+O3NSFI77h2z5WDWGc3+ZvAdpEVYHaA7LKIbBw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=clHk+aZakxgQcn3hrlQgds874DzfI1G10yijaA8JyJtjEiKN8hXywx5zS68rfw669 3n1Jg7hoWyWdsegZALW7seDxGcdvqHCR8pFM8XAxz1O0P4G0vj1NL4nxKHafZ5Py9Y 65CcP99Nu915C16NYO5QVnBrGtMMfX7mmwCcsqAs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+bfda097c12a00c8cae67@syzkaller.appspotmail.com, Johannes Berg , Jay Vosburgh , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 08/67] bonding: init notify_work earlier to avoid uninitialized use Date: Mon, 14 Jun 2021 12:26:51 +0200 Message-Id: <20210614102644.070274479@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614102643.797691914@linuxfoundation.org> References: <20210614102643.797691914@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg [ Upstream commit 35d96e631860226d5dc4de0fad0a415362ec2457 ] If bond_kobj_init() or later kzalloc() in bond_alloc_slave() fail, then we call kobject_put() on the slave->kobj. This in turn calls the release function slave_kobj_release() which will always try to cancel_delayed_work_sync(&slave->notify_work), which shouldn't be done on an uninitialized work struct. Always initialize the work struct earlier to avoid problems here. Syzbot bisected this down to a completely pointless commit, some fault injection may have been at work here that caused the alloc failure in the first place, which may interact badly with bisect. Reported-by: syzbot+bfda097c12a00c8cae67@syzkaller.appspotmail.com Signed-off-by: Johannes Berg Acked-by: Jay Vosburgh Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/bonding/bond_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index c21c4291921f..c814b266af79 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1310,6 +1310,7 @@ static struct slave *bond_alloc_slave(struct bonding *bond, slave->bond = bond; slave->dev = slave_dev; + INIT_DELAYED_WORK(&slave->notify_work, bond_netdev_notify_work); if (bond_kobj_init(slave)) return NULL; @@ -1322,7 +1323,6 @@ static struct slave *bond_alloc_slave(struct bonding *bond, return NULL; } } - INIT_DELAYED_WORK(&slave->notify_work, bond_netdev_notify_work); return slave; } -- 2.30.2