Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2281132ybc; Wed, 13 Nov 2019 11:49:12 -0800 (PST) X-Google-Smtp-Source: APXvYqwI7oaj7OfqDgiB4pFa7Xam0MmDBKj+kk6cYFGO4r32YIX80g3nIAoamaB7ObO2ymUr1EAq X-Received: by 2002:a50:970e:: with SMTP id c14mr5693812edb.20.1573674552215; Wed, 13 Nov 2019 11:49:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573674552; cv=none; d=google.com; s=arc-20160816; b=btlPukirnJ8NusU73U01EFGm/Z9fVIkh9pdaKBqxnE5QcOKmkizfpFTYmKUm73FXQP VF2sobdPTL/ouuCa551oQ2bFK4wN7IHa5m7gT1yTvngoKY5v8LTDaGWdxCdlholzopmw bs5VW8ij5TIXhP2h20v2nWCJeI92gpbOOXkfGZrLFs4JlFbGg96EOR5AIb0fSYvA0Yqx aFAsdrz0swYC83Q559mApNn7/W6uczkku2B0icBz5gBtNq2hz6tySDl2Erysq2W0bT0o 5PurRM7/E7I/0s75jrRj0RP0pfU9fGyOzsuJ0jkGhtU4KyZcHC2frKwS56sZKLaT5okM Yl+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=mbbQ8szWzQDo95ZAUbmHRcCCPL8eyU27djnd3ud3GOM=; b=iz87wrWG58ESu5QnTxcF/8eNk1kQ2euVZjpfhQGmfnzrKE9VOBJDZ1fUTUd7xq0B7u sEKrANYLV13W41Tfl2MaGvJ60M4+fRXl9F9pLOIycNRElkb4ZWEl8nttZG4PQrqL5mOJ pMxKD8XNo1MqdfZWCsT9b24MhYlCQ4CiSqqtC6k0TksRMRKQ/w1nbjPBmAUusvC6u8VH Zwmz61ATUMYtZJixoNcw8gdFdZhIQStVi0z85/I11iZPG+oWwX0cmWuso7d9oiBJ+IbE vlrTbR+RDYLnqDglIGSa2Uf36qjizW0j/9p+4rcVwWqz27VeNJo0xrom6g4wmWj0stFA VhBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=uniroma2.it Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e48si2400400ede.207.2019.11.13.11.48.48; Wed, 13 Nov 2019 11:49:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=uniroma2.it Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726980AbfKMTsG (ORCPT + 99 others); Wed, 13 Nov 2019 14:48:06 -0500 Received: from smtp.uniroma2.it ([160.80.6.16]:57695 "EHLO smtp.uniroma2.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbfKMTsF (ORCPT ); Wed, 13 Nov 2019 14:48:05 -0500 X-Greylist: delayed 1019 seconds by postgrey-1.27 at vger.kernel.org; Wed, 13 Nov 2019 14:47:58 EST Received: from localhost.localdomain ([160.80.103.126]) by smtp-2015.uniroma2.it (8.14.4/8.14.4/Debian-8) with ESMTP id xADJTiml023525 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 13 Nov 2019 20:30:27 +0100 From: Andrea Mayer To: "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , David Lebrun , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andrea Mayer Subject: [net-next, 1/3] seg6: verify srh pointer in get_srh() Date: Wed, 13 Nov 2019 20:29:10 +0100 Message-Id: <20191113192912.17546-2-andrea.mayer@uniroma2.it> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191113192912.17546-1-andrea.mayer@uniroma2.it> References: <20191113192912.17546-1-andrea.mayer@uniroma2.it> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.100.0 at smtp-2015 X-Virus-Status: Clean Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pskb_may_pull may change pointers in header. For this reason, it is mandatory to reload any pointer that points into skb header. Signed-off-by: Andrea Mayer --- net/ipv6/seg6_local.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c index 9d4f75e0d33a..e187dec2eed1 100644 --- a/net/ipv6/seg6_local.c +++ b/net/ipv6/seg6_local.c @@ -75,12 +75,16 @@ static struct ipv6_sr_hdr *get_srh(struct sk_buff *skb) return NULL; srh = (struct ipv6_sr_hdr *)(skb->data + srhoff); - len = (srh->hdrlen + 1) << 3; if (!pskb_may_pull(skb, srhoff + len)) return NULL; + /* note that pskb_may_pull may change pointers in header; + * for this reason it is necessary to reload them when needed. + */ + srh = (struct ipv6_sr_hdr *)(skb->data + srhoff); + if (!seg6_validate_srh(srh, len)) return NULL; -- 2.20.1