Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1148475rdb; Mon, 19 Feb 2024 06:01:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXOJi1n8evF9mtTdibefMlG8MMP81EXdlz7OsEQj9yzhS0NqR1/dZfQ7Z+sQ4U3eaiRyrI+go2r71qzeRBCvB1qZgibLyi56cNxj9gV2g== X-Google-Smtp-Source: AGHT+IFP655MTfJoBtlgG9glIuSmLxKnrezxsnztcBI4QwAUNM2/XVu4CckYWOvPxcWrWRRqJNnc X-Received: by 2002:a17:902:d508:b0:1db:d307:593f with SMTP id b8-20020a170902d50800b001dbd307593fmr5607893plg.3.1708351287507; Mon, 19 Feb 2024 06:01:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708351287; cv=pass; d=google.com; s=arc-20160816; b=dn3/pgre2JFRnNCf2gy4CSh/KCSO16rN90tgs4GEPkTGbzIwIcwWh1fH15ezTREAAh QYy02Q/Msom23WqvgB7cBPjAYaUQ8OLTTEtm/XQblDgHHPLeGLfcFjxmS7kq1IVHc9bo yKafPsIZV7DX8aUN8gSM2LLW4cgYfwVU7swDL216I8zijlHuqQ7eL/3nRa6oVc6GUR2d 35OBhXlNn2Qv+vZ5ZAO1YfTMt+48z+wCz00ZWwlj1O85Te5h5gJyqhWgDJvn0LyQVtXi nlyZ9XizRFk6PYV6qRA13rlr+lKnNHwP0tShnO9e8Ze1CLdT7VL87RxipjiTvK+1TISG UXEQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-filter; bh=k3BbLM+W3IY++z5FItf1PQyWOHVjGz95oS2lZDTR3f4=; fh=1UEXF8WEdTRZGz3zsBPr9blJ8rxkIELeUsA6ymhnv1o=; b=cY6CXuoCp8q/nWYvUpEIROqcZAzmYiF25cXgjsvn8cj+iHWWAsWaPq+aRKlcH8/At0 yTmn5iHJ3RygE+NNz4Ye7CyRo8VSQtfqHXxjbHW8fBAFBjE6Sn9S9mi5HIF2GM48GqyJ FefLPhAdTcZVKrYkCQzCQMrcPHE8Q8kdOSCMle2igtMwLP2nOof21nThf0bqm48IKCOn RT0uRAukLnLqQLWjj83qYQYpgMLpbjVIFAfXXVY3PFb7bYNL1vII5j1hoxTqSt5VE70m Ifa34pc8jgqiPZeizzJ8Wu3a82V39NHuez12Z+3m9Z+hbbd1wNQJOSxyNKnMJm5g46oS a4JA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@uliege.be header.s=ulg20190529 header.b=LeD7FTRu; arc=pass (i=1 spf=pass spfdomain=uliege.be dkim=pass dkdomain=uliege.be dmarc=pass fromdomain=uliege.be); spf=pass (google.com: domain of linux-kernel+bounces-71432-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71432-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=uliege.be Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u11-20020a17090282cb00b001d93b25f1c5si4346774plz.474.2024.02.19.06.01.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 06:01:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71432-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@uliege.be header.s=ulg20190529 header.b=LeD7FTRu; arc=pass (i=1 spf=pass spfdomain=uliege.be dkim=pass dkdomain=uliege.be dmarc=pass fromdomain=uliege.be); spf=pass (google.com: domain of linux-kernel+bounces-71432-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71432-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=uliege.be 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 02B2E28479B for ; Mon, 19 Feb 2024 13:53:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7536374EA; Mon, 19 Feb 2024 13:53:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=uliege.be header.i=@uliege.be header.b="LeD7FTRu" Received: from serv108.segi.ulg.ac.be (serv108.segi.ulg.ac.be [139.165.32.111]) (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 8FD2C364CC; Mon, 19 Feb 2024 13:53:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=139.165.32.111 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708350783; cv=none; b=vCYMXKDm4e06e+JlGrXHGgI1ItTSrCQsuFc/QZZbKlpXpj9UcTt8ocQZ/Cl76xNXDEmpFC7/3uqPLJIgRvYzGiHk193RskXjVz5ndE8ciCIfaDC6ybGdE7RpMiHOhcANuF03w64x7T2QJzcjiSdHDnyN+ELfb8b0Yr1Ji/hQnrY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708350783; c=relaxed/simple; bh=pSf/6yBlnsj3efx67HWLfiYU1L7RVALqEg3khS/oWgk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RiHqdCtICWRp7J87f+zf7Ni2tS7Q8Ht4ELtRhDxz2pdOVN2FhePDtU7Tu5NUIGSqB8mn7sJdhXLVOnI9qhDGSxkbEV5IK1X4t13SXwg1Aa9LmLWf77rv194np0ar6Dze68IWvcucNX5iJSuKFcBLGWQiUdcB82PXxsuV6iigNe0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uliege.be; spf=pass smtp.mailfrom=uliege.be; dkim=pass (2048-bit key) header.d=uliege.be header.i=@uliege.be header.b=LeD7FTRu; arc=none smtp.client-ip=139.165.32.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uliege.be Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uliege.be Received: from ubuntu.home (125.179-65-87.adsl-dyn.isp.belgacom.be [87.65.179.125]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by serv108.segi.ulg.ac.be (Postfix) with ESMTPSA id BBFD72012173; Mon, 19 Feb 2024 14:52:59 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 serv108.segi.ulg.ac.be BBFD72012173 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uliege.be; s=ulg20190529; t=1708350779; bh=k3BbLM+W3IY++z5FItf1PQyWOHVjGz95oS2lZDTR3f4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LeD7FTRu1UZv0Ax6scZg93ZbR/A7tXJxuEboY23KBSAQfrBM+jDp59ehXrAEnxUUu H9g6lQAGOji7i+pNJqLeHN1Lix50+M3LAgdetCDfQOBWWv7PXLGjApvcmJx4UqNFp1 cBEHDp9POX076y4L5tKQpl1PTCmBg2BkCgiD+oczKoh86wc2QKCZ+Nih2eQOO+HtQC by3IZ3OJtf6dhSdOtAEEpPssrP2FO7DVFWMwO3uAeNyfMlcjZBKJPk2H+X0u2FereO AQI2Jdh4zUScaqb9onAVI3bA6vaFIQzC30ySgu41JM++P0G+TTwCMskDrWOdBN3+3Z 9iechtlY0x5GQ== From: Justin Iurman To: netdev@vger.kernel.org Cc: davem@davemloft.net, dsahern@kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, justin.iurman@uliege.be Subject: [PATCH net v3 1/2] Fix write to cloned skb in ipv6_hop_ioam() Date: Mon, 19 Feb 2024 14:52:54 +0100 Message-Id: <20240219135255.15429-2-justin.iurman@uliege.be> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240219135255.15429-1-justin.iurman@uliege.be> References: <20240219135255.15429-1-justin.iurman@uliege.be> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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(). It also updates ip6_parse_tlv() to refresh the network header pointer ("nh") when returning from ipv6_hop_ioam(). Fixes: 9ee11f0fff20 ("ipv6: ioam: Data plane support for Pre-allocated Trace") Reported-by: Paolo Abeni Signed-off-by: Justin Iurman --- net/ipv6/exthdrs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c index 4952ae792450..02e9ffb63af1 100644 --- a/net/ipv6/exthdrs.c +++ b/net/ipv6/exthdrs.c @@ -177,6 +177,8 @@ static bool ip6_parse_tlv(bool hopbyhop, case IPV6_TLV_IOAM: if (!ipv6_hop_ioam(skb, off)) return false; + + nh = skb_network_header(skb); break; case IPV6_TLV_JUMBO: if (!ipv6_hop_jumbo(skb, off)) @@ -943,6 +945,14 @@ static bool ipv6_hop_ioam(struct sk_buff *skb, int optoff) if (!skb_valid_dst(skb)) ip6_route_input(skb); + /* About to mangle packet header */ + if (skb_ensure_writable(skb, optoff + 2 + hdr->opt_len)) + goto drop; + + /* Trace pointer may have changed */ + trace = (struct ioam6_trace_hdr *)(skb_network_header(skb) + + optoff + sizeof(*hdr)); + ioam6_fill_trace_data(skb, ns, trace, true); break; default: -- 2.34.1