Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1419751rdb; Fri, 16 Feb 2024 15:50:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUQZ4WmqUMyvG/aoKjVe0Nnac0pujh4guu26+3U1qUZXEK2TwX2iCPAWFxH1ip7U4iTMWY1AudCJnBxhc7WSS0tLN+4aI/jjDcCc4cRuA== X-Google-Smtp-Source: AGHT+IHx45sQpIRDCRrUSm3cuGVm2BKHbYtW8zN0Hpm+upHGAMdIhHvy7QpOfWQfr6ndMLTwj7ZL X-Received: by 2002:a17:90a:8a0d:b0:299:d17:a992 with SMTP id w13-20020a17090a8a0d00b002990d17a992mr5373848pjn.25.1708127433094; Fri, 16 Feb 2024 15:50:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708127433; cv=pass; d=google.com; s=arc-20160816; b=dF8zSjTo8vtw5Q6ZU7oNt3Dwf/UoXCBT1zCmTqIRUPeZ2cTrck8Vd93b1JGIGzWC/u 10n5LjxoIllYBbCtBVxu9ttaIDZdhjb6NwFZqufw1sBP7e+Pb5UP0HRV0RZJSj6e/Era pdWXld6R/GK61VjbrX2ZWydhIVhcVOddpPH05H9gLiRpoj/JXe2f9ToZgbe6f5rgl9BW iorOLX0k+pmKNxe3GVNgQyLAkehr4JS9I27burB3S1KjlLSP8HT7gqtbr/2NAdlHkTWw eYoNFlJs1Br4AF+aVSb1KQlMXMvQqVVDhZIeroOF0Gbm8YCKLsft/tHPOYEmNJdYdTvr 9gJA== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69491-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 fs13-20020a17090af28d00b0029899e1d6d9si685378pjb.58.2024.02.16.15.50.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 15:50:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69491-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=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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69491-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 C7CD12896F8 for ; Fri, 16 Feb 2024 23:50:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A68414A093; Fri, 16 Feb 2024 23:50:15 +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 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(). 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: -- 2.34.1