linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Johannes Berg <johannes.berg@intel.com>,
	syzbot+bfda097c12a00c8cae67@syzkaller.appspotmail.com,
	Jay Vosburgh <jay.vosburgh@canonical.com>,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>,
	netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.9 04/17] bonding: init notify_work earlier to avoid uninitialized use
Date: Thu,  3 Jun 2021 13:10:39 -0400	[thread overview]
Message-ID: <20210603171052.3169893-4-sashal@kernel.org> (raw)
In-Reply-To: <20210603171052.3169893-1-sashal@kernel.org>

From: Johannes Berg <johannes.berg@intel.com>

[ 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 <johannes.berg@intel.com>
Acked-by: Jay Vosburgh <jay.vosburgh@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 16437aa35bc4..2b721ed392ad 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1280,6 +1280,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;
@@ -1292,7 +1293,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


  parent reply	other threads:[~2021-06-03 17:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03 17:10 [PATCH AUTOSEL 4.9 01/17] net/nfc/rawsock.c: fix a permission check bug Sasha Levin
2021-06-03 17:10 ` [PATCH AUTOSEL 4.9 02/17] ASoC: sti-sas: add missing MODULE_DEVICE_TABLE Sasha Levin
2021-06-03 17:10 ` [PATCH AUTOSEL 4.9 03/17] isdn: mISDN: netjet: Fix crash in nj_probe: Sasha Levin
2021-06-03 17:10 ` Sasha Levin [this message]
2021-06-03 17:10 ` [PATCH AUTOSEL 4.9 05/17] netlink: disable IRQs for netlink_lock_table() Sasha Levin
2021-06-03 17:10 ` [PATCH AUTOSEL 4.9 06/17] net: mdiobus: get rid of a BUG_ON() Sasha Levin
2021-06-03 17:10 ` [PATCH AUTOSEL 4.9 07/17] cgroup: disable controllers at parse time Sasha Levin
2021-06-03 17:10 ` [PATCH AUTOSEL 4.9 08/17] wq: handle VM suspension in stall detection Sasha Levin
2021-06-03 17:10 ` [PATCH AUTOSEL 4.9 09/17] net/qla3xxx: fix schedule while atomic in ql_sem_spinlock Sasha Levin
2021-06-03 17:10 ` [PATCH AUTOSEL 4.9 10/17] scsi: vmw_pvscsi: Set correct residual data length Sasha Levin
2021-06-03 17:10 ` [PATCH AUTOSEL 4.9 11/17] scsi: target: qla2xxx: Wait for stop_phase1 at WWN removal Sasha Levin
2021-06-03 17:10 ` [PATCH AUTOSEL 4.9 12/17] net: macb: ensure the device is available before accessing GEMGXL control registers Sasha Levin
2021-06-03 17:10 ` [PATCH AUTOSEL 4.9 13/17] net: appletalk: cops: Fix data race in cops_probe1 Sasha Levin
2021-06-03 17:10 ` [PATCH AUTOSEL 4.9 14/17] MIPS: Fix kernel hang under FUNCTION_GRAPH_TRACER and PREEMPT_TRACER Sasha Levin
2021-06-03 17:10 ` [PATCH AUTOSEL 4.9 15/17] bnx2x: Fix missing error code in bnx2x_iov_init_one() Sasha Levin
2021-06-03 17:10 ` [PATCH AUTOSEL 4.9 16/17] powerpc/fsl: set fsl,i2c-erratum-a004447 flag for P2041 i2c controllers Sasha Levin
2021-06-03 17:10 ` [PATCH AUTOSEL 4.9 17/17] powerpc/fsl: set fsl,i2c-erratum-a004447 flag for P1010 " Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210603171052.3169893-4-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=davem@davemloft.net \
    --cc=jay.vosburgh@canonical.com \
    --cc=johannes.berg@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+bfda097c12a00c8cae67@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).