Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1016613rdb; Mon, 19 Feb 2024 01:06:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUf7P5PTXCtTI73YQdFflnFNc7+EzJVccB9C8dSEMbNIRUozKdl89BhstmyrveE2j18zsd0n5DMuOqT4BcEsdlWJZrnjjUOaSyjDTTZmQ== X-Google-Smtp-Source: AGHT+IEmk99TyNyv8PcxLMtQnW9k/xUltLHsbeLAJv2EixSRU9fgpOkHA9ENQtNmlbsNOy2+AamQ X-Received: by 2002:a17:90a:2d8b:b0:299:147f:e915 with SMTP id p11-20020a17090a2d8b00b00299147fe915mr8967282pjd.9.1708333602272; Mon, 19 Feb 2024 01:06:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708333602; cv=pass; d=google.com; s=arc-20160816; b=p2scqMh7OCeQ/wPC+IzcAHe1h8lVVQNQHYJ52qmFD8G9if2/OR2MFKMl80EQk9oWyF 7omR9f8TrSiuV1rxGN9DB8IVAxcYzMRWWL+Yfcp7hs6vRBvWzZblGRxI0uQTJYgpGsDs WlnV6r12yB+uEXDEDDl+Oq43E2HH+NNrIa/gyY8nTjXHDsB91fOfzH2SQNoSHy9zwHk2 ApbQrZjJ739jTRdoKDqmNq8XmjoPsUckNIH8Ox4TkTUsN9o8GDufgmoocfi3SK4/MrYI 8Nd3xWWKDi4PTM/qB3QlpL68dPigESjt0UmPyZ9yq6gfLeP4KsTbLmjrUmnkZMUJpxYl HcEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:autocrypt:references :in-reply-to:date:cc:to:from:subject:message-id:dkim-signature; bh=mvmiQ9Kd1nkve/0Looqf6/3ALADHPkqVvnShGJp77EI=; fh=bXtApvwpPavRnKI7FX1hUSBLh9IQOUtqwpaw4umfGck=; b=ijXqPa00VldW5BriSUpEYmPGSLNTloWGE1smtQ0iGrRm9EEzgADeWZyINc6bHPQNfQ QQAnBvse1PmnayLHlFUISZQgs015siwXg5G8dszYQCA6dyHkY1hkY5QXTeyPY3NtcX5G Dq/ZlSl8wMruSFINBwYihGghABeslt1wlh54lLK3BbEACcJp9f+x8JsSs98FpSEfDo5D 8dtdv0q38ZKcbxIZOsn7ei/rTluTsolPh8Z57diQiwi+Q2/WxDR0XJhSDjiw5MR+lCg+ JqVWnwxymcezkToRuAS5+qIu52uXg3FGIq7PbUR5lLLBeZeYLdpqc6myOUAYcugRIsYI OiXg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Umo7MM+1; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-70995-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70995-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id ot8-20020a17090b3b4800b00299734a4506si2793823pjb.132.2024.02.19.01.06.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 01:06:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70995-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Umo7MM+1; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-70995-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70995-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 EE173B21877 for ; Mon, 19 Feb 2024 09:05:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE8D022EF7; Mon, 19 Feb 2024 09:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Umo7MM+1" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 19B3322618 for ; Mon, 19 Feb 2024 09:05:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708333512; cv=none; b=Ni+x7Lcfo1vVP5gu+xrJONhN280dRgygXte2rvMe3yo9z4fnd2/4XNR6fI63KVqX2PWWJlGXOKupiB7vZZo6XFJbL8U88m8O81/ylAn7ORV/uKNjj6S52vQ7zYLtieFmbpfJT/jOqEYa5k/jV3bvyc67BDTdTaSepJnwFdMK/J0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708333512; c=relaxed/simple; bh=eQbzK6udwGnvj1Xh5Im+mUok/MbiejLYuLtoqIi3BAA=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=uXjOrPamlgNq+UugnenrGQNH9lDnC/gqew46I/03IRAg5M3F7s4guGaJH3Bebs322nGVwlL7fcXbN2DOnYeR2SZnKJt0H372zSYx+0Ec2jq2O28lprHyI2D1e8ccVintdVvChHHynjCJMqQtkbOhbaNNdIYthtAn4PeMXYR9g+s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Umo7MM+1; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708333510; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=mvmiQ9Kd1nkve/0Looqf6/3ALADHPkqVvnShGJp77EI=; b=Umo7MM+1R9YaEygYEdxsxxaceu2Dfu4URk1UPbEPQXTQ20IstuYEjfnnCDfTYbWO3fQ1iV zpnYZkhJSTD56nrC68paGfPoKr8fFyeMwwdzlsAExsE9CYZvRvlBTQv4Cpno3l4m/kt1za E2hzqKkT29godyY/OyZqkdnHjier9/M= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-505-fPB08JqFP-S7eD72Ch1DCQ-1; Mon, 19 Feb 2024 04:05:07 -0500 X-MC-Unique: fPB08JqFP-S7eD72Ch1DCQ-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-33d1896e0d5so242987f8f.1 for ; Mon, 19 Feb 2024 01:05:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708333505; x=1708938305; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mvmiQ9Kd1nkve/0Looqf6/3ALADHPkqVvnShGJp77EI=; b=Se3enFgZkWHaS7Z7ph0zP4vrGT82vtUKMwnM67NE1wMebR3RmH1SG7BIOVtDB3ftBK S4cjM640zGalCmWY28+mBZWAcV8mV6WaZEQXYC0PwKPWcXUs1inzEMpPGrAf36yREP3r yaH81imEDou66TUnnYXehykelqavtOfwOqJcx6lyDX1gYN9BZJRIan8R1HTjbNI/xDR2 6uIgNFp0ZpbrweEZ89SDARRNy5/crfZAoQBBYudj/ZM421DK8qwv74H7GT9ntfALlaT8 6i5paa5mIJudjJ2izyzS5LYC4DCwTTJCA7cqas4VK78qjThHY6X5JB6vFnutEjN4QjoH B8AQ== X-Forwarded-Encrypted: i=1; AJvYcCVxHKzzzt0VvjuX2OLFzgmkWtCXfS3vn/GVNsPOppKVkqnsX6jOAc9Rl1t6JVF0HlYfCoOn4zZSUIu6S0ENu+0x7S3IvoiitegRvXsN X-Gm-Message-State: AOJu0YxDzostcxjTIF8SGuctIZRBEyVQoSoh/SkZ7SVi64Izr9jbWaa9 KfIttgolXhZiz/8HIhckOuhFFwcfwUAyLn/rCoxD1KnnmI+iowHkCqDY/EgvGxeFOq72bmpx+ob 2QuUB7aentQJLtxuAUN1Z3ORkqQNS418H/jFmoPXGXUZTXd+gqNfTE7S4QKpIGtVgb7aZVg== X-Received: by 2002:a5d:5a90:0:b0:33d:4921:6a6c with SMTP id bp16-20020a5d5a90000000b0033d49216a6cmr1928585wrb.1.1708333505759; Mon, 19 Feb 2024 01:05:05 -0800 (PST) X-Received: by 2002:a5d:5a90:0:b0:33d:4921:6a6c with SMTP id bp16-20020a5d5a90000000b0033d49216a6cmr1928565wrb.1.1708333505400; Mon, 19 Feb 2024 01:05:05 -0800 (PST) Received: from gerbillo.redhat.com (146-241-227-135.dyn.eolo.it. [146.241.227.135]) by smtp.gmail.com with ESMTPSA id c5-20020adfe705000000b0033b8305ffe2sm9703340wrm.87.2024.02.19.01.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 01:05:05 -0800 (PST) Message-ID: Subject: Re: [PATCH net 1/2] ioam6: fix write to cloned skb in ipv6_hop_ioam() From: Paolo Abeni To: Justin Iurman , netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 19 Feb 2024 10:05:03 +0100 In-Reply-To: <20240216234356.32243-2-justin.iurman@uliege.be> References: <20240216234356.32243-1-justin.iurman@uliege.be> <20240216234356.32243-2-justin.iurman@uliege.be> Autocrypt: addr=pabeni@redhat.com; prefer-encrypt=mutual; keydata=mQINBGISiDUBEAC5uMdJicjm3ZlWQJG4u2EU1EhWUSx8IZLUTmEE8zmjPJFSYDcjtfGcbzLPb63BvX7FADmTOkO7gwtDgm501XnQaZgBUnCOUT8qv5MkKsFH20h1XJyqjPeGM55YFAXc+a4WD0YyO5M0+KhDeRLoildeRna1ey944VlZ6Inf67zMYw9vfE5XozBtytFIrRyGEWkQwkjaYhr1cGM8ia24QQVQid3P7SPkR78kJmrT32sGk+TdR4YnZzBvVaojX4AroZrrAQVdOLQWR+w4w1mONfJvahNdjq73tKv51nIpu4SAC1Zmnm3x4u9r22mbMDr0uWqDqwhsvkanYmn4umDKc1ZkBnDIbbumd40x9CKgG6ogVlLYeJa9WyfVMOHDF6f0wRjFjxVoPO6p/ZDkuEa67KCpJnXNYipLJ3MYhdKWBZw0xc3LKiKc+nMfQlo76T/qHMDfRMaMhk+L8gWc3ZlRQFG0/Pd1pdQEiRuvfM5DUXDo/YOZLV0NfRFU9SmtIPhbdm9cV8Hf8mUwubihi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kmSxN1nABoutHEO/N87fpIbpbZaIdinF7b9srwUvDOKsywfs5HMiUZhLKoZzCcU/AEFjQsPTATACGsWf3JYPnWxL9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.3 (3.50.3-1.fc39) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Sat, 2024-02-17 at 00:43 +0100, Justin Iurman wrote: > ioam6_fill_trace_data() writes inside the skb payload without ensuring > it's writeable (e.g., not cloned). This function is called both from the > input and output path. The output path (ioam6_iptunnel) already does the > check. This commit provides a fix for the input path, inside > ipv6_hop_ioam(). >=20 > Fixes: 9ee11f0fff20 ("ipv6: ioam: Data plane support for Pre-allocated Tr= ace ") > Reported-by: Paolo Abeni > Signed-off-by: Justin Iurman > --- > net/ipv6/exthdrs.c | 8 ++++++++ > 1 file changed, 8 insertions(+) >=20 > diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c > index 4952ae792450..f68e5faab3aa 100644 > --- a/net/ipv6/exthdrs.c > +++ b/net/ipv6/exthdrs.c > @@ -943,6 +943,14 @@ static bool ipv6_hop_ioam(struct sk_buff *skb, int o= ptoff) > if (!skb_valid_dst(skb)) > ip6_route_input(skb); > =20 > + if (skb_cloned(skb)) { > + if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) > + goto drop; My personal preference would be for using skb_ensure_writable() here, with write_len =3D=3D optoff + hdr->opt_len. > + > + hdr =3D (struct ioam6_hdr *)(skb_network_header(skb) + optoff); > + trace =3D (struct ioam6_trace_hdr *)((u8 *)hdr + sizeof(*hdr)); Note that this can potentially change the network header ptr and the caller - ip6_parse_tlv() - has cached such value in 'nh'. You also need to update ip6_parse_tlv() to reload such pointer. Side note: a bunch of self-tests are apparently stuck after this series. I think it's an unrelated problem. I'll try to have a better look. Cheers, Paolo