Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4830659ybl; Wed, 22 Jan 2020 05:32:25 -0800 (PST) X-Google-Smtp-Source: APXvYqx5hGADEVR3kNgk+yAEHTiSep+WQkzn61shFvT9TPCIV+n8hFb3KN+NEBbxV970slfdvnaa X-Received: by 2002:aca:b183:: with SMTP id a125mr7030179oif.83.1579699945762; Wed, 22 Jan 2020 05:32:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579699945; cv=none; d=google.com; s=arc-20160816; b=UHb9DN5SKqoMhabCrAydbk82+k54oyme4OzSYkvW9wnFDX2MDdBLdbuUiBav+adEwG q7WWsqNf2g1ETOp2YfAxELTeOu/6SjlHdBHp501j3BieisnoYW7ymptlT8A2uJu9lRwy VUaPPQ22Q98Hoh6ygDqBEgw6UIGojwRzeqTniCq0ImzDKLU19/l91/AZ7AQpZjvi7lzY r3F7K+w/F71p7EEgdC9c/eLubYZdcq9z38smLnAXgs5L9wxGquRFS5ht9bwachzTCZyd GXZ6iJiP9KNfNYVESs46C9hFMlaXAj8E1TfvZhoV5XAnfaU+l4dBgQfa8qYb8BYHo0Q2 9rdw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=C34++A/aqsyCtsPitundbf5hxJb0+0AfqztH0mohvqg=; b=mW8HSVtpn/EBbKdSKiYFvSBNYdR/Lte/q1UMsFRSu4xyh2RAzzlS6hIw0NKvSRQcZc WDbYcQD4GnVJRD/7GMwQb5d1CecpGjUAfM3GmsDUONTtk4TfaSVq9hfRjxTgBu+xzN0d 2zWVNGEmAMEGeBMHP0exnPQjxob8PRB+kSUTZ+abQ1mx1Ule68S0Vt3dpU1pVSV0Glra IXU6Sas9C/iD5JIaTMLWAK+h3IyoaN8AW53PsxsY0nZIg8N9ogHEvJALKkQdBNaQW2VP wp3mYAdssmAoHHNHYIqygcUaszFs7KPdq+DmTCp7Yo5/6pF+U92oPWym/Wq+7dikeZ/F nvCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tPB9QzYv; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j24si23380211otn.110.2020.01.22.05.32.08; Wed, 22 Jan 2020 05:32:25 -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; dkim=pass header.i=@kernel.org header.s=default header.b=tPB9QzYv; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729864AbgAVNYQ (ORCPT + 99 others); Wed, 22 Jan 2020 08:24:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:43018 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729184AbgAVNYN (ORCPT ); Wed, 22 Jan 2020 08:24:13 -0500 Received: from localhost (unknown [84.241.205.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 272B82467B; Wed, 22 Jan 2020 13:24:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699452; bh=CieECoi7YdqBWSVo5QJb+cYgFiEPq497RWDxtyjRnGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tPB9QzYvrO22zcV/h5o5/xhV4yFvt/RVYJfuDChUjB0DqFAe27JnjH23E3CYHOEAR +nN+jcmI9kqq/yEs15VlVbajvpKn2aySelJsAmqSR5ssPTpycRyXoi1UEqyNLv+dmH dVcBP9SrHWLqSaET2kJZFc2yzt6H4ZWc/Y0WMUc8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Fastabend , Daniel Borkmann , Jonathan Lemon Subject: [PATCH 5.4 114/222] bpf: Sockmap/tls, skmsg can have wrapped skmsg that needs extra chaining Date: Wed, 22 Jan 2020 10:28:20 +0100 Message-Id: <20200122092841.894240359@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Fastabend commit 9aaaa56845a06aeabdd597cbe19492dc01f281ec upstream. Its possible through a set of push, pop, apply helper calls to construct a skmsg, which is just a ring of scatterlist elements, with the start value larger than the end value. For example, end start |_0_|_1_| ... |_n_|_n+1_| Where end points at 1 and start points and n so that valid elements is the set {n, n+1, 0, 1}. Currently, because we don't build the correct chain only {n, n+1} will be sent. This adds a check and sg_chain call to correctly submit the above to the crypto and tls send path. Fixes: d3b18ad31f93d ("tls: add bpf support to sk_msg handling") Signed-off-by: John Fastabend Signed-off-by: Daniel Borkmann Acked-by: Jonathan Lemon Cc: stable@vger.kernel.org Link: https://lore.kernel.org/bpf/20200111061206.8028-8-john.fastabend@gmail.com Signed-off-by: Greg Kroah-Hartman --- net/tls/tls_sw.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -724,6 +724,12 @@ static int tls_push_record(struct sock * sg_mark_end(sk_msg_elem(msg_pl, i)); } + if (msg_pl->sg.end < msg_pl->sg.start) { + sg_chain(&msg_pl->sg.data[msg_pl->sg.start], + MAX_SKB_FRAGS - msg_pl->sg.start + 1, + msg_pl->sg.data); + } + i = msg_pl->sg.start; sg_chain(rec->sg_aead_in, 2, &msg_pl->sg.data[i]);