From patchwork Fri Feb 16 23:43:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Iurman X-Patchwork-Id: 202432 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp57900dyc; Fri, 16 Feb 2024 15:50:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU2khqwLoc6FMNcE3NVpC7FwuRdKqoXl/kRtO/rfwn9LV7IPHWL9wXfR/R9zD2mWDbziNTQWgREy0L+s0RKqrQP31XNvQ== X-Google-Smtp-Source: AGHT+IGT3REHxUe6QmxXR0gQzsCYqdqPoXh+lBTSxLHiupC/Gnp7W8cEzDh9N7lztEKuI1fNKCiO X-Received: by 2002:a92:d94a:0:b0:363:b8fb:fcb7 with SMTP id l10-20020a92d94a000000b00363b8fbfcb7mr3511409ilq.16.1708127458182; Fri, 16 Feb 2024 15:50:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708127458; cv=pass; d=google.com; s=arc-20160816; b=d+d46IowEz5wh4iQSpvH01XAy5QgvTP5mzfgOz3M1WsI3ccz0hMdtGo49JnebyZbU3 e+h6KD3sFbaiH0fk8W/R9jjnlH3TGtr9OWPgUY+a1u5nF7lvdnnKEmUrJrYNMuPp6/kA EtjGoZWlr2mFT70wqmhDFUJ661nyhVQwW3R9OK7brTfoWGVe6sQ/kn99OJnlfB5qSh+6 wWxHg8NNf1f7nUDOOmcfbe8acdVxhfPW8J2aIHuS9dFqAX4iyfbL22AG7tXTlKyIO3BE 48IE3jDGtlbwpC8WVdCBEqKfKdBHCw5X6UOYgWZJzVvoVZfdeGbL2Bu6v1UMthRSjzOh HqHA== 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=KBT5QiCYF+jW6KQjYqqpLSpV8B1JmQ2uuG5tyIxcSu0=; fh=wKA1yLAaxZXTggjEsc7ekQegiUD1yMj/fZjOnZZQ/2U=; b=o/RAnzUXB3HxL+9aAOP+D+Z8W0eeZSWxZ1OkiY4otfVHKrL3j6lXgn04M5kpZmQ0Uf Kif0kOHsq+PBB/gUKwj1ejiXQosodS0rLPFEYpL9tuXnbGE7O7Z3Wp9y/AjhGO+n/DKw ySWHk8uxwFX8H+JF4kWhqSCn4hYnUqX+K5B8Ma1rAT80MYCGRVLoyXgEjogyEZV2PzA+ vQtbLCKmEmw0C33qCb7fMnbU+/JOaRcX1AOJdZl6KkISAOYcpAlhVwgUeQQowsPOnieL 92/m78r9kw4fsG1fuBPQwnx50/hyxc0hljMfNkiWAGZGxWqfmA87D9zUhGKcpj3qO5HB dfVw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@uliege.be header.s=ulg20190529 header.b=OBkwBK7b; 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-69491-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69491-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=uliege.be Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e22-20020a656896000000b005cf0309e41bsi566673pgt.823.2024.02.16.15.50.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 15:50:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69491-ouuuleilei=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=OBkwBK7b; 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-69491-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69491-ouuuleilei=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 00A8F2897D9 for ; Fri, 16 Feb 2024 23:50:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1079714A4E2; Fri, 16 Feb 2024 23:50:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=uliege.be header.i=@uliege.be header.b="OBkwBK7b" 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 5A884148FE9; Fri, 16 Feb 2024 23:50:12 +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=1708127414; cv=none; b=Rqp6ChPHPhltJpjksdCznJNS77TCQgspWfzFCc/Zm9tcKwdtodkuGOb4AJrHaeXMInzaz/jXHlIvhUXvEXOcZ8r8uiJCErm/QokawlohU+8BEWEWXGXQqVBuoQAGLZ5BPCgbx8XIf1hilBTozWqMi4qez4nZlHOwhAlFXTYutZo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708127414; c=relaxed/simple; bh=SUlpKvijFULBhu+onKj0KJkGrequq3NY9IlyDbpNHsc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GtORZfEeiLvzOWWl6kx+fUQ8pmWUAc+uDFOg7Bj4sfL/OeeR7p885uyXtTVDIAwmbv8mlDax+kyf65ww6gTzfMk3A9PevqTgsCemy9tzIpofNawIaHWBlC/ReA93j1eBtBW5NRrMNJuBtm2wLgRXpmEOAhGjaQGax22qyc50jVs= 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=OBkwBK7b; 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 localhost.localdomain (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 86162200C99A; Sat, 17 Feb 2024 00:44:26 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 serv108.segi.ulg.ac.be 86162200C99A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uliege.be; s=ulg20190529; t=1708127066; bh=KBT5QiCYF+jW6KQjYqqpLSpV8B1JmQ2uuG5tyIxcSu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OBkwBK7bv651mHZOpD6QhZyzeYarcjkiZici4n8srVvFYAlZfKsBwVFHYnAPWOi8m a7YleW/tQUHWUSaNLLBqNq0JIO0CjGV802Za7FmmlyDmOvIc0waX08uefRzPAirUNs /ctZQi7LcszxAHJaaBfWHyX2OG0Lx4xjLtYvoqeSPYK6fh7celuenNDoc/GXyOr/Oi ZmDSKM1ozAuxeTMHKaavo36EICuh4nlR0tI9q0EcZ+7Q3H5qrM8VQD8sHLiTZCXrWK TyKGQA5EVMjm5PtXFce6IreT3NxvygjvuBrWA3vHk9GC5uqBeoCdI1rfNsi/HiEZ0a O2aiS7FdFH2xg== From: Justin Iurman To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, justin.iurman@uliege.be Subject: [PATCH net 1/2] ioam6: fix write to cloned skb in ipv6_hop_ioam() Date: Sat, 17 Feb 2024 00:43:55 +0100 Message-Id: <20240216234356.32243-2-justin.iurman@uliege.be> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216234356.32243-1-justin.iurman@uliege.be> References: <20240216234356.32243-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791101457473459294 X-GMAIL-MSGID: 1791101457473459294 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(). Fixes: 9ee11f0fff20 ("ipv6: ioam: Data plane support for Pre-allocated Trace ") Reported-by: Paolo Abeni Signed-off-by: Justin Iurman --- net/ipv6/exthdrs.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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 optoff) if (!skb_valid_dst(skb)) ip6_route_input(skb); + if (skb_cloned(skb)) { + if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) + goto drop; + + hdr = (struct ioam6_hdr *)(skb_network_header(skb) + optoff); + trace = (struct ioam6_trace_hdr *)((u8 *)hdr + sizeof(*hdr)); + } + ioam6_fill_trace_data(skb, ns, trace, true); break; default: