Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp732884imm; Thu, 13 Sep 2018 07:00:18 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY8dMSbas3/O+GFQJJHN1OdQqOFNA1VEWuxfJi7FWEcDDMPU2X9Ag56RI3LAKLCkEg1LJR+ X-Received: by 2002:aa7:800f:: with SMTP id j15-v6mr7685710pfi.174.1536847218211; Thu, 13 Sep 2018 07:00:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536847218; cv=none; d=google.com; s=arc-20160816; b=WdD6d5Q6XSAqEikTSPgXPDXEaOikK3e175RJAsBgkyLwQkOWyT2LIP92bXe1LSCVrd ijtnSg7gxB08nuJGNfK0uxfII15+fbi/Z3hZWJv/lJxI4/PPeMhiE0YBeP2kZb8HQzUV krPOE6FZVwm7hLrXImL0KL4Yn7njhLQVnj+XTM6FRMC7DeOild0+GReqmSabpek9wYaE vM0eYv/NKMqGL5bJa65wcYKl9Mmq8bnHg0/LckLC4u9EzeMlUEaPjQErKr6ATPyyPovj Q4tjX5qcNyqA1SlkMEb0GIT3Lb/ACAEZNLRBZn4v03eEDXnmP28aKbjn085wf8G+Zy12 NrNg== 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=eWMJeBrBsZJqqz99ipxE353uJKUXVWlWFoXDFlxQV4c=; b=0TZgSffUN9NSowKvf8xZNF/v+2UcCjVb3tje6AxFDIpF/uOplZylNPwzmqQ/TChfPx 5Pd1pZ1ILSmpX0SqL9fk6iNQlO4CRuNpEvEDvfTVEbw/psVTdlK5Fjo7KSThU/UMJ3ww 0t9dMDCza09nu607tMkedG+BwcM7pjxu6MUgYi704ATVP0EEchBpgmShxHz7/lRz7W3W nm1w7rH/ebOnXwsQeR7E1eb60xe7TJRuxjGCe5WYHRvWhCkcY5AHPRsOvMfbWfpoPw/2 sweJuQo8Yp3S1jC3FETvufKWHMN3EFIXhbi+1LsVKg+/u8NiwhOEHhvdYBnNZPBqbT2e hbkA== 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 m1-v6si3800819plb.348.2018.09.13.07.00.02; Thu, 13 Sep 2018 07:00:18 -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 S1731567AbeIMTIS (ORCPT + 99 others); Thu, 13 Sep 2018 15:08:18 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34658 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728566AbeIMTIS (ORCPT ); Thu, 13 Sep 2018 15:08:18 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3A27ED15; Thu, 13 Sep 2018 13:58:40 +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.18 076/197] tcp, ulp: add alias for all ulp modules Date: Thu, 13 Sep 2018 15:30:25 +0200 Message-Id: <20180913131844.568035775@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@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.18-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 @@ -2023,6 +2023,10 @@ int tcp_set_ulp_id(struct sock *sk, cons 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 @@ -51,7 +51,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 @@ -45,6 +45,7 @@ MODULE_AUTHOR("Mellanox Technologies"); MODULE_DESCRIPTION("Transport Layer Security Support"); MODULE_LICENSE("Dual BSD/GPL"); +MODULE_ALIAS_TCP_ULP("tls"); enum { TLSV4,