From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F37841F0E27 for ; Tue, 4 Mar 2025 03:53:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741060439; cv=none; b=VTXSAhMcGXNIFqpnqtjmAKmVeVuYnChdPUaHlkpUg4Tt0XC90tCGBQ5TuKsikixVF4T+aCHlT8Y6/xpf86FTp9GH/wQMNfpa5pcFODHOfQEc9HGyfmvulY9ceWdrk38J5/+yO51XvO+h511j3C0iRsioN8YTebCfUwyGdOFUQQU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741060439; c=relaxed/simple; bh=v4ZIW03tXTq33ylUh9Hi3kvpmNUOTXtibE59mai2iZ8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=OdZTQN2kIdJ3Pfz68slzJegLijaC8xu4gFgB+l9BD8qg6T20QMiK05jXCUgO03MLrs94FreZkhHYxfXuv7BXiguETd7YeBSfXz33B+MERT5Tp8PtITwE/FwFOCrEsY0FeTy/NC0PhfMZutjyn7RIrybTv4pHZP8sOTP43NyhBYY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Zeha4UDL; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Zeha4UDL" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-223722270b7so63245ad.1 for ; Mon, 03 Mar 2025 19:53:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741060437; x=1741665237; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=hSFEb6cmbj6TrSKHrJmKO1hlYsPUC+0FUI58pDz1vl8=; b=Zeha4UDL+PUCz5e9lJQdQ12LAT7HMzDhQtuPE6EzaQxiOITpXFceZVvMq1+a2pKt0J y7za/dpejvEOzlvhE5g4JKZlZiTf2yr2hlGqc7LT/WGncgsyCnfOvk/sucC927Rr4ddm bUkywf/hRsJuweRVxy6NpyUhiY/0nyvBDrmiOEZ6IP4Mw2LUgvP6Cm/yxYbJAGyXIUX7 JZUByRUTGpZisw9jgUXQVUHCipDQonZKeoCX66hEDsV+OEwk67XglZbZ8Bsx4gIXtx46 wka3oEIwuZ1I8yNNu92/Oq7D9CxIeqXofDA3kyHn7TLGFqrYqQbZXiQQlcvBRE90saRt 6a4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741060437; x=1741665237; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hSFEb6cmbj6TrSKHrJmKO1hlYsPUC+0FUI58pDz1vl8=; b=nwsP8jIdoa0DpTFS2gkCqoiClKqLH2oXZrNb9CtV9wT/TwJ7CAKXMhzt7DDurBM72o VC1kLzZFT+QWeIQsgdV9wYGto/vBMoI2Xk9h5jg5wR0AT7ZV9BpS5r0iqUCF0+PpfL9s FuDWJXfj2n5szYgzbWU/IamBwaMU9jN9YNWbq+oe2Fqq2oW1kHAxt9Q/BhwpTwU79ZQL u4lEihKICK1aehmkykPIiLT4SJ6/E5Vw6qwM5ngPb7/RIkEgrJ7xzT238FQ8rfpP7FtW yEAtS/0b11ZgmUv20HEjzk9/bMi9MvQUCmU+l4qtsnbV5XA42ti79evbYJowvgBAyFHw YtNw== X-Forwarded-Encrypted: i=1; AJvYcCUtRh1IPaEkiHayGJC/X7f0WksW8yjcBdIZ47Skg+mgRuQs0rLZ0pFrmWgGHntq9xFpjkw5BAjxsNc=@vger.kernel.org X-Gm-Message-State: AOJu0YxtCqBYQjh4ByDOniH3LSSBEApzjudFmqiYfHoQy3fJPtRuWUSb SBy62lya9fDj6NjbaeqpCRU2Co0IPBNh1bPaFe7B7bzQetY8zNDhlV3whqPf+FoPl6EOduy8JXJ 1p7VKk1rg9ykoKguAIC9UxiHGczRs6pob35CT X-Gm-Gg: ASbGncvjh23F+hQFRjFO/WlE8EwacEsP8xbzY0qTW87Jp5fTT3Ix0atT+C78wZLNEzM 9Dib/3xKDsHg1K1Geu8XQ8F7AZtmoALVJr182zXirymFHx5XrUvHOzVNCD9JcRcxzTFmD/5srv3 EXSDdzklxbC1nxf3He3u2VR6KCDg== X-Google-Smtp-Source: AGHT+IHSpmXymQz0Hg2Nfi/UMM95jLNI0Agz8LxyDxK7J1nuQGrVPSq5ZOQpmxKAyc8gv2/Tg1AhK763Ctub08I/iBk= X-Received: by 2002:a17:902:e892:b0:217:8612:b690 with SMTP id d9443c01a7336-223d9e008f0mr1582615ad.8.1741060436769; Mon, 03 Mar 2025 19:53:56 -0800 (PST) Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20250227041209.2031104-1-almasrymina@google.com> <20250227041209.2031104-8-almasrymina@google.com> <20250228164301.07af6753@kernel.org> <20250303162901.7fa57cd0@kernel.org> In-Reply-To: <20250303162901.7fa57cd0@kernel.org> From: Mina Almasry Date: Mon, 3 Mar 2025 19:53:44 -0800 X-Gm-Features: AQ5f1JrYu9C4BjqccschILEVQXZn6ayr_hbqMYvwnSubi9nhcByOZkaDeGtsjTs Message-ID: Subject: Re: [PATCH net-next v6 7/8] net: check for driver support in netmem TX To: Jakub Kicinski Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux.dev, linux-kselftest@vger.kernel.org, Donald Hunter , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Jonathan Corbet , Andrew Lunn , Jeroen de Borst , Harshitha Ramamurthy , Kuniyuki Iwashima , Willem de Bruijn , David Ahern , Neal Cardwell , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?Q?Eugenio_P=C3=A9rez?= , Stefan Hajnoczi , Stefano Garzarella , Shuah Khan , sdf@fomichev.me, asml.silence@gmail.com, dw@davidwei.uk, Jamal Hadi Salim , Victor Nogueira , Pedro Tammela , Samiullah Khawaja Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Mar 3, 2025 at 4:29=E2=80=AFPM Jakub Kicinski wro= te: > > On Fri, 28 Feb 2025 17:53:24 -0800 Mina Almasry wrote: > > On Fri, Feb 28, 2025 at 4:43=E2=80=AFPM Jakub Kicinski wrote: > > > On Thu, 27 Feb 2025 04:12:08 +0000 Mina Almasry wrote: > > > > + if (!skb_frags_readable(skb) && !dev->netmem_tx) > > > > > > How do you know it's for _this_ device tho? > > > > Maybe a noob question, but how do we end up here with an skb that is > > not targeted for the 'dev' device? We are checking in > > tcp_sendmsg_locked that we're targeting the appropriate device before > > creating the skb. Is this about a packet arriving on a dmabuf bound to > > a device and then being forwarded through another device that doesn't > > own the mapping, bypassing the check? > > Forwarded or just redirected by nft/bpf/tc > > > > The driver doesn't seem to check the DMA mapping belongs to it either= . > > > > > > Remind me, how do we prevent the unreadable skbs from getting into th= e > > > Tx path today? > > > > I'm not sure if this is about forwarding, or if there is some other > > way for unreadable skbs to end up in the XT path that you have in > > mind. At some point in this thread[1] we had talked about preventing > > MP bound devices from being lower devices at all to side step this > > entirely but you mentioned that may not be enough, and we ended up > > sidestepping only XDP entirely. > > > > [1] https://lore.kernel.org/bpf/20240821153049.7dc983db@kernel.org/ > > Upper devices and BPF access is covered I think, by the skbuff checks. > But I think we missed adding a check in validate_xmit_skb() to protect > the xmit paths of HW|virt drivers. You can try to add a TC rule which > forwards all traffic from your devmem flow back out to the device and > see if it crashes on net-next ? No crash, but by adding debug logs I'm detecting that we're passing unreadable netmem dma-addresses to the dma_unmap_*() APIs, which is known to be unsafe. I just can't reproduce an issue because my platform has the IOMMU disabled. I guess I do need to send the hunk from validate_xmit_skb() as a fix to net and CC stable. Another thing I'm worried about is ip_forward() inserting an unreadable skb into the tx path somewhere higher up the stack which calls more code that isn't expecting unreadable skbs? Specifically worried about skb_frag_ref/unref. Does this sound like a concern as well? Or is it a similar code path to tc? -- Thanks, Mina