Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1558884rdb; Mon, 8 Jan 2024 03:15:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAcWoMQG51pZbGKBXR/v83WI9H+jdpof4MqMzlsWDGq4OfMPoIc3vs4In+VEaC7EPxn+bU X-Received: by 2002:a17:90b:374c:b0:28c:6446:2dde with SMTP id ne12-20020a17090b374c00b0028c64462ddemr889620pjb.52.1704712551600; Mon, 08 Jan 2024 03:15:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704712551; cv=none; d=google.com; s=arc-20160816; b=yLqRfZU6Mg53v0vz/0forOsrOc6Ac0DAIUpx8yEHUCwGeiW56E287pRolLdtbMThr7 SDBTGT6lb/npy7X2tlHQgKRT3mCyxdPnBn8ExtDbAfF9QVacUCG1bmWOr9cJag5G32dn SqVJVvods0KhFTwZFlxmewxm6fRL8dc/pxjzVP4Hzoi4lKpZTUkWv/WHZyYlHAeXtqwx 8J3p4KLdy7t8GsiCq3PSWMmDH2qIOR9nu0CXMxsdrSvuaoiwmCfXJkY5JpQV1ImLGvtY +PB+g7fEpmvgq1/KOTv4uQdWjl8/jsg+UDjbA0cwpzj6MHNytg1M+PUFsIseMJALwjmZ Bd4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date; bh=7DhZxENtzRbQmrHgJxedenPQyJbY8l7CKlXxBAAvf24=; fh=8tcWnGIZo35g9RSVlEVfRA2T1sf67gMllFAm02hOrBE=; b=OTH1P8Xf4jukLqxqNRSb/bSMXLsw0rc2HhYR0BVVMTSYuewIr1omygZmkMPDslF3pV IQxcozszod1fr6kaRqsgJosxK42RnjEa80JjtUvkDmXE/+bJMYTRY8aCRgtBHpZVVpem 4tXonzkKzfk/yITjg3+6Ry3uVTA4EM32JZfx8eJ5l2PRKJKrH2pLJNquG2G7ktjx8dy0 r+PwPpg5M1AykKdQwCiJrZfTwPny04uvM/Ma7XmPpRAThlCDpMxqpvv4tQym5Ztt27rR /4LOUGRND1xtlIUSuBDQ/a6PunjuMSaG5xORQoMT8A0UCFRR8x8x5Lcq6MrBEfpMbLLP 6zGg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19398-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19398-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id em24-20020a17090b015800b0028c984d53b4si5542339pjb.73.2024.01.08.03.15.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 03:15:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19398-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19398-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19398-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 9DA43B2194B for ; Mon, 8 Jan 2024 11:15:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C75BF14A90; Mon, 8 Jan 2024 11:15:23 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [91.216.245.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D35614266; Mon, 8 Jan 2024 11:15:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strlen.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=strlen.de Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1rMnay-0000kd-E6; Mon, 08 Jan 2024 12:15:04 +0100 Date: Mon, 8 Jan 2024 12:15:04 +0100 From: Florian Westphal To: Pavel Tikhomirov Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@openvz.org Subject: Re: [PATCH] neighbour: purge nf_bridged skb from foreign device neigh Message-ID: <20240108111504.GA23297@breakpoint.cc> References: <20240108085232.95437-1-ptikhomirov@virtuozzo.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240108085232.95437-1-ptikhomirov@virtuozzo.com> User-Agent: Mutt/1.10.1 (2018-07-13) Pavel Tikhomirov wrote: > An skb can be added to a neigh->arp_queue while waiting for an arp > reply. Where original skb's skb->dev can be different to neigh's > neigh->dev. For instance in case of bridging dnated skb from one veth to > another, the skb would be added to a neigh->arp_queue of the bridge. > > There is no explicit mechanism that prevents the original skb->dev link > of such skb from being freed under us. For instance neigh_flush_dev does > not cleanup skbs from different device's neigh queue. But that original > link can be used and lead to crash on e.g. this stack: > > arp_process > neigh_update > skb = __skb_dequeue(&neigh->arp_queue) > neigh_resolve_output(..., skb) > ... > br_nf_dev_xmit > br_nf_pre_routing_finish_bridge_slow > skb->dev = nf_bridge->physindev > br_handle_frame_finish > > So let's improve neigh_flush_dev to also purge skbs when device > equal to their skb->nf_bridge->physindev gets destroyed. Can we fix this by replacing physindev pointer with plain ifindex instead? There are not too many places that need to peek into the original net_device struct, so I don't think the additional dev_get_by_index_rcu() would be an issue.