From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3D07C4709C for ; Thu, 3 Jun 2021 17:14:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DE67613DE for ; Thu, 3 Jun 2021 17:14:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232897AbhFCRQY (ORCPT ); Thu, 3 Jun 2021 13:16:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:43644 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232726AbhFCRMO (ORCPT ); Thu, 3 Jun 2021 13:12:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C0E6D61414; Thu, 3 Jun 2021 17:10:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622740208; bh=QjZL+O3NSFI77h2z5WDWGc3+ZvAdpEVYHaA7LKIbBw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pzpHVR+0onU6Kd2dVYZeTgpc42PwOLMiK2voWOVs8lfYfs2wCgYFtpkLjYf/aO4rp 0BzkSDQXHJuaVzEe1cPS622nIoATzgKjVa6FWbaHyWmgUXDa6VZCVI0FRUvMUf7jxa 8shQyKovIaxUbTIpYKhzjrCfULrMsOLN21crrZnpf3ElgGoxbdk+IyjlvghRPD6b1P J/8JGa2zuDJ6+TWWnKnNIbtPKyXWMNPMyTaKtBGodCS79gQeWQ+cP9zlewOtGcm4iG gKbHgW8LRj0DidXrSSpv/qzknr0eydx0rqpKYWyk/WvdbqbxC5GAcq/UF6T2Ab6KE0 HT66+bd+IEA/g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Johannes Berg , syzbot+bfda097c12a00c8cae67@syzkaller.appspotmail.com, Jay Vosburgh , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 07/23] bonding: init notify_work earlier to avoid uninitialized use Date: Thu, 3 Jun 2021 13:09:43 -0400 Message-Id: <20210603170959.3169420-7-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210603170959.3169420-1-sashal@kernel.org> References: <20210603170959.3169420-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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