Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp717133imm; Thu, 13 Sep 2018 06:45:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZD5CMAQlOxTRe7itLmMLnGk3XaDO7juH2yFBD7ZA2sbqwHlNOVL6ih6WxDIeZUSMLFF4xA X-Received: by 2002:a63:7a0f:: with SMTP id v15-v6mr7434554pgc.127.1536846343916; Thu, 13 Sep 2018 06:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536846343; cv=none; d=google.com; s=arc-20160816; b=RbHhMjIyfmUHgE8MhByyOj4cL9fxNx6u9iHI1YBYiAhzHC4yEhSF310HuCZpNUq1Ud PrIcshWCBbMMi0ODU+sBCaLFskQY8KhKg7T/mx2iS0g/yQTCpUd2Sc1E5ImTlkjlqKAB 8Si3urGiLsUqF6S6IIEyhaM/hHgAVmAbCCdKOKdo85NydsEbubnwAwjD45OYX9iTCsMF UoXRc4CdhCqxScbDzvjgxpKBuNLgtU2NtfAAk98ZXTpWB9AYlP9/vELL4kOUDiZrP8dR U2Z0cxl15iQh4Y0A2WbicGSd/xHZxoa0vD52yZ/GUdiDOcUGcC2danuV15y9XQjrLXCA CNZQ== 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; bh=pmwKiRrwGLGSa6RR9jfkWLaHapBCTLug+JAy6/VOioc=; b=noVFCYi6m51I4V/8+nHDgegD8oW3/43d4qaBAtMB2pXWEhscKS47H00J9BCsP9WDuY LD2llBE2JEmKi1gtAqTJhAN136rz2SfREvqcDDpj+NefDOMpFp4seT/EyAe/YxKaUki6 xLvNIdrng5IkIgvdGeFhvGGDsJUgaiPpR/4bCrY+ieatQ8ELPgmMxcKbFsEO1jBJZEgh z/4Px5/SlcqgWX3gHrNNMzfXv0On4vJkVW5EMOqDTSkH5i/OD8/ppPeoC9DmHPttYjgi fG9w/bWn3umG0wspQdEZW/TiwPuXQX65IHGkBuTMR6rJBwIfth5QGI4eNaNd72CgLyuz AQQQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t23-v6si3486055pgk.26.2018.09.13.06.45.27; Thu, 13 Sep 2018 06:45:43 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729960AbeIMSxh (ORCPT + 99 others); Thu, 13 Sep 2018 14:53:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60456 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728132AbeIMSxg (ORCPT ); Thu, 13 Sep 2018 14:53:36 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6D2BCD10; Thu, 13 Sep 2018 13:44:03 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Borkmann , John Fastabend , Song Liu , Alexei Starovoitov , Sasha Levin Subject: [PATCH 4.14 044/115] tcp, ulp: add alias for all ulp modules Date: Thu, 13 Sep 2018 15:31:04 +0200 Message-Id: <20180913131826.395398578@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131823.327472833@linuxfoundation.org> References: <20180913131823.327472833@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Daniel Borkmann [ Upstream commit 037b0b86ecf5646f8eae777d8b52ff8b401692ec ] Lets not turn the TCP ULP lookup into an arbitrary module loader as we only intend to load ULP modules through this mechanism, not other unrelated kernel modules: [root@bar]# cat foo.c #include #include #include #include int main(void) { int sock = socket(PF_INET, SOCK_STREAM, 0); setsockopt(sock, IPPROTO_TCP, TCP_ULP, "sctp", sizeof("sctp")); return 0; } [root@bar]# gcc foo.c -O2 -Wall [root@bar]# lsmod | grep sctp [root@bar]# ./a.out [root@bar]# lsmod | grep sctp sctp 1077248 4 libcrc32c 16384 3 nf_conntrack,nf_nat,sctp [root@bar]# Fix it by adding module alias to TCP ULP modules, so probing module via request_module() will be limited to tcp-ulp-[name]. The existing modules like kTLS will load fine given tcp-ulp-tls alias, but others will fail to load: [root@bar]# lsmod | grep sctp [root@bar]# ./a.out [root@bar]# lsmod | grep sctp [root@bar]# Sockmap is not affected from this since it's either built-in or not. Fixes: 734942cc4ea6 ("tcp: ULP infrastructure") Signed-off-by: Daniel Borkmann Acked-by: John Fastabend Acked-by: Song Liu Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- include/net/tcp.h | 4 ++++ net/ipv4/tcp_ulp.c | 2 +- net/tls/tls_main.c | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -2063,6 +2063,10 @@ int tcp_set_ulp(struct sock *sk, const c void tcp_get_available_ulp(char *buf, size_t len); void tcp_cleanup_ulp(struct sock *sk); +#define MODULE_ALIAS_TCP_ULP(name) \ + __MODULE_INFO(alias, alias_userspace, name); \ + __MODULE_INFO(alias, alias_tcp_ulp, "tcp-ulp-" name) + /* Call BPF_SOCK_OPS program that returns an int. If the return value * is < 0, then the BPF op failed (for example if the loaded BPF * program does not support the chosen operation or there is no BPF --- a/net/ipv4/tcp_ulp.c +++ b/net/ipv4/tcp_ulp.c @@ -39,7 +39,7 @@ static const struct tcp_ulp_ops *__tcp_u #ifdef CONFIG_MODULES if (!ulp && capable(CAP_NET_ADMIN)) { rcu_read_unlock(); - request_module("%s", name); + request_module("tcp-ulp-%s", name); rcu_read_lock(); ulp = tcp_ulp_find(name); } --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -44,6 +44,7 @@ MODULE_AUTHOR("Mellanox Technologies"); MODULE_DESCRIPTION("Transport Layer Security Support"); MODULE_LICENSE("Dual BSD/GPL"); +MODULE_ALIAS_TCP_ULP("tls"); static struct proto tls_base_prot; static struct proto tls_sw_prot;