Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp488135pxu; Thu, 3 Dec 2020 05:35:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHhBExqFYzFpkdYvQIDHxuJjp0kILlzg/zem9G3iEojeEr2r921sKcaylqgLX8JpGUcCZI X-Received: by 2002:a05:6402:2208:: with SMTP id cq8mr2830852edb.182.1607002523916; Thu, 03 Dec 2020 05:35:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607002523; cv=none; d=google.com; s=arc-20160816; b=AwSVLfEgqVRms/IQP6fcyXvOLPUHMn3gqontRkoR6TbYmxnC4I1kObUGivFeEDN99f o95qEmA8cMAhDvWiMwqCj0i+lpR8T18k5x8WtkC53MZZR/Ask3iil7ZiHkcRBwtdpXxw G664TTGzyDnrYXyh5f5KYrWfUnD2xegBBmXqZwnPy03z7NvbNol5PYi1Pa3mZY6+PPfZ uC9bjgJajGrbPIjQqn8qSxCzTd26Fh966nU9LGI73L/arlv2Bq047dzFOSS2p12y9n8l WB1CZoORBrSTUY8vh7bgHsrhvxcVxAIDHTzxBh6nf5boqqdpH8/utLC67wGyVZDyVYsR nCKw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=6f0ZkSO043DoqdumAUSBIH8BufWr9xGYUqLmzrHTfvY=; b=Vsai0ZIbli3lcF4z/E4pp+8LIv3c1aaTF3S8rrBnIF6bfhyvG4PM5XE9rLTSYnslYQ sDJL7vK+d7PGN1p3oO3D3j8n3l8gKulnST7a1YJGxxMBWq8AvzB0Z+o82WyQKty0IJPA C2KGvqbp1rtI4pTyGUpekVu0XZ06AVS6hNe7fXfiftwLGm63cdoGtEOhf3fpmM947133 B7CKSXTVMMgG9gej0JpVjA7o+waJOupHgW2PfBBgf4Sayl0z5jym2ATrcsCGmEndlDNJ gxqwLvcnYfa5dfe2xJQ4kHy035g0LuDHs9s6LUnKvTjeLFMUbSWNfyUYZyfsRL5wVM1G X8oQ== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u4si1061957eja.497.2020.12.03.05.35.00; Thu, 03 Dec 2020 05:35:23 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436635AbgLCNad (ORCPT + 99 others); Thu, 3 Dec 2020 08:30:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:47840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436562AbgLCNac (ORCPT ); Thu, 3 Dec 2020 08:30:32 -0500 From: Sasha Levin Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oliver Hartkopp , syzbot+381d06e0c8eaacb8706f@syzkaller.appspotmail.com, syzbot+d0ddd88c9a7432f041e6@syzkaller.appspotmail.com, syzbot+76d62d3b8162883c7d11@syzkaller.appspotmail.com, Marc Kleine-Budde , Sasha Levin , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.9 39/39] can: af_can: can_rx_unregister(): remove WARN() statement from list operation sanity check Date: Thu, 3 Dec 2020 08:28:33 -0500 Message-Id: <20201203132834.930999-39-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201203132834.930999-1-sashal@kernel.org> References: <20201203132834.930999-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: Oliver Hartkopp [ Upstream commit d73ff9b7c4eacaba0fd956d14882bcae970f8307 ] To detect potential bugs in CAN protocol implementations (double removal of receiver entries) a WARN() statement has been used if no matching list item was found for removal. The fault injection issued by syzkaller was able to create a situation where the closing of a socket runs simultaneously to the notifier call chain for removing the CAN network device in use. This case is very unlikely in real life but it doesn't break anything. Therefore we just replace the WARN() statement with pr_warn() to preserve the notification for the CAN protocol development. Reported-by: syzbot+381d06e0c8eaacb8706f@syzkaller.appspotmail.com Reported-by: syzbot+d0ddd88c9a7432f041e6@syzkaller.appspotmail.com Reported-by: syzbot+76d62d3b8162883c7d11@syzkaller.appspotmail.com Signed-off-by: Oliver Hartkopp Link: https://lore.kernel.org/r/20201126192140.14350-1-socketcan@hartkopp.net Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- net/can/af_can.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/can/af_can.c b/net/can/af_can.c index 0e71e0164ab3b..086a595caa5a7 100644 --- a/net/can/af_can.c +++ b/net/can/af_can.c @@ -541,10 +541,13 @@ void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id, /* Check for bugs in CAN protocol implementations using af_can.c: * 'rcv' will be NULL if no matching list item was found for removal. + * As this case may potentially happen when closing a socket while + * the notifier for removing the CAN netdev is running we just print + * a warning here. */ if (!rcv) { - WARN(1, "BUG: receive list entry not found for dev %s, id %03X, mask %03X\n", - DNAME(dev), can_id, mask); + pr_warn("can: receive list entry not found for dev %s, id %03X, mask %03X\n", + DNAME(dev), can_id, mask); goto out; } -- 2.27.0