From patchwork Thu May 21 17:46:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218779 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A0BAC433DF for ; Thu, 21 May 2020 17:50:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A05E20759 for ; Thu, 21 May 2020 17:50:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="H0f9X8jq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730305AbgEURu2 (ORCPT ); Thu, 21 May 2020 13:50:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729163AbgEURrs (ORCPT ); Thu, 21 May 2020 13:47:48 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1370EC061A0E; Thu, 21 May 2020 10:47:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=SJ+Ph6rC+YitHvOexDFQbdPJO37rQFZR+I4PuJi52Yo=; b=H0f9X8jq4vOBnfRh4Um8Yr83tI BKBr3FtbdP1bG86iCyZTdXArHKEn6+ftfcSt1oZsgAFsuSfuIfqND8jOAC1JOzFcWqOgosbi0ixNo 5u8PJewel2hPgAH+cBwuASIHqbc4Vd6DpgJ5ZGqVhsGRm2ci1H23GAUUe9jVDsLT0qU2hdRtrQYFJ JOFTsarYrOys7ND7a/pt45XcSzd5jWbLpxoabt8s6iLGmvbJozR1JUH2z2vXH2q5m6QmHYreaUCXe 2SQUWQ162t3XCR+kRnirIyIU2W/vPG4WF9giJhHF7gTFECgczEW931Zf4PhhOZCC4PxMV7ikrI4bd IdnoVHdg==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpI8-0002wm-9F; Thu, 21 May 2020 17:47:36 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 03/49] sctp: pass a kernel pointer to __sctp_setsockopt_connectx Date: Thu, 21 May 2020 19:46:38 +0200 Message-Id: <20200521174724.2635475-4-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 50 ++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index eb08e44c0c57a..f7621ea99340e 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -1282,36 +1282,29 @@ static int __sctp_connect(struct sock *sk, struct sockaddr *kaddrs, * it. * * sk The sk of the socket - * addrs The pointer to the addresses in user land + * addrs The pointer to the addresses * addrssize Size of the addrs buffer * * Returns >=0 if ok, <0 errno code on error. */ -static int __sctp_setsockopt_connectx(struct sock *sk, - struct sockaddr __user *addrs, - int addrs_size, - sctp_assoc_t *assoc_id) +static int __sctp_setsockopt_connectx(struct sock *sk, struct sockaddr *kaddrs, + int addrs_size, sctp_assoc_t *assoc_id) { - struct sockaddr *kaddrs; int err = 0, flags = 0; pr_debug("%s: sk:%p addrs:%p addrs_size:%d\n", - __func__, sk, addrs, addrs_size); + __func__, sk, kaddrs, addrs_size); /* make sure the 1st addr's sa_family is accessible later */ if (unlikely(addrs_size < sizeof(sa_family_t))) return -EINVAL; - kaddrs = memdup_user(addrs, addrs_size); - if (IS_ERR(kaddrs)) - return PTR_ERR(kaddrs); - /* Allow security module to validate connectx addresses. */ err = security_sctp_bind_connect(sk, SCTP_SOCKOPT_CONNECTX, (struct sockaddr *)kaddrs, addrs_size); if (err) - goto out_free; + return err; /* in-kernel sockets don't generally have a file allocated to them * if all they do is call sock_create_kern(). @@ -1319,12 +1312,7 @@ static int __sctp_setsockopt_connectx(struct sock *sk, if (sk->sk_socket->file) flags = sk->sk_socket->file->f_flags; - err = __sctp_connect(sk, kaddrs, addrs_size, flags, assoc_id); - -out_free: - kfree(kaddrs); - - return err; + return __sctp_connect(sk, kaddrs, addrs_size, flags, assoc_id); } /* @@ -1332,10 +1320,10 @@ static int __sctp_setsockopt_connectx(struct sock *sk, * to the option that doesn't provide association id. */ static int sctp_setsockopt_connectx_old(struct sock *sk, - struct sockaddr __user *addrs, + struct sockaddr *kaddrs, int addrs_size) { - return __sctp_setsockopt_connectx(sk, addrs, addrs_size, NULL); + return __sctp_setsockopt_connectx(sk, kaddrs, addrs_size, NULL); } /* @@ -1345,13 +1333,13 @@ static int sctp_setsockopt_connectx_old(struct sock *sk, * always positive. */ static int sctp_setsockopt_connectx(struct sock *sk, - struct sockaddr __user *addrs, + struct sockaddr *kaddrs, int addrs_size) { sctp_assoc_t assoc_id = 0; int err = 0; - err = __sctp_setsockopt_connectx(sk, addrs, addrs_size, &assoc_id); + err = __sctp_setsockopt_connectx(sk, kaddrs, addrs_size, &assoc_id); if (err) return err; @@ -1381,6 +1369,7 @@ static int sctp_getsockopt_connectx3(struct sock *sk, int len, { struct sctp_getaddrs_old param; sctp_assoc_t assoc_id = 0; + struct sockaddr *kaddrs; int err = 0; #ifdef CONFIG_COMPAT @@ -1404,9 +1393,12 @@ static int sctp_getsockopt_connectx3(struct sock *sk, int len, return -EFAULT; } - err = __sctp_setsockopt_connectx(sk, (struct sockaddr __user *) - param.addrs, param.addr_num, - &assoc_id); + kaddrs = memdup_user(param.addrs, param.addr_num); + if (IS_ERR(kaddrs)) + return PTR_ERR(kaddrs); + + err = __sctp_setsockopt_connectx(sk, kaddrs, param.addr_num, &assoc_id); + kfree(kaddrs); if (err == 0 || err == -EINPROGRESS) { if (copy_to_user(optval, &assoc_id, sizeof(assoc_id))) return -EFAULT; @@ -4696,16 +4688,12 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, case SCTP_SOCKOPT_CONNECTX_OLD: /* 'optlen' is the size of the addresses buffer. */ - retval = sctp_setsockopt_connectx_old(sk, - (struct sockaddr __user *)optval, - optlen); + retval = sctp_setsockopt_connectx_old(sk, kopt, optlen); break; case SCTP_SOCKOPT_CONNECTX: /* 'optlen' is the size of the addresses buffer. */ - retval = sctp_setsockopt_connectx(sk, - (struct sockaddr __user *)optval, - optlen); + retval = sctp_setsockopt_connectx(sk, kopt, optlen); break; case SCTP_DISABLE_FRAGMENTS: From patchwork Thu May 21 17:46:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218806 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59786C433E0 for ; Thu, 21 May 2020 17:47:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 399AA207F7 for ; Thu, 21 May 2020 17:47:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="HW33xHDI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729840AbgEURru (ORCPT ); Thu, 21 May 2020 13:47:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728961AbgEURrt (ORCPT ); Thu, 21 May 2020 13:47:49 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 692DDC061A0E; Thu, 21 May 2020 10:47:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=xriRSFhBjUZn87I8/ZlHJc6Fud4nO2hvhxfK6I1AnAA=; b=HW33xHDIM4qJusn5NLe0yZyHsr xeaLezxer9Q9Goi+IkqLXFNlZtWUufPWHjgibQEXjSFarhbIGi0zrdFzZGAlipTx6rY7hSe9qDwJf ZrnHDsVNetSKaBXwOgc3hLVcpb0rv0p7Mb7Art2pz/FU/+vhH7Gnfdxz7TjbEC1gYje07WipFs6d0 xK8p3wmsIcKVKwXyjxDIoBUUCkYgSDTt5nO+p/4EjjbGsn9/nCJIGMKlDc9eEFajtDMytdnMDvWD2 7Vxm0lB/6GMOFnnh1RngEcPMAJpSVttLAT9yo6bhD6sg8OWkVYml0vz3OHQDvxkgY0qUw6vrd656R hq9yHm4Q==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpIA-00030i-Ql; Thu, 21 May 2020 17:47:39 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 04/49] sctp: pass a kernel pointer to sctp_setsockopt_disable_fragments Date: Thu, 21 May 2020 19:46:39 +0200 Message-Id: <20200521174724.2635475-5-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index f7621ea99340e..0ca8001acfd50 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -2180,20 +2180,12 @@ static int sctp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, * exceeds the current PMTU size, the message will NOT be sent and * instead a error will be indicated to the user. */ -static int sctp_setsockopt_disable_fragments(struct sock *sk, - char __user *optval, +static int sctp_setsockopt_disable_fragments(struct sock *sk, int *val, unsigned int optlen) { - int val; - if (optlen < sizeof(int)) return -EINVAL; - - if (get_user(val, (int __user *)optval)) - return -EFAULT; - - sctp_sk(sk)->disable_fragments = (val == 0) ? 0 : 1; - + sctp_sk(sk)->disable_fragments = (*val == 0) ? 0 : 1; return 0; } @@ -4697,7 +4689,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, break; case SCTP_DISABLE_FRAGMENTS: - retval = sctp_setsockopt_disable_fragments(sk, optval, optlen); + retval = sctp_setsockopt_disable_fragments(sk, kopt, optlen); break; case SCTP_EVENTS: From patchwork Thu May 21 17:46:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218802 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 253C9C433DF for ; Thu, 21 May 2020 17:48:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2F77207F7 for ; Thu, 21 May 2020 17:48:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="D1WjVfCB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729147AbgEURsI (ORCPT ); Thu, 21 May 2020 13:48:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729844AbgEURrw (ORCPT ); Thu, 21 May 2020 13:47:52 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18A1BC061A0E; Thu, 21 May 2020 10:47:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=YXyPnqvk9m+Tq45lS2l1W+4eb0eHRkvX5n+PUsJrrPs=; b=D1WjVfCBjFk7PcZraBpDoEBib5 JZE8KCmz5+jTpx9Zyi42v2LJVMeVXBQoSuYz5RGNP0U0RJQZFEZhsZSdu72mA23V9uHJm6RhU3pFJ uwHMlsnhitP+PV13a4TZX7e+/CvvwScwWz9UbRwjCRLurnXskFnW7mamH0Dpb47W7UH1Jnf/EYknL LqJVbVFN40/3Rai4zl/cDCVZdvux1sriEL9D7k64SqAXLw/Vd+x91VeeyjuwAJZq12Zejf+lVBARx bdCEqjGbal3424tq6E3ZrlqqVJbrYPRnrsDX09g0BTHDlkFf/13pg5xjNFHeSvgBAotYkWRW+vd5a ZMbcOp2w==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpID-00034H-Eu; Thu, 21 May 2020 17:47:41 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 05/49] sctp: pass a kernel pointer to sctp_setsockopt_events Date: Thu, 21 May 2020 19:46:40 +0200 Message-Id: <20200521174724.2635475-6-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 0ca8001acfd50..34bd2ce2ddf66 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -2189,11 +2189,9 @@ static int sctp_setsockopt_disable_fragments(struct sock *sk, int *val, return 0; } -static int sctp_setsockopt_events(struct sock *sk, char __user *optval, +static int sctp_setsockopt_events(struct sock *sk, __u8 *sn_type, unsigned int optlen) { - struct sctp_event_subscribe subscribe; - __u8 *sn_type = (__u8 *)&subscribe; struct sctp_sock *sp = sctp_sk(sk); struct sctp_association *asoc; int i; @@ -2201,9 +2199,6 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval, if (optlen > sizeof(struct sctp_event_subscribe)) return -EINVAL; - if (copy_from_user(&subscribe, optval, optlen)) - return -EFAULT; - for (i = 0; i < optlen; i++) sctp_ulpevent_type_set(&sp->subscribe, SCTP_SN_TYPE_BASE + i, sn_type[i]); @@ -4693,7 +4688,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, break; case SCTP_EVENTS: - retval = sctp_setsockopt_events(sk, optval, optlen); + retval = sctp_setsockopt_events(sk, kopt, optlen); break; case SCTP_AUTOCLOSE: From patchwork Thu May 21 17:46:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218804 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7AE9C433E1 for ; Thu, 21 May 2020 17:48:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC62D20849 for ; Thu, 21 May 2020 17:48:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="IQou0yUS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730051AbgEURsA (ORCPT ); Thu, 21 May 2020 13:48:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729029AbgEURr6 (ORCPT ); Thu, 21 May 2020 13:47:58 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 243CAC061A0E; Thu, 21 May 2020 10:47:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=MFIjqh7L0Ypvl3sy3hiiVZhAMWqnjyOevJWMSHjQzcM=; b=IQou0yUSn/MoVLBFZ/ZPdOmLYj cbKZlpjODMw/JrS3T7VSMkBnx6sVIUzjulw8iU0i3FvEiHaum79Vdo8kfNkdoYfkUlh3fLmYorXK4 KUgKSpbBeHcHqmkVaSE+LiScp2mMSt2oc+TI2PsZMOjFy5Bo9IK3NuJuP+I5Wg3Tfr5uBPAdc5hUx nIxqejgNbJuLW5Fxh0EX5VlH9rsmQcFjFS/2L/B6JowqEB28ryIS/a1eeD4TYH5s4mNPBIGsWBYz1 KKrrDoR71PZYp0F8Gu8T9Vz4oGOXbRyYERc0RNbecj30sY49io06d8DPS4sXXgNMjdeZrxyfFYzi6 QRe1n11w==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpIK-00038Z-7h; Thu, 21 May 2020 17:47:48 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 07/49] sctp: pass a kernel pointer to sctp_setsockopt_peer_addr_params Date: Thu, 21 May 2020 19:46:42 +0200 Message-Id: <20200521174724.2635475-8-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 2fb3a5590a12e..0498cf21923e8 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -2586,48 +2586,42 @@ static int sctp_apply_peer_addr_params(struct sctp_paddrparams *params, } static int sctp_setsockopt_peer_addr_params(struct sock *sk, - char __user *optval, + struct sctp_paddrparams *params, unsigned int optlen) { - struct sctp_paddrparams params; struct sctp_transport *trans = NULL; struct sctp_association *asoc = NULL; struct sctp_sock *sp = sctp_sk(sk); int error; int hb_change, pmtud_change, sackdelay_change; - if (optlen == sizeof(params)) { - if (copy_from_user(¶ms, optval, optlen)) - return -EFAULT; - } else if (optlen == ALIGN(offsetof(struct sctp_paddrparams, + if (optlen == ALIGN(offsetof(struct sctp_paddrparams, spp_ipv6_flowlabel), 4)) { - if (copy_from_user(¶ms, optval, optlen)) - return -EFAULT; - if (params.spp_flags & (SPP_DSCP | SPP_IPV6_FLOWLABEL)) + if (params->spp_flags & (SPP_DSCP | SPP_IPV6_FLOWLABEL)) return -EINVAL; - } else { + } else if (optlen != sizeof(*params)) { return -EINVAL; } /* Validate flags and value parameters. */ - hb_change = params.spp_flags & SPP_HB; - pmtud_change = params.spp_flags & SPP_PMTUD; - sackdelay_change = params.spp_flags & SPP_SACKDELAY; + hb_change = params->spp_flags & SPP_HB; + pmtud_change = params->spp_flags & SPP_PMTUD; + sackdelay_change = params->spp_flags & SPP_SACKDELAY; if (hb_change == SPP_HB || pmtud_change == SPP_PMTUD || sackdelay_change == SPP_SACKDELAY || - params.spp_sackdelay > 500 || - (params.spp_pathmtu && - params.spp_pathmtu < SCTP_DEFAULT_MINSEGMENT)) + params->spp_sackdelay > 500 || + (params->spp_pathmtu && + params->spp_pathmtu < SCTP_DEFAULT_MINSEGMENT)) return -EINVAL; /* If an address other than INADDR_ANY is specified, and * no transport is found, then the request is invalid. */ - if (!sctp_is_any(sk, (union sctp_addr *)¶ms.spp_address)) { - trans = sctp_addr_id2transport(sk, ¶ms.spp_address, - params.spp_assoc_id); + if (!sctp_is_any(sk, (union sctp_addr *)¶ms->spp_address)) { + trans = sctp_addr_id2transport(sk, ¶ms->spp_address, + params->spp_assoc_id); if (!trans) return -EINVAL; } @@ -2636,19 +2630,19 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk, * socket is a one to many style socket, and an association * was not found, then the id was invalid. */ - asoc = sctp_id2assoc(sk, params.spp_assoc_id); - if (!asoc && params.spp_assoc_id != SCTP_FUTURE_ASSOC && + asoc = sctp_id2assoc(sk, params->spp_assoc_id); + if (!asoc && params->spp_assoc_id != SCTP_FUTURE_ASSOC && sctp_style(sk, UDP)) return -EINVAL; /* Heartbeat demand can only be sent on a transport or * association, but not a socket. */ - if (params.spp_flags & SPP_HB_DEMAND && !trans && !asoc) + if (params->spp_flags & SPP_HB_DEMAND && !trans && !asoc) return -EINVAL; /* Process parameters. */ - error = sctp_apply_peer_addr_params(¶ms, trans, asoc, sp, + error = sctp_apply_peer_addr_params(params, trans, asoc, sp, hb_change, pmtud_change, sackdelay_change); @@ -2661,7 +2655,7 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk, if (!trans && asoc) { list_for_each_entry(trans, &asoc->peer.transport_addr_list, transports) { - sctp_apply_peer_addr_params(¶ms, trans, asoc, sp, + sctp_apply_peer_addr_params(params, trans, asoc, sp, hb_change, pmtud_change, sackdelay_change); } @@ -4696,7 +4690,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, break; case SCTP_PEER_ADDR_PARAMS: - retval = sctp_setsockopt_peer_addr_params(sk, optval, optlen); + retval = sctp_setsockopt_peer_addr_params(sk, kopt, optlen); break; case SCTP_DELAYED_SACK: From patchwork Thu May 21 17:46:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218803 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0678EC433DF for ; Thu, 21 May 2020 17:48:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C493420829 for ; Thu, 21 May 2020 17:48:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="iQRMDtxQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729059AbgEURsF (ORCPT ); Thu, 21 May 2020 13:48:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729029AbgEURsD (ORCPT ); Thu, 21 May 2020 13:48:03 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEF1CC061A0E; Thu, 21 May 2020 10:48:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=XdMJEjTtoaAs1w9xt+NgrWfZ6KjmtXggnReOY/jA7IY=; b=iQRMDtxQsnOLxaz23jBChf2PEg uVeLaeC+lSiJBk0Fs+wmzsnxBR6KvzuSOd0NQ0+5jMWhitPYBbVSZUDU4VuObSr4xVDLuv1hUlbtr /VzD0NW45J08oyJIXe6l4n3axca7pMmOLNMsBOnT74DXey3lX4Ds4/eAOhLe4lzwN0P1wY+Ai+X1X xnNMcrA3HKLSM0uMXynA2PkqyRF5CgZVgreO6CrO+asLfBjK46ygILuleuPIdYsdvpw9tdIp0F/Xj MsWUymY8KgKu7MmO3l0yXmJ0uKLEuuS4Ev8urtTK1p5MWemS4zQLDwDs9pkMmK43PP7iOD6huVqBo dIn5vevg==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpIP-0003AV-4R; Thu, 21 May 2020 17:47:53 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 09/49] sctp: pass a kernel pointer to sctp_setsockopt_partial_delivery_point Date: Thu, 21 May 2020 19:46:44 +0200 Message-Id: <20200521174724.2635475-10-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 3763f124f9fea..6dd6b0cfcfe03 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -3484,24 +3484,19 @@ static int sctp_setsockopt_fragment_interleave(struct sock *sk, * call as long as the user provided buffer is large enough to hold the * message. */ -static int sctp_setsockopt_partial_delivery_point(struct sock *sk, - char __user *optval, +static int sctp_setsockopt_partial_delivery_point(struct sock *sk, u32 *val, unsigned int optlen) { - u32 val; - if (optlen != sizeof(u32)) return -EINVAL; - if (get_user(val, (int __user *)optval)) - return -EFAULT; /* Note: We double the receive buffer from what the user sets * it to be, also initial rwnd is based on rcvbuf/2. */ - if (val > (sk->sk_rcvbuf >> 1)) + if (*val > (sk->sk_rcvbuf >> 1)) return -EINVAL; - sctp_sk(sk)->pd_point = val; + sctp_sk(sk)->pd_point = *val; return 0; /* is this the right error code? */ } @@ -4692,7 +4687,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_delayed_ack(sk, kopt, optlen); break; case SCTP_PARTIAL_DELIVERY_POINT: - retval = sctp_setsockopt_partial_delivery_point(sk, optval, optlen); + retval = sctp_setsockopt_partial_delivery_point(sk, kopt, optlen); break; case SCTP_INITMSG: From patchwork Thu May 21 17:46:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218801 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BF31C433E2 for ; Thu, 21 May 2020 17:48:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E579207F7 for ; Thu, 21 May 2020 17:48:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="AlU39C63" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730128AbgEURsP (ORCPT ); Thu, 21 May 2020 13:48:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730104AbgEURsL (ORCPT ); Thu, 21 May 2020 13:48:11 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76E7AC061A0E; Thu, 21 May 2020 10:48:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=qrLUQyaeJYthY29m3jqWphySEvOPt3fDowQiG2CAWq8=; b=AlU39C63nzkXuMED6VWrJqLdVb lEWdvMLQv3dXg04djzGXTYkeq7b9wocSP9nwz12Af1vcXbhAd4NQGNBaG3/k/gmqAJwtvwJAQyxKK 4btbxfD8DiwnHjY8RV9n+QLuaOskABFyeqPuqLzp2+3rU6HmwhtyveKuRcW0K+nEuKJyeq8rjkNmC zstAkUs+UbPWtpyy0Q5zdSNsCEQX2ai1/mArhqsifKlRnfJUxbfg0cBBIp9gmmPadosJzkWU7wrpR XTKY0bne2MyECCn4xn+IDK9b5t80OszxYXw8TWpbdZrZH61x6H1YAgA1ngWaq0Uwy7ydAWx7v7lY+ qS8xvzeQ==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpIX-0003Cg-8T; Thu, 21 May 2020 17:48:01 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 12/49] sctp: pass a kernel pointer to sctp_setsockopt_default_sndinfo Date: Thu, 21 May 2020 19:46:47 +0200 Message-Id: <20200521174724.2635475-13-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index acf1484cd62a1..53bd58a5cc954 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -2922,54 +2922,51 @@ static int sctp_setsockopt_default_send_param(struct sock *sk, * (SCTP_DEFAULT_SNDINFO) */ static int sctp_setsockopt_default_sndinfo(struct sock *sk, - char __user *optval, + struct sctp_sndinfo *info, unsigned int optlen) { struct sctp_sock *sp = sctp_sk(sk); struct sctp_association *asoc; - struct sctp_sndinfo info; if (optlen != sizeof(info)) return -EINVAL; - if (copy_from_user(&info, optval, optlen)) - return -EFAULT; - if (info.snd_flags & + if (info->snd_flags & ~(SCTP_UNORDERED | SCTP_ADDR_OVER | SCTP_ABORT | SCTP_EOF)) return -EINVAL; - asoc = sctp_id2assoc(sk, info.snd_assoc_id); - if (!asoc && info.snd_assoc_id > SCTP_ALL_ASSOC && + asoc = sctp_id2assoc(sk, info->snd_assoc_id); + if (!asoc && info->snd_assoc_id > SCTP_ALL_ASSOC && sctp_style(sk, UDP)) return -EINVAL; if (asoc) { - asoc->default_stream = info.snd_sid; - asoc->default_flags = info.snd_flags; - asoc->default_ppid = info.snd_ppid; - asoc->default_context = info.snd_context; + asoc->default_stream = info->snd_sid; + asoc->default_flags = info->snd_flags; + asoc->default_ppid = info->snd_ppid; + asoc->default_context = info->snd_context; return 0; } if (sctp_style(sk, TCP)) - info.snd_assoc_id = SCTP_FUTURE_ASSOC; + info->snd_assoc_id = SCTP_FUTURE_ASSOC; - if (info.snd_assoc_id == SCTP_FUTURE_ASSOC || - info.snd_assoc_id == SCTP_ALL_ASSOC) { - sp->default_stream = info.snd_sid; - sp->default_flags = info.snd_flags; - sp->default_ppid = info.snd_ppid; - sp->default_context = info.snd_context; + if (info->snd_assoc_id == SCTP_FUTURE_ASSOC || + info->snd_assoc_id == SCTP_ALL_ASSOC) { + sp->default_stream = info->snd_sid; + sp->default_flags = info->snd_flags; + sp->default_ppid = info->snd_ppid; + sp->default_context = info->snd_context; } - if (info.snd_assoc_id == SCTP_CURRENT_ASSOC || - info.snd_assoc_id == SCTP_ALL_ASSOC) { + if (info->snd_assoc_id == SCTP_CURRENT_ASSOC || + info->snd_assoc_id == SCTP_ALL_ASSOC) { list_for_each_entry(asoc, &sp->ep->asocs, asocs) { - asoc->default_stream = info.snd_sid; - asoc->default_flags = info.snd_flags; - asoc->default_ppid = info.snd_ppid; - asoc->default_context = info.snd_context; + asoc->default_stream = info->snd_sid; + asoc->default_flags = info->snd_flags; + asoc->default_ppid = info->snd_ppid; + asoc->default_context = info->snd_context; } } @@ -4692,7 +4689,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_default_send_param(sk, kopt, optlen); break; case SCTP_DEFAULT_SNDINFO: - retval = sctp_setsockopt_default_sndinfo(sk, optval, optlen); + retval = sctp_setsockopt_default_sndinfo(sk, kopt, optlen); break; case SCTP_PRIMARY_ADDR: retval = sctp_setsockopt_primary_addr(sk, optval, optlen); From patchwork Thu May 21 17:46:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218800 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBD8EC433E2 for ; Thu, 21 May 2020 17:48:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AFC11207F7 for ; Thu, 21 May 2020 17:48:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="CgMYwaA3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730150AbgEURsS (ORCPT ); Thu, 21 May 2020 13:48:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727966AbgEURsR (ORCPT ); Thu, 21 May 2020 13:48:17 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 484B4C061A0E; Thu, 21 May 2020 10:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=iOe6JgwGaZZrHfSABkfjp3vB27JIcpUw1fCRdF6mDx8=; b=CgMYwaA3Pxe/EsgRrHHe6WDWK9 6AbJQFVJK/OdbSqBwmjhVLlpS6Rl4lEMXoh93nKrA8Jf9Hvv5LGBs6iJWZP/c+ZQqBeJLje8Cg9N6 McW9Ind4uKlfm2rhxqtBQRhAzvNMYhn2DXelo1zR6fYH4wrjgK/Ym2X3bFc/zTSGEUPQ6fejJ3/fO y2QpiH7G2j8uRnZIItEMbAMuKr+cDBOvxDiWOooeMRIEMmvx+XiecGpy8/1YCV3zswwHGmBSF5kND SymtwWgC5838UGHjA4wxRaC3jBQqQhLKwvVHkO7SJr3RmGd4IywazFJY0Kmthe3jHLfFO41DRLwZy NOsWQPow==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpIc-0003Dr-PF; Thu, 21 May 2020 17:48:07 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 14/49] sctp: pass a kernel pointer to sctp_setsockopt_peer_primary_addr Date: Thu, 21 May 2020 19:46:49 +0200 Message-Id: <20200521174724.2635475-15-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index df00342ac74f9..eb01992da7949 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -3281,12 +3281,12 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned * locally bound addresses. The following structure is used to make a * set primary request: */ -static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optval, +static int sctp_setsockopt_peer_primary_addr(struct sock *sk, + struct sctp_setpeerprim *prim, unsigned int optlen) { struct sctp_sock *sp; struct sctp_association *asoc = NULL; - struct sctp_setpeerprim prim; struct sctp_chunk *chunk; struct sctp_af *af; int err; @@ -3299,10 +3299,7 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva if (optlen != sizeof(struct sctp_setpeerprim)) return -EINVAL; - if (copy_from_user(&prim, optval, optlen)) - return -EFAULT; - - asoc = sctp_id2assoc(sk, prim.sspp_assoc_id); + asoc = sctp_id2assoc(sk, prim->sspp_assoc_id); if (!asoc) return -EINVAL; @@ -3315,26 +3312,26 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva if (!sctp_state(asoc, ESTABLISHED)) return -ENOTCONN; - af = sctp_get_af_specific(prim.sspp_addr.ss_family); + af = sctp_get_af_specific(prim->sspp_addr.ss_family); if (!af) return -EINVAL; - if (!af->addr_valid((union sctp_addr *)&prim.sspp_addr, sp, NULL)) + if (!af->addr_valid((union sctp_addr *)&prim->sspp_addr, sp, NULL)) return -EADDRNOTAVAIL; - if (!sctp_assoc_lookup_laddr(asoc, (union sctp_addr *)&prim.sspp_addr)) + if (!sctp_assoc_lookup_laddr(asoc, (union sctp_addr *)&prim->sspp_addr)) return -EADDRNOTAVAIL; /* Allow security module to validate address. */ err = security_sctp_bind_connect(sk, SCTP_SET_PEER_PRIMARY_ADDR, - (struct sockaddr *)&prim.sspp_addr, + (struct sockaddr *)&prim->sspp_addr, af->sockaddr_len); if (err) return err; /* Create an ASCONF chunk with SET_PRIMARY parameter */ chunk = sctp_make_asconf_set_prim(asoc, - (union sctp_addr *)&prim.sspp_addr); + (union sctp_addr *)&prim->sspp_addr); if (!chunk) return -ENOMEM; @@ -4691,7 +4688,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_primary_addr(sk, kopt, optlen); break; case SCTP_SET_PEER_PRIMARY_ADDR: - retval = sctp_setsockopt_peer_primary_addr(sk, optval, optlen); + retval = sctp_setsockopt_peer_primary_addr(sk, kopt, optlen); break; case SCTP_NODELAY: retval = sctp_setsockopt_nodelay(sk, optval, optlen); From patchwork Thu May 21 17:46:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A91AC433E0 for ; Thu, 21 May 2020 17:48:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 09FDF207F7 for ; Thu, 21 May 2020 17:48:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="n9+DIAws" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730173AbgEURsW (ORCPT ); Thu, 21 May 2020 13:48:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727966AbgEURsU (ORCPT ); Thu, 21 May 2020 13:48:20 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35E67C061A0E; Thu, 21 May 2020 10:48:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=UijWnm5eSd4PckpUS4Tjc81iEuS4R7Ony9OCzxMc32s=; b=n9+DIAwski1au5E155UrPL9GNd 8tCvRPE3bjsqn2TiUFNyzw8AWHinKaSsYQ9iEVfU3Tc57D3589eOcrhAcTU05AAE2/0ZDuJUA9026 2Anfis4VL28nq8Kwm5vCGiUznSzWLdYfl/Pv1d+0GamUao7dxLjsXgFjEghgL4bUD3YX84fxQ0ocP 7VRSng56nIL9EoStL5y75zBIbDVB4YL638zXiK7Nt995PK6Lelphgq/cVJy+ylGl21ZcOsv09KFiv YP6Rjiq4soQkmoLBhtyOk2OyzkPrKWITAX7qDmsnfhMaCDNUKJsSS98GAahmYaynqqSqxlQynWK50 3bUdb2AQ==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpIf-0003Ec-81; Thu, 21 May 2020 17:48:09 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 15/49] sctp: pass a kernel pointer to sctp_setsockopt_nodelay Date: Thu, 21 May 2020 19:46:50 +0200 Message-Id: <20200521174724.2635475-16-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index eb01992da7949..99df37bbcb903 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -3017,17 +3017,12 @@ static int sctp_setsockopt_primary_addr(struct sock *sk, struct sctp_prim *prim, * introduced, at the cost of more packets in the network. Expects an * integer boolean flag. */ -static int sctp_setsockopt_nodelay(struct sock *sk, char __user *optval, +static int sctp_setsockopt_nodelay(struct sock *sk, int *val, unsigned int optlen) { - int val; - if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) - return -EFAULT; - - sctp_sk(sk)->nodelay = (val == 0) ? 0 : 1; + sctp_sk(sk)->nodelay = (*val == 0) ? 0 : 1; return 0; } @@ -4691,7 +4686,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_peer_primary_addr(sk, kopt, optlen); break; case SCTP_NODELAY: - retval = sctp_setsockopt_nodelay(sk, optval, optlen); + retval = sctp_setsockopt_nodelay(sk, kopt, optlen); break; case SCTP_RTOINFO: retval = sctp_setsockopt_rtoinfo(sk, optval, optlen); From patchwork Thu May 21 17:46:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218798 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 511BBC433E1 for ; Thu, 21 May 2020 17:48:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2446E207F7 for ; Thu, 21 May 2020 17:48:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="pdRB3wk7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730191AbgEURs2 (ORCPT ); Thu, 21 May 2020 13:48:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730180AbgEURsZ (ORCPT ); Thu, 21 May 2020 13:48:25 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 439FAC061A0E; Thu, 21 May 2020 10:48:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=IbAxHvXeQq8TGrR00szbPu8WdNCV+tocb8h6szetRZk=; b=pdRB3wk7XauQ5xNozg7x0ajlns ONf5SxlTbtvOeqRE1W1GQnKPpb46zeuuGJRCsZwQBQeqR11uIZssMR3wJmGIB6a/itOrh9qkHb7TI 8l6MXleoAmIQz4KSLSjVQdBdQ6C1Qw/Y2CythTWMtwY9Zr+cxZWxM6xqK6o/zl82YcCrXxcJd5LLf 0CV3rzcCT9/XwggmwSjcmXssmg4vWChKV71fKgF1gHy+6r6zYWI/GY8vwEAvJpDilcsHgcJPVrEus wh33GSNsKVS6vPysyHK23aCWGEBwPGh/DEW9SMKLBXbAkz+rmvMSkx4ekIUICqh7+2KnqUyTmARs9 0nuGsACQ==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpIk-0003FH-IR; Thu, 21 May 2020 17:48:15 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 17/49] sctp: pass a kernel pointer to sctp_setsockopt_associnfo Date: Thu, 21 May 2020 19:46:52 +0200 Message-Id: <20200521174724.2635475-18-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 7998b25a8a271..161acd6253e06 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -3102,26 +3102,25 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, * See [SCTP] for more information. * */ -static int sctp_setsockopt_associnfo(struct sock *sk, char __user *optval, unsigned int optlen) +static int sctp_setsockopt_associnfo(struct sock *sk, + struct sctp_assocparams *assocparams, + unsigned int optlen) { - struct sctp_assocparams assocparams; struct sctp_association *asoc; if (optlen != sizeof(struct sctp_assocparams)) return -EINVAL; - if (copy_from_user(&assocparams, optval, optlen)) - return -EFAULT; - asoc = sctp_id2assoc(sk, assocparams.sasoc_assoc_id); + asoc = sctp_id2assoc(sk, assocparams->sasoc_assoc_id); - if (!asoc && assocparams.sasoc_assoc_id != SCTP_FUTURE_ASSOC && + if (!asoc && assocparams->sasoc_assoc_id != SCTP_FUTURE_ASSOC && sctp_style(sk, UDP)) return -EINVAL; /* Set the values to the specific association */ if (asoc) { - if (assocparams.sasoc_asocmaxrxt != 0) { + if (assocparams->sasoc_asocmaxrxt != 0) { __u32 path_sum = 0; int paths = 0; struct sctp_transport *peer_addr; @@ -3138,24 +3137,25 @@ static int sctp_setsockopt_associnfo(struct sock *sk, char __user *optval, unsig * then one path. */ if (paths > 1 && - assocparams.sasoc_asocmaxrxt > path_sum) + assocparams->sasoc_asocmaxrxt > path_sum) return -EINVAL; - asoc->max_retrans = assocparams.sasoc_asocmaxrxt; + asoc->max_retrans = assocparams->sasoc_asocmaxrxt; } - if (assocparams.sasoc_cookie_life != 0) - asoc->cookie_life = ms_to_ktime(assocparams.sasoc_cookie_life); + if (assocparams->sasoc_cookie_life != 0) + asoc->cookie_life = + ms_to_ktime(assocparams->sasoc_cookie_life); } else { /* Set the values to the endpoint */ struct sctp_sock *sp = sctp_sk(sk); - if (assocparams.sasoc_asocmaxrxt != 0) + if (assocparams->sasoc_asocmaxrxt != 0) sp->assocparams.sasoc_asocmaxrxt = - assocparams.sasoc_asocmaxrxt; - if (assocparams.sasoc_cookie_life != 0) + assocparams->sasoc_asocmaxrxt; + if (assocparams->sasoc_cookie_life != 0) sp->assocparams.sasoc_cookie_life = - assocparams.sasoc_cookie_life; + assocparams->sasoc_cookie_life; } return 0; } @@ -4690,7 +4690,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_rtoinfo(sk, kopt, optlen); break; case SCTP_ASSOCINFO: - retval = sctp_setsockopt_associnfo(sk, optval, optlen); + retval = sctp_setsockopt_associnfo(sk, kopt, optlen); break; case SCTP_I_WANT_MAPPED_V4_ADDR: retval = sctp_setsockopt_mappedv4(sk, optval, optlen); From patchwork Thu May 21 17:46:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218797 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9B7DC433E2 for ; Thu, 21 May 2020 17:48:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B3357207F7 for ; Thu, 21 May 2020 17:48:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="utL85sTB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730226AbgEURsf (ORCPT ); Thu, 21 May 2020 13:48:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730206AbgEURsc (ORCPT ); Thu, 21 May 2020 13:48:32 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 295E8C05BD43; Thu, 21 May 2020 10:48:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=+W6A8x+QQrTs5cRuqkGdWhnjYRP3hZU2/tpgA64vpx0=; b=utL85sTBSVJDA/PNnz1GacWJ3e o3pQwMsd+eVVDAN2Rux32yEZSk6XH9NxxEzWX48RESiQ19l6YurTA2KiXzldztqUb3CgxelLHzOvJ jfrRHG6fPyhSGECnvUYsdXkwR1xCQKuA/D+qVKxD5UMRvcNoFV5HpafBTHNAnOl4lhqKF863LwiG5 YwCfyAyJ4rPpfsURSgZRFKfBkJFxHcHfP77TYcGno36hWU3YuJmIgI1ZGcjSXKlJpj7tEVMrB0cwK OgENtXRKO1sJaLE48DoKJcx/8P9nWgzmAi7FNEYo0fabFPgPIjmDpQun9ceILH1b8QdqRQId/R0eo aN9vAA4A==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpIs-0003Gp-3m; Thu, 21 May 2020 17:48:22 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 20/49] sctp: pass a kernel pointer to sctp_setsockopt_adaptation_layer Date: Thu, 21 May 2020 19:46:55 +0200 Message-Id: <20200521174724.2635475-21-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 4374d4fff080a..b7bf09f86a5e7 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -3333,17 +3333,14 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, return err; } -static int sctp_setsockopt_adaptation_layer(struct sock *sk, char __user *optval, +static int sctp_setsockopt_adaptation_layer(struct sock *sk, + struct sctp_setadaptation *adapt, unsigned int optlen) { - struct sctp_setadaptation adaptation; - if (optlen != sizeof(struct sctp_setadaptation)) return -EINVAL; - if (copy_from_user(&adaptation, optval, optlen)) - return -EFAULT; - sctp_sk(sk)->adaptation_ind = adaptation.ssb_adaptation_ind; + sctp_sk(sk)->adaptation_ind = adapt->ssb_adaptation_ind; return 0; } @@ -4697,7 +4694,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_maxseg(sk, kopt, optlen); break; case SCTP_ADAPTATION_LAYER: - retval = sctp_setsockopt_adaptation_layer(sk, optval, optlen); + retval = sctp_setsockopt_adaptation_layer(sk, kopt, optlen); break; case SCTP_CONTEXT: retval = sctp_setsockopt_context(sk, optval, optlen); From patchwork Thu May 21 17:46:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218796 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C833FC433E0 for ; Thu, 21 May 2020 17:48:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9BA9A207F7 for ; Thu, 21 May 2020 17:48:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="R/lfl1/D" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730245AbgEURsj (ORCPT ); Thu, 21 May 2020 13:48:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730199AbgEURsc (ORCPT ); Thu, 21 May 2020 13:48:32 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D453C061A0E; Thu, 21 May 2020 10:48:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=1bjbzbcVhHMPlQGEvEog0coBv4aadRPsOd8JywRQ2Mo=; b=R/lfl1/D6cxge1zYoG6vGZAh9q k8y+fKvIU0cDAznBt0j/19gxckD5HMdk/EfCbZF6M4gWYPwrSsmCvqnwYJq2rl1lEOVDaBVBq28f9 iGg3IUVUcy8UlyqRCr7kXps+Lnya79+D0K7yO24Bwvu0fFPv00QRT/3KzwUtglseWZs1MpZROuDAD kpjZ+tQi/FE4idUSZv/AIsAvlxgkcTlAAqGZ2esQlpQwACiW8VSJom1NZK0EohBkRFhUqHFgjtZcg cbsWsDBr+seXWlbq07zBBxSO/EOzDMsJM53vzmYbNWt67500Gf4nDsbC8nI5GeiJsxkkRzCJKibX5 msTVw13g==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpIu-0003HA-KV; Thu, 21 May 2020 17:48:25 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 21/49] sctp: pass a kernel pointer to sctp_setsockopt_context Date: Thu, 21 May 2020 19:46:56 +0200 Message-Id: <20200521174724.2635475-22-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index b7bf09f86a5e7..03577684be65f 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -3359,40 +3359,38 @@ static int sctp_setsockopt_adaptation_layer(struct sock *sk, * received messages from the peer and does not effect the value that is * saved with outbound messages. */ -static int sctp_setsockopt_context(struct sock *sk, char __user *optval, +static int sctp_setsockopt_context(struct sock *sk, + struct sctp_assoc_value *params, unsigned int optlen) { struct sctp_sock *sp = sctp_sk(sk); - struct sctp_assoc_value params; struct sctp_association *asoc; if (optlen != sizeof(struct sctp_assoc_value)) return -EINVAL; - if (copy_from_user(¶ms, optval, optlen)) - return -EFAULT; - asoc = sctp_id2assoc(sk, params.assoc_id); - if (!asoc && params.assoc_id > SCTP_ALL_ASSOC && + asoc = sctp_id2assoc(sk, params->assoc_id); + if (!asoc && params->assoc_id > SCTP_ALL_ASSOC && sctp_style(sk, UDP)) return -EINVAL; if (asoc) { - asoc->default_rcv_context = params.assoc_value; + asoc->default_rcv_context = params->assoc_value; return 0; } if (sctp_style(sk, TCP)) - params.assoc_id = SCTP_FUTURE_ASSOC; + params->assoc_id = SCTP_FUTURE_ASSOC; - if (params.assoc_id == SCTP_FUTURE_ASSOC || - params.assoc_id == SCTP_ALL_ASSOC) - sp->default_rcv_context = params.assoc_value; + if (params->assoc_id == SCTP_FUTURE_ASSOC || + params->assoc_id == SCTP_ALL_ASSOC) + sp->default_rcv_context = params->assoc_value; - if (params.assoc_id == SCTP_CURRENT_ASSOC || - params.assoc_id == SCTP_ALL_ASSOC) + if (params->assoc_id == SCTP_CURRENT_ASSOC || + params->assoc_id == SCTP_ALL_ASSOC) list_for_each_entry(asoc, &sp->ep->asocs, asocs) - asoc->default_rcv_context = params.assoc_value; + asoc->default_rcv_context = params->assoc_value; return 0; } @@ -4697,7 +4695,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_adaptation_layer(sk, kopt, optlen); break; case SCTP_CONTEXT: - retval = sctp_setsockopt_context(sk, optval, optlen); + retval = sctp_setsockopt_context(sk, kopt, optlen); break; case SCTP_FRAGMENT_INTERLEAVE: retval = sctp_setsockopt_fragment_interleave(sk, optval, optlen); From patchwork Thu May 21 17:47:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218783 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25B01C433E1 for ; Thu, 21 May 2020 17:49:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF58D207F7 for ; Thu, 21 May 2020 17:49:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ieUXnWww" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730303AbgEURsn (ORCPT ); Thu, 21 May 2020 13:48:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730236AbgEURsh (ORCPT ); Thu, 21 May 2020 13:48:37 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EB1AC061A0E; Thu, 21 May 2020 10:48:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=Bv65sC4uAgBaRnpAKqnPt6Y54+pI7qtIct0VTY/fthc=; b=ieUXnWwwjI+3F0dbwr5+oAc8qH Cw8+vr4g8XCP8YNUCrkSGlhyXvBY68D3aVC1y++9cVNHeW/wYCx39YIXNRK28ln8E+dgegMx/P1Pl Y4fTSHACfL2cxWETi3/u/Fma+2Cv0WomGN3RR1arsbfS8GUPOgFWuQ0JsV1KBpRWPutnC5Dmc/Rbg j0tPxNaJK02KFRVfwk2idBGZWr3HS1xP5vj5sO3CWwE7zrtrESFdOLqyEYqrptbKjbBRkvGdEpghE e5q+Wnox8iOtiath/82E++ZB/DTcHvQhdKDfRu3Sc6P6W0dbZzSYq4qoogn0zlHNJRiToDC/zpkEP NxSgENHA==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpJ5-0003Ip-Nf; Thu, 21 May 2020 17:48:36 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 25/49] sctp: pass a kernel pointer to sctp_setsockopt_hmac_ident Date: Thu, 21 May 2020 19:47:00 +0200 Message-Id: <20200521174724.2635475-26-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index aa06affcd66e0..88edf5413fd22 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -3562,13 +3562,11 @@ static int sctp_setsockopt_auth_chunk(struct sock *sk, * endpoint requires the peer to use. */ static int sctp_setsockopt_hmac_ident(struct sock *sk, - char __user *optval, + struct sctp_hmacalgo *hmacs, unsigned int optlen) { struct sctp_endpoint *ep = sctp_sk(sk)->ep; - struct sctp_hmacalgo *hmacs; u32 idents; - int err; if (!ep->auth_enable) return -EACCES; @@ -3578,21 +3576,12 @@ static int sctp_setsockopt_hmac_ident(struct sock *sk, optlen = min_t(unsigned int, optlen, sizeof(struct sctp_hmacalgo) + SCTP_AUTH_NUM_HMACS * sizeof(u16)); - hmacs = memdup_user(optval, optlen); - if (IS_ERR(hmacs)) - return PTR_ERR(hmacs); - idents = hmacs->shmac_num_idents; if (idents == 0 || idents > SCTP_AUTH_NUM_HMACS || - (idents * sizeof(u16)) > (optlen - sizeof(struct sctp_hmacalgo))) { - err = -EINVAL; - goto out; - } + (idents * sizeof(u16)) > (optlen - sizeof(struct sctp_hmacalgo))) + return -EINVAL; - err = sctp_auth_ep_set_hmacs(ep, hmacs); -out: - kfree(hmacs); - return err; + return sctp_auth_ep_set_hmacs(ep, hmacs); } /* @@ -4696,7 +4685,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_auth_chunk(sk, kopt, optlen); break; case SCTP_HMAC_IDENT: - retval = sctp_setsockopt_hmac_ident(sk, optval, optlen); + retval = sctp_setsockopt_hmac_ident(sk, kopt, optlen); break; case SCTP_AUTH_KEY: retval = sctp_setsockopt_auth_key(sk, optval, optlen); From patchwork Thu May 21 17:47:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218780 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5383C433E0 for ; Thu, 21 May 2020 17:50:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B525B20759 for ; Thu, 21 May 2020 17:50:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ppTFQsKZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730022AbgEURuS (ORCPT ); Thu, 21 May 2020 13:50:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730258AbgEURsl (ORCPT ); Thu, 21 May 2020 13:48:41 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B12EC061A0E; Thu, 21 May 2020 10:48:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=uV/6VvsFrT7rKBrCOkAvlvdEtjI8hO5JNu4RqbiP830=; b=ppTFQsKZ3rWwcP0V3c4MTkWFcE TkUqfpDfcz18zodm3yXMkFZ9uISSOvhpmi8wHdg6ZE/wPAtLLriRrEe4GjtR+jI8UdiX0ZQd29PhB fHiWFZjkYpWpBpims5cma4xv2Tvji76lkbmH460VzroB9Llfx1Xol0CrwGRaAjoLFUuUwWCouwkBk qnL2bbUrE+AFgQWkAMgwoF9BBRLQecWOl7Jw11CWNRY5JXPO9Sbt70TlTlbefwUsi6z14XoLpg9Dp lms5i/rOgwCTsrqtzF64VVODoSpfZha8MpCPs+2tqvG/zr2P3gkCEWwPfXIn/ySBs4T6vlEHvdG5/ KIhWRQPw==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpJ8-0003JD-73; Thu, 21 May 2020 17:48:38 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 26/49] sctp: pass a kernel pointer to sctp_setsockopt_auth_key Date: Thu, 21 May 2020 19:47:01 +0200 Message-Id: <20200521174724.2635475-27-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Adapt sctp_setsockopt to use a kzfree for this case. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 88edf5413fd22..d3442dcd49aa8 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -3591,11 +3591,10 @@ static int sctp_setsockopt_hmac_ident(struct sock *sk, * association shared key. */ static int sctp_setsockopt_auth_key(struct sock *sk, - char __user *optval, + struct sctp_authkey *authkey, unsigned int optlen) { struct sctp_endpoint *ep = sctp_sk(sk)->ep; - struct sctp_authkey *authkey; struct sctp_association *asoc; int ret = -EINVAL; @@ -3606,10 +3605,6 @@ static int sctp_setsockopt_auth_key(struct sock *sk, */ optlen = min_t(unsigned int, optlen, USHRT_MAX + sizeof(*authkey)); - authkey = memdup_user(optval, optlen); - if (IS_ERR(authkey)) - return PTR_ERR(authkey); - if (authkey->sca_keylength > optlen - sizeof(*authkey)) goto out; @@ -3646,7 +3641,6 @@ static int sctp_setsockopt_auth_key(struct sock *sk, } out: - kzfree(authkey); return ret; } @@ -4688,7 +4682,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_hmac_ident(sk, kopt, optlen); break; case SCTP_AUTH_KEY: - retval = sctp_setsockopt_auth_key(sk, optval, optlen); + retval = sctp_setsockopt_auth_key(sk, kopt, optlen); break; case SCTP_AUTH_ACTIVE_KEY: retval = sctp_setsockopt_active_key(sk, optval, optlen); @@ -4771,7 +4765,10 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, } release_sock(sk); - kfree(kopt); + if (optname == SCTP_AUTH_KEY) + kzfree(kopt); + else + kfree(kopt); out_nounlock: return retval; From patchwork Thu May 21 17:47:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218782 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DDC9C433DF for ; Thu, 21 May 2020 17:50:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D3BE20759 for ; Thu, 21 May 2020 17:50:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="qN27vLKB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728897AbgEURuA (ORCPT ); Thu, 21 May 2020 13:50:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730278AbgEURsm (ORCPT ); Thu, 21 May 2020 13:48:42 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BA6FC061A0E; Thu, 21 May 2020 10:48:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=7HBY45D0CZ2sXVph0QcqI6+dgMRp0Ik5bZt6bdzdAxk=; b=qN27vLKB/YMyGK0kPGKRqbEhRu llfTFuEtI0nBdMcWj7Z2wKPnQYVkhd8xUViyZZstqF/jv5oHAlLq3+vYeqozGfsjbuDgugfPig6hu a6mkJvEPv0bZmWEcEK32O4m8K47zn3CZ3OASaxNvRwcP/f52JZaWohfM1ZJJsFLJXGSgbWV/bKUZ6 7gYYxPklySnpkEbTy5P9avbDPA3NpOGfUM1CGI84L8ugPjkFm8ev681WvRFemyIPYnxxVUthpMADN Uais7Cr8neEFRIHsunipeUF2J+xSygqesprSN+hQg926kq2OLv3wcdExtO5hMlr8xK7SHKpUmckVr HnJsgEyg==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpJA-0003JZ-NJ; Thu, 21 May 2020 17:48:41 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 27/49] sctp: pass a kernel pointer to sctp_setsockopt_active_key Date: Thu, 21 May 2020 19:47:02 +0200 Message-Id: <20200521174724.2635475-28-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index d3442dcd49aa8..88514a17654a7 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -3651,42 +3651,39 @@ static int sctp_setsockopt_auth_key(struct sock *sk, * the association shared key. */ static int sctp_setsockopt_active_key(struct sock *sk, - char __user *optval, + struct sctp_authkeyid *val, unsigned int optlen) { struct sctp_endpoint *ep = sctp_sk(sk)->ep; struct sctp_association *asoc; - struct sctp_authkeyid val; int ret = 0; if (optlen != sizeof(struct sctp_authkeyid)) return -EINVAL; - if (copy_from_user(&val, optval, optlen)) - return -EFAULT; - asoc = sctp_id2assoc(sk, val.scact_assoc_id); - if (!asoc && val.scact_assoc_id > SCTP_ALL_ASSOC && + asoc = sctp_id2assoc(sk, val->scact_assoc_id); + if (!asoc && val->scact_assoc_id > SCTP_ALL_ASSOC && sctp_style(sk, UDP)) return -EINVAL; if (asoc) - return sctp_auth_set_active_key(ep, asoc, val.scact_keynumber); + return sctp_auth_set_active_key(ep, asoc, val->scact_keynumber); if (sctp_style(sk, TCP)) - val.scact_assoc_id = SCTP_FUTURE_ASSOC; + val->scact_assoc_id = SCTP_FUTURE_ASSOC; - if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || - val.scact_assoc_id == SCTP_ALL_ASSOC) { - ret = sctp_auth_set_active_key(ep, asoc, val.scact_keynumber); + if (val->scact_assoc_id == SCTP_FUTURE_ASSOC || + val->scact_assoc_id == SCTP_ALL_ASSOC) { + ret = sctp_auth_set_active_key(ep, asoc, val->scact_keynumber); if (ret) return ret; } - if (val.scact_assoc_id == SCTP_CURRENT_ASSOC || - val.scact_assoc_id == SCTP_ALL_ASSOC) { + if (val->scact_assoc_id == SCTP_CURRENT_ASSOC || + val->scact_assoc_id == SCTP_ALL_ASSOC) { list_for_each_entry(asoc, &ep->asocs, asocs) { int res = sctp_auth_set_active_key(ep, asoc, - val.scact_keynumber); + val->scact_keynumber); if (res && !ret) ret = res; @@ -4685,7 +4682,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_auth_key(sk, kopt, optlen); break; case SCTP_AUTH_ACTIVE_KEY: - retval = sctp_setsockopt_active_key(sk, optval, optlen); + retval = sctp_setsockopt_active_key(sk, kopt, optlen); break; case SCTP_AUTH_DELETE_KEY: retval = sctp_setsockopt_del_key(sk, optval, optlen); From patchwork Thu May 21 17:47:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218792 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F6C5C433E0 for ; Thu, 21 May 2020 17:49:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 00E4720829 for ; Thu, 21 May 2020 17:49:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="LCm4CqYR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730366AbgEURsw (ORCPT ); Thu, 21 May 2020 13:48:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730357AbgEURst (ORCPT ); Thu, 21 May 2020 13:48:49 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC5D0C061A0F; Thu, 21 May 2020 10:48:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=gM6y0Fs0opQzXquIVwkWoZa9s9AjgwaxY2IZTBk9C0U=; b=LCm4CqYRghUAe5awDIKZgS3XYU VKnqjdJ+vpcPWr1LxoCSfWTR6/kYNx0WrckdGTRlx6EJk4tes9GoI+JyNmu7HOIbjbTWz3oaLWUDx R3IN8seq+oNID+9TQYfwEzx+1ZxUoCs/+eqRntlaIs0buush9YU9CjI3RbNOZC7tcYRI9SW/Ynttf lw5k7jTFW8WwIrM/u+23jfSXyiprKqdIM6YVMlQRRYUabp0u4DMPBt8RQKhDBw3FLrxxuCCvIXBRy DBK9t2dNZJS5x/Fp3LLF7G1b3VEvJYy8qxbJZfklNrvr/ceiS+8P+wyz3GHS2YHNa4a+RxDW2/moQ SHDySgEg==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpJD-0003Jx-3H; Thu, 21 May 2020 17:48:43 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 28/49] sctp: pass a kernel pointer to sctp_setsockopt_del_key Date: Thu, 21 May 2020 19:47:03 +0200 Message-Id: <20200521174724.2635475-29-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 88514a17654a7..a664e9eb323fb 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -3699,42 +3699,39 @@ static int sctp_setsockopt_active_key(struct sock *sk, * This set option will delete a shared secret key from use. */ static int sctp_setsockopt_del_key(struct sock *sk, - char __user *optval, + struct sctp_authkeyid *val, unsigned int optlen) { struct sctp_endpoint *ep = sctp_sk(sk)->ep; struct sctp_association *asoc; - struct sctp_authkeyid val; int ret = 0; if (optlen != sizeof(struct sctp_authkeyid)) return -EINVAL; - if (copy_from_user(&val, optval, optlen)) - return -EFAULT; - asoc = sctp_id2assoc(sk, val.scact_assoc_id); - if (!asoc && val.scact_assoc_id > SCTP_ALL_ASSOC && + asoc = sctp_id2assoc(sk, val->scact_assoc_id); + if (!asoc && val->scact_assoc_id > SCTP_ALL_ASSOC && sctp_style(sk, UDP)) return -EINVAL; if (asoc) - return sctp_auth_del_key_id(ep, asoc, val.scact_keynumber); + return sctp_auth_del_key_id(ep, asoc, val->scact_keynumber); if (sctp_style(sk, TCP)) - val.scact_assoc_id = SCTP_FUTURE_ASSOC; + val->scact_assoc_id = SCTP_FUTURE_ASSOC; - if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || - val.scact_assoc_id == SCTP_ALL_ASSOC) { - ret = sctp_auth_del_key_id(ep, asoc, val.scact_keynumber); + if (val->scact_assoc_id == SCTP_FUTURE_ASSOC || + val->scact_assoc_id == SCTP_ALL_ASSOC) { + ret = sctp_auth_del_key_id(ep, asoc, val->scact_keynumber); if (ret) return ret; } - if (val.scact_assoc_id == SCTP_CURRENT_ASSOC || - val.scact_assoc_id == SCTP_ALL_ASSOC) { + if (val->scact_assoc_id == SCTP_CURRENT_ASSOC || + val->scact_assoc_id == SCTP_ALL_ASSOC) { list_for_each_entry(asoc, &ep->asocs, asocs) { int res = sctp_auth_del_key_id(ep, asoc, - val.scact_keynumber); + val->scact_keynumber); if (res && !ret) ret = res; @@ -4685,7 +4682,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_active_key(sk, kopt, optlen); break; case SCTP_AUTH_DELETE_KEY: - retval = sctp_setsockopt_del_key(sk, optval, optlen); + retval = sctp_setsockopt_del_key(sk, kopt, optlen); break; case SCTP_AUTH_DEACTIVATE_KEY: retval = sctp_setsockopt_deactivate_key(sk, optval, optlen); From patchwork Thu May 21 17:47:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218793 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EF62C433DF for ; Thu, 21 May 2020 17:49:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E67D5207F7 for ; Thu, 21 May 2020 17:49:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="tPw7joQY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730386AbgEURs4 (ORCPT ); Thu, 21 May 2020 13:48:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730369AbgEURsx (ORCPT ); Thu, 21 May 2020 13:48:53 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEB49C061A0E; Thu, 21 May 2020 10:48:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=QhjTnbbyAWJatFw6lxgPgg1rL8J0LDpK4JJ9WUs6mlw=; b=tPw7joQYNFOl1IE9VVpOM6J4aB g+G70+YSHIFPKU9i5jI4YprBPklUbTWmbQ8+k1l1l0oJjD8Cj7QHggbng4E4hZ/MyKoePrGhCYNSl ggTER/BHsa2Mr2LJEK0NG37HssNCzY/dtSfNW63U7gQXbFX9/nahxBG3OGAs8NyTDcbIj6QXXeDS2 jaYMHGwKhc+tTUlEO5rCax0TbZsyoht9d/dQA1gW0X7ZuXPZUU1m80rqrXgXg0mmbA8Dx2KdAnOTT HcxNmvK5bNJ82bwZYkx9VP7M4YZebAKMoRBj0HJXIe2dqCcQ6gaH6KnS80LoZrHhjVmjIN3UWnrgW Rlk83bzg==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpJL-0003LV-Cy; Thu, 21 May 2020 17:48:51 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 31/49] sctp: pass a kernel pointer to sctp_setsockopt_paddr_thresholds Date: Thu, 21 May 2020 19:47:06 +0200 Message-Id: <20200521174724.2635475-32-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 53 ++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 04eac086831f0..a2aa1e309d595 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -3836,10 +3836,9 @@ static int sctp_setsockopt_auto_asconf(struct sock *sk, int *val, * http://www.ietf.org/id/draft-nishida-tsvwg-sctp-failover-05.txt */ static int sctp_setsockopt_paddr_thresholds(struct sock *sk, - char __user *optval, + struct sctp_paddrthlds_v2 *val, unsigned int optlen, bool v2) { - struct sctp_paddrthlds_v2 val; struct sctp_transport *trans; struct sctp_association *asoc; int len; @@ -3847,55 +3846,53 @@ static int sctp_setsockopt_paddr_thresholds(struct sock *sk, len = v2 ? sizeof(val) : sizeof(struct sctp_paddrthlds); if (optlen < len) return -EINVAL; - if (copy_from_user(&val, optval, len)) - return -EFAULT; - if (v2 && val.spt_pathpfthld > val.spt_pathcpthld) + if (v2 && val->spt_pathpfthld > val->spt_pathcpthld) return -EINVAL; - if (!sctp_is_any(sk, (const union sctp_addr *)&val.spt_address)) { - trans = sctp_addr_id2transport(sk, &val.spt_address, - val.spt_assoc_id); + if (!sctp_is_any(sk, (const union sctp_addr *)&val->spt_address)) { + trans = sctp_addr_id2transport(sk, &val->spt_address, + val->spt_assoc_id); if (!trans) return -ENOENT; - if (val.spt_pathmaxrxt) - trans->pathmaxrxt = val.spt_pathmaxrxt; + if (val->spt_pathmaxrxt) + trans->pathmaxrxt = val->spt_pathmaxrxt; if (v2) - trans->ps_retrans = val.spt_pathcpthld; - trans->pf_retrans = val.spt_pathpfthld; + trans->ps_retrans = val->spt_pathcpthld; + trans->pf_retrans = val->spt_pathpfthld; return 0; } - asoc = sctp_id2assoc(sk, val.spt_assoc_id); - if (!asoc && val.spt_assoc_id != SCTP_FUTURE_ASSOC && + asoc = sctp_id2assoc(sk, val->spt_assoc_id); + if (!asoc && val->spt_assoc_id != SCTP_FUTURE_ASSOC && sctp_style(sk, UDP)) return -EINVAL; if (asoc) { list_for_each_entry(trans, &asoc->peer.transport_addr_list, transports) { - if (val.spt_pathmaxrxt) - trans->pathmaxrxt = val.spt_pathmaxrxt; + if (val->spt_pathmaxrxt) + trans->pathmaxrxt = val->spt_pathmaxrxt; if (v2) - trans->ps_retrans = val.spt_pathcpthld; - trans->pf_retrans = val.spt_pathpfthld; + trans->ps_retrans = val->spt_pathcpthld; + trans->pf_retrans = val->spt_pathpfthld; } - if (val.spt_pathmaxrxt) - asoc->pathmaxrxt = val.spt_pathmaxrxt; + if (val->spt_pathmaxrxt) + asoc->pathmaxrxt = val->spt_pathmaxrxt; if (v2) - asoc->ps_retrans = val.spt_pathcpthld; - asoc->pf_retrans = val.spt_pathpfthld; + asoc->ps_retrans = val->spt_pathcpthld; + asoc->pf_retrans = val->spt_pathpfthld; } else { struct sctp_sock *sp = sctp_sk(sk); - if (val.spt_pathmaxrxt) - sp->pathmaxrxt = val.spt_pathmaxrxt; + if (val->spt_pathmaxrxt) + sp->pathmaxrxt = val->spt_pathmaxrxt; if (v2) - sp->ps_retrans = val.spt_pathcpthld; - sp->pf_retrans = val.spt_pathpfthld; + sp->ps_retrans = val->spt_pathcpthld; + sp->pf_retrans = val->spt_pathpfthld; } return 0; @@ -4686,11 +4683,11 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_auto_asconf(sk, kopt, optlen); break; case SCTP_PEER_ADDR_THLDS: - retval = sctp_setsockopt_paddr_thresholds(sk, optval, optlen, + retval = sctp_setsockopt_paddr_thresholds(sk, kopt, optlen, false); break; case SCTP_PEER_ADDR_THLDS_V2: - retval = sctp_setsockopt_paddr_thresholds(sk, optval, optlen, + retval = sctp_setsockopt_paddr_thresholds(sk, kopt, optlen, true); break; case SCTP_RECVRCVINFO: From patchwork Thu May 21 17:47:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218794 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 341D1C433E0 for ; Thu, 21 May 2020 17:48:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13D43207F7 for ; Thu, 21 May 2020 17:48:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="eZsFjT4Z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730399AbgEURs6 (ORCPT ); Thu, 21 May 2020 13:48:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730382AbgEURsz (ORCPT ); Thu, 21 May 2020 13:48:55 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50716C061A0E; Thu, 21 May 2020 10:48:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=LGgjnUDD7/tNYRvFOkgjYDhRsSm/aq2XucU7vT1iu30=; b=eZsFjT4Z3lDCaYWrwDrzYiaHN2 IqAGWVOAFl2wcm1brlABhC+UHyt55NhoRHkgfNpLezdsXJLM4KS9DunXsZtnN4d5vRvpsJ7JP5GTw OXFIKRtgv0LyEzA/uK3ZV90WBMDWg1hDZvKUCPeBb8vPji3lS5Ya0qpCz3D83Rh1+hH168KMJXbPZ q6a9lthqF5ioX8orzs3smAcYHUv3j3wI8IKNkw0wbnjPm9uoy+Cj3esfn3xekdWPg+V1ihkFQndVO 5ZRF/DD49YCMJmdRvnTOOMGxyDLnAQCEAtsgNAmDY1YA6vRXFQiJSqVwoP6Hd0Po+9bMwvVJkX8tr UNOYrLtg==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpJN-0003MA-Qr; Thu, 21 May 2020 17:48:54 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 32/49] sctp: pass a kernel pointer to sctp_setsockopt_recvrcvinfo Date: Thu, 21 May 2020 19:47:07 +0200 Message-Id: <20200521174724.2635475-33-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index a2aa1e309d595..e4b537e6d61da 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -3898,18 +3898,13 @@ static int sctp_setsockopt_paddr_thresholds(struct sock *sk, return 0; } -static int sctp_setsockopt_recvrcvinfo(struct sock *sk, - char __user *optval, +static int sctp_setsockopt_recvrcvinfo(struct sock *sk, int *val, unsigned int optlen) { - int val; - if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *) optval)) - return -EFAULT; - sctp_sk(sk)->recvrcvinfo = (val == 0) ? 0 : 1; + sctp_sk(sk)->recvrcvinfo = (*val == 0) ? 0 : 1; return 0; } @@ -4691,7 +4686,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, true); break; case SCTP_RECVRCVINFO: - retval = sctp_setsockopt_recvrcvinfo(sk, optval, optlen); + retval = sctp_setsockopt_recvrcvinfo(sk, kopt, optlen); break; case SCTP_RECVNXTINFO: retval = sctp_setsockopt_recvnxtinfo(sk, optval, optlen); From patchwork Thu May 21 17:47:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD364C433E0 for ; Thu, 21 May 2020 17:49:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F57320829 for ; Thu, 21 May 2020 17:49:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="qvDb+ii6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728541AbgEURtG (ORCPT ); Thu, 21 May 2020 13:49:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730382AbgEURtA (ORCPT ); Thu, 21 May 2020 13:49:00 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E082C061A0E; Thu, 21 May 2020 10:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=2g0u4o8Rvmwnji3cNAjrXaCaw/C+5697blWlj0zWtyA=; b=qvDb+ii6xtpMIuGfzmmMn3NENY W1uVexQ8lNKX13amLA/hy9Z0Ne8RjJRfvg+N4vR0zQb8OJqTwpIAwRBj+eMpEm50ln1YIWa0uCCOV lLqy4ZGK8+fCLAP1lU34qYLsFols4b2Zu+YtE1tfSYl/asTc8CZ3HjXQpYzyUbXCg4eGZQUItC4nZ 6krYKAwaBZlj2QERw0r5chGR1vAjvJ7epF0S6Y97K8gXXvcc9YPVrZutZSOEoEmNtlUxBoMKpdw1J Kyam668iCCa9R0Pzk/yjDP3x5QUUYtgxz3PDIu0joHG7NL++2bZ9ZF8elDn2AmODWvGQRuD5k61UZ 6+aSpVzw==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpJS-0003Mx-PH; Thu, 21 May 2020 17:48:59 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 34/49] sctp: pass a kernel pointer to sctp_setsockopt_pr_supported Date: Thu, 21 May 2020 19:47:09 +0200 Message-Id: <20200521174724.2635475-35-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index fe8d1ea7d9c35..fb7ed11382af1 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -3921,24 +3921,20 @@ static int sctp_setsockopt_recvnxtinfo(struct sock *sk, int *val, } static int sctp_setsockopt_pr_supported(struct sock *sk, - char __user *optval, + struct sctp_assoc_value *params, unsigned int optlen) { - struct sctp_assoc_value params; struct sctp_association *asoc; - if (optlen != sizeof(params)) + if (optlen != sizeof(*params)) return -EINVAL; - if (copy_from_user(¶ms, optval, optlen)) - return -EFAULT; - - asoc = sctp_id2assoc(sk, params.assoc_id); - if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC && + asoc = sctp_id2assoc(sk, params->assoc_id); + if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC && sctp_style(sk, UDP)) return -EINVAL; - sctp_sk(sk)->ep->prsctp_enable = !!params.assoc_value; + sctp_sk(sk)->ep->prsctp_enable = !!params->assoc_value; return 0; } @@ -4687,7 +4683,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_recvnxtinfo(sk, kopt, optlen); break; case SCTP_PR_SUPPORTED: - retval = sctp_setsockopt_pr_supported(sk, optval, optlen); + retval = sctp_setsockopt_pr_supported(sk, kopt, optlen); break; case SCTP_DEFAULT_PRINFO: retval = sctp_setsockopt_default_prinfo(sk, optval, optlen); From patchwork Thu May 21 17:47:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218790 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD3E2C433E0 for ; Thu, 21 May 2020 17:49:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9FCDA207F7 for ; Thu, 21 May 2020 17:49:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="YjMqvKB1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730410AbgEURtJ (ORCPT ); Thu, 21 May 2020 13:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730413AbgEURtF (ORCPT ); Thu, 21 May 2020 13:49:05 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8327C061A0E; Thu, 21 May 2020 10:49:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=A4RhtAlMgtV+Kx8yN7Qg619HsYQu5dhP4W31YOOBSSs=; b=YjMqvKB1ihEEls1yt7enB1lR+c 06iz1KNEVKQTTLHwGJiQ966iSj7Roe/SNce72zQZ2QDg2rb2zUYhbksux9r6ZNuXTU+rQ8WyRIP// UU641ZqsvBxFISVoh6id/hlfs4NzmffkYtafQbiivOTNF/2KEKYCHeMifrdanAOWVS9Wk1b7MIKKd 3GA3wBMTRrfCpt3Ml0+SNIjvuZFujRsej5sKqzKTqYAGIoXjYvYWWXLLdVmEaOGH6WaB6mJ02OFLv MwL6NiKmILUvayrP3sbbWgS1ZkN1cf+HtCvnZ65RNx0KRKjpwjVhun+pcbSpKIjLw9IMMuPjUdbni jAzF/CyA==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpJY-0003Ns-8t; Thu, 21 May 2020 17:49:04 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 36/49] sctp: pass a kernel pointer to sctp_setsockopt_reconfig_supported Date: Thu, 21 May 2020 19:47:11 +0200 Message-Id: <20200521174724.2635475-37-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 6136f863095ef..9173b1b80ee17 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -3992,27 +3992,21 @@ static int sctp_setsockopt_default_prinfo(struct sock *sk, } static int sctp_setsockopt_reconfig_supported(struct sock *sk, - char __user *optval, + struct sctp_assoc_value *params, unsigned int optlen) { - struct sctp_assoc_value params; struct sctp_association *asoc; int retval = -EINVAL; - if (optlen != sizeof(params)) - goto out; - - if (copy_from_user(¶ms, optval, optlen)) { - retval = -EFAULT; + if (optlen != sizeof(*params)) goto out; - } - asoc = sctp_id2assoc(sk, params.assoc_id); - if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC && + asoc = sctp_id2assoc(sk, params->assoc_id); + if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC && sctp_style(sk, UDP)) goto out; - sctp_sk(sk)->ep->reconf_enable = !!params.assoc_value; + sctp_sk(sk)->ep->reconf_enable = !!params->assoc_value; retval = 0; @@ -4684,7 +4678,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_default_prinfo(sk, kopt, optlen); break; case SCTP_RECONFIG_SUPPORTED: - retval = sctp_setsockopt_reconfig_supported(sk, optval, optlen); + retval = sctp_setsockopt_reconfig_supported(sk, kopt, optlen); break; case SCTP_ENABLE_STREAM_RESET: retval = sctp_setsockopt_enable_strreset(sk, optval, optlen); From patchwork Thu May 21 17:47:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8531C433DF for ; Thu, 21 May 2020 17:49:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A92E9207F7 for ; Thu, 21 May 2020 17:49:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="VBsmE1rJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730435AbgEURtN (ORCPT ); Thu, 21 May 2020 13:49:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730423AbgEURtI (ORCPT ); Thu, 21 May 2020 13:49:08 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7801EC061A0E; Thu, 21 May 2020 10:49:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=KZlu0a1RPDpdqPU/N0DSqR5fWS88/PeOym7SITiFHXA=; b=VBsmE1rJ9xw8r63SaTAquetVZw oRSzgFYZ4Bk81X4TnhQgbem7EyvVjWXw/vo3o/zbmU5gG/EjxlLdYOhDD431yoMLtKuk49F+D0KeK GP9KO1+IdSK+hGojARoM+uyVm/N+MmQqOX0k0eqfSDtn8FAKja+fOuQ50HryUgHiEMIWROfbPcS5F AOznT4lqhwAjH7K+81qJZbABfdLFGSkyYTynmQS1O7UjWYc+tr9vLmF8kAYNrnIf2FBmwWw9FDv1J otARvY15d8YV+2+lBOBkc8QghIGF1V2y4ZCA9hUGdBL2N8DmB5VcE1e5oFNm0GUadvw/GT58VbiTd 5KAr5m+g==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpJa-0003OG-TV; Thu, 21 May 2020 17:49:07 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 37/49] sctp: pass a kernel pointer to sctp_setsockopt_enable_strreset Date: Thu, 21 May 2020 19:47:12 +0200 Message-Id: <20200521174724.2635475-38-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 9173b1b80ee17..c5a4e9375bb55 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -4015,48 +4015,42 @@ static int sctp_setsockopt_reconfig_supported(struct sock *sk, } static int sctp_setsockopt_enable_strreset(struct sock *sk, - char __user *optval, + struct sctp_assoc_value *params, unsigned int optlen) { struct sctp_endpoint *ep = sctp_sk(sk)->ep; - struct sctp_assoc_value params; struct sctp_association *asoc; int retval = -EINVAL; - if (optlen != sizeof(params)) - goto out; - - if (copy_from_user(¶ms, optval, optlen)) { - retval = -EFAULT; + if (optlen != sizeof(*params)) goto out; - } - if (params.assoc_value & (~SCTP_ENABLE_STRRESET_MASK)) + if (params->assoc_value & (~SCTP_ENABLE_STRRESET_MASK)) goto out; - asoc = sctp_id2assoc(sk, params.assoc_id); - if (!asoc && params.assoc_id > SCTP_ALL_ASSOC && + asoc = sctp_id2assoc(sk, params->assoc_id); + if (!asoc && params->assoc_id > SCTP_ALL_ASSOC && sctp_style(sk, UDP)) goto out; retval = 0; if (asoc) { - asoc->strreset_enable = params.assoc_value; + asoc->strreset_enable = params->assoc_value; goto out; } if (sctp_style(sk, TCP)) - params.assoc_id = SCTP_FUTURE_ASSOC; + params->assoc_id = SCTP_FUTURE_ASSOC; - if (params.assoc_id == SCTP_FUTURE_ASSOC || - params.assoc_id == SCTP_ALL_ASSOC) - ep->strreset_enable = params.assoc_value; + if (params->assoc_id == SCTP_FUTURE_ASSOC || + params->assoc_id == SCTP_ALL_ASSOC) + ep->strreset_enable = params->assoc_value; - if (params.assoc_id == SCTP_CURRENT_ASSOC || - params.assoc_id == SCTP_ALL_ASSOC) + if (params->assoc_id == SCTP_CURRENT_ASSOC || + params->assoc_id == SCTP_ALL_ASSOC) list_for_each_entry(asoc, &ep->asocs, asocs) - asoc->strreset_enable = params.assoc_value; + asoc->strreset_enable = params->assoc_value; out: return retval; @@ -4681,7 +4675,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_reconfig_supported(sk, kopt, optlen); break; case SCTP_ENABLE_STREAM_RESET: - retval = sctp_setsockopt_enable_strreset(sk, optval, optlen); + retval = sctp_setsockopt_enable_strreset(sk, kopt, optlen); break; case SCTP_RESET_STREAMS: retval = sctp_setsockopt_reset_streams(sk, optval, optlen); From patchwork Thu May 21 17:47:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218788 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D09B1C433E0 for ; Thu, 21 May 2020 17:49:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A1DAB207F7 for ; Thu, 21 May 2020 17:49:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="hYB1AfNt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730456AbgEURtT (ORCPT ); Thu, 21 May 2020 13:49:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728455AbgEURtQ (ORCPT ); Thu, 21 May 2020 13:49:16 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EC9BC061A0E; Thu, 21 May 2020 10:49:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=H+5x+DixtPFUc8G/CM8QavdCywZMjYxsxgqxbqm03D8=; b=hYB1AfNtPSgqoflB2UqnbRaGjJ xJPkSER5Qu4DaCF5lXsjRwBGXc+E5QS8syVahTe/fw42csfqB3mZzGNofFMDjJ/L9YOem+LRngKJP JIu8v+deR7jEniuE8GLI001evZMMKiH5CNj2nVT92e/dsW4unJFVP56oqZHfk+85f6mW/XLoZEk8P 58KoDxVcx4df87NUpzsWWM9W7P2zrlx4w96DlL1eKX98smT5jwzCeTJT9f095L+xE3+kopdizXhBt 2SMQYZvYOdC2pFc9/hYBFKLvzxYEAHUmPB/L745s6aVreksO+s/MsdD5VWrAyur0+w84FzB9tgG95 WLYsDUzw==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpJi-0003PR-Gv; Thu, 21 May 2020 17:49:14 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 40/49] sctp: pass a kernel pointer to sctp_setsockopt_add_streams Date: Thu, 21 May 2020 19:47:15 +0200 Message-Id: <20200521174724.2635475-41-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 185c07916281c..84881913dbc7f 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -4095,29 +4095,19 @@ static int sctp_setsockopt_reset_assoc(struct sock *sk, sctp_assoc_t *associd, } static int sctp_setsockopt_add_streams(struct sock *sk, - char __user *optval, + struct sctp_add_streams *params, unsigned int optlen) { struct sctp_association *asoc; - struct sctp_add_streams params; - int retval = -EINVAL; - - if (optlen != sizeof(params)) - goto out; - if (copy_from_user(¶ms, optval, optlen)) { - retval = -EFAULT; - goto out; - } + if (optlen != sizeof(*params)) + return -EINVAL; - asoc = sctp_id2assoc(sk, params.sas_assoc_id); + asoc = sctp_id2assoc(sk, params->sas_assoc_id); if (!asoc) - goto out; - - retval = sctp_send_add_streams(asoc, ¶ms); + return -EINVAL; -out: - return retval; + return sctp_send_add_streams(asoc, params); } static int sctp_setsockopt_scheduler(struct sock *sk, @@ -4663,7 +4653,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_reset_assoc(sk, kopt, optlen); break; case SCTP_ADD_STREAMS: - retval = sctp_setsockopt_add_streams(sk, optval, optlen); + retval = sctp_setsockopt_add_streams(sk, kopt, optlen); break; case SCTP_STREAM_SCHEDULER: retval = sctp_setsockopt_scheduler(sk, optval, optlen); From patchwork Thu May 21 17:47:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218787 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35244C433E0 for ; Thu, 21 May 2020 17:49:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 00CFD20826 for ; Thu, 21 May 2020 17:49:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="qe00OQKr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730470AbgEURt2 (ORCPT ); Thu, 21 May 2020 13:49:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730453AbgEURtY (ORCPT ); Thu, 21 May 2020 13:49:24 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B779C061A0E; Thu, 21 May 2020 10:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=5tPMqSURDR0UDtFhBlgZgSBiCIrl7O1eqcFWzN5W/kc=; b=qe00OQKrwINSDpPOYY23V/knsH SZ6ZWydSb8vc2DrkNpmkuu9Zh2rr/N8jgJwtK7qTHDtmGuU8oPa5Cg5dc+u0MgcE7N9uotikWbzMq uR/fThZFTjUHrcEiT+SOLHyZ3fjV5wJJ7G0oeCI1v01tX5JdpAq1TmHigqC4dTSZQLY8rDfxveufh syccO0IKmZefG3KM8sf4hI3X7NROVPuCz0W6fmI1sQTWHyqhcBVf+9Fk0b7EjKPPfxglzrtp6Wc/X AkZkzrwKchQ9ZjMpokta9wxFHkMS65hnxiskp98HH9IOmcf8DLrGdBn2/RUekj/IhlmIHmTK8C0oi 6vzLecWg==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpJn-0003QM-VC; Thu, 21 May 2020 17:49:20 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 42/49] sctp: pass a kernel pointer to sctp_setsockopt_scheduler_value Date: Thu, 21 May 2020 19:47:17 +0200 Message-Id: <20200521174724.2635475-43-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 122e6b95a8f0d..4d61c2885f8f2 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -4154,38 +4154,32 @@ static int sctp_setsockopt_scheduler(struct sock *sk, } static int sctp_setsockopt_scheduler_value(struct sock *sk, - char __user *optval, + struct sctp_stream_value *params, unsigned int optlen) { - struct sctp_stream_value params; struct sctp_association *asoc; int retval = -EINVAL; - if (optlen < sizeof(params)) - goto out; - - optlen = sizeof(params); - if (copy_from_user(¶ms, optval, optlen)) { - retval = -EFAULT; + if (optlen < sizeof(*params)) goto out; - } - asoc = sctp_id2assoc(sk, params.assoc_id); - if (!asoc && params.assoc_id != SCTP_CURRENT_ASSOC && + asoc = sctp_id2assoc(sk, params->assoc_id); + if (!asoc && params->assoc_id != SCTP_CURRENT_ASSOC && sctp_style(sk, UDP)) goto out; if (asoc) { - retval = sctp_sched_set_value(asoc, params.stream_id, - params.stream_value, GFP_KERNEL); + retval = sctp_sched_set_value(asoc, params->stream_id, + params->stream_value, GFP_KERNEL); goto out; } retval = 0; list_for_each_entry(asoc, &sctp_sk(sk)->ep->asocs, asocs) { - int ret = sctp_sched_set_value(asoc, params.stream_id, - params.stream_value, GFP_KERNEL); + int ret = sctp_sched_set_value(asoc, params->stream_id, + params->stream_value, + GFP_KERNEL); if (ret && !retval) /* try to return the 1st error. */ retval = ret; } @@ -4654,7 +4648,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_scheduler(sk, kopt, optlen); break; case SCTP_STREAM_SCHEDULER_VALUE: - retval = sctp_setsockopt_scheduler_value(sk, optval, optlen); + retval = sctp_setsockopt_scheduler_value(sk, kopt, optlen); break; case SCTP_INTERLEAVING_SUPPORTED: retval = sctp_setsockopt_interleaving_supported(sk, optval, From patchwork Thu May 21 17:47:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218784 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4104C433E0 for ; Thu, 21 May 2020 17:49:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9174A207F7 for ; Thu, 21 May 2020 17:49:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Am0a2qW1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730516AbgEURtp (ORCPT ); Thu, 21 May 2020 13:49:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728551AbgEURt0 (ORCPT ); Thu, 21 May 2020 13:49:26 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6334C061A0E; Thu, 21 May 2020 10:49:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=5X42DXlpMmI8hWtS+txSKbPVzoglgqW6DiQuuhKPluo=; b=Am0a2qW1Q3cXJH1IW4OWp+rDao MPhX9ebl6vZb3m5ZazCf/yXymkfOF0hiSg29noWRtMqv3VVXoOgqw1Jj6AvOhPPoDpyKZoNhTfv/8 bRv5SiekxwZ+SrdIiVwu8xGVNtL8xFeThe8UPV+KrqQCzWxNNbtHKNi5eCeSyaygQUhl5GYlqLQ0s hjn1C1VEie3XtOpAU7r2/JZDq0CHrlLAtYnRGzp69GFpbsX+vJn4g0bxcchMuitJudAs/j0up7rSG l8dfD8H7cw8rmRtZ9eoJ+ptrTJ+YpkvLMHPz2k4N2+L3RLM9KPpGFY3QIUz+1mal8kxAu7kU2Vhb1 JcrjyEEw==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpJt-0003RH-4N; Thu, 21 May 2020 17:49:25 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 44/49] sctp: pass a kernel pointer to sctp_setsockopt_reuse_port Date: Thu, 21 May 2020 19:47:19 +0200 Message-Id: <20200521174724.2635475-45-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 48229ffabbaee..c2abf3ab544c3 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -4210,11 +4210,9 @@ static int sctp_setsockopt_interleaving_supported(struct sock *sk, return 0; } -static int sctp_setsockopt_reuse_port(struct sock *sk, char __user *optval, +static int sctp_setsockopt_reuse_port(struct sock *sk, int *val, unsigned int optlen) { - int val; - if (!sctp_style(sk, TCP)) return -EOPNOTSUPP; @@ -4224,10 +4222,7 @@ static int sctp_setsockopt_reuse_port(struct sock *sk, char __user *optval, if (optlen < sizeof(int)) return -EINVAL; - if (get_user(val, (int __user *)optval)) - return -EFAULT; - - sctp_sk(sk)->reuse = !!val; + sctp_sk(sk)->reuse = !!*val; return 0; } @@ -4641,7 +4636,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, optlen); break; case SCTP_REUSE_PORT: - retval = sctp_setsockopt_reuse_port(sk, optval, optlen); + retval = sctp_setsockopt_reuse_port(sk, kopt, optlen); break; case SCTP_EVENT: retval = sctp_setsockopt_event(sk, optval, optlen); From patchwork Thu May 21 17:47:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218786 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0946EC433DF for ; Thu, 21 May 2020 17:49:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DDD8D207F7 for ; Thu, 21 May 2020 17:49:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="bn+SDjG9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730494AbgEURte (ORCPT ); Thu, 21 May 2020 13:49:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730483AbgEURtb (ORCPT ); Thu, 21 May 2020 13:49:31 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B788FC061A0E; Thu, 21 May 2020 10:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=BMkYyDLsRin/OZpBF9efei87s7wdgpDG1Mh/8tA9vhQ=; b=bn+SDjG9aZIrlZNPTXCCaBR8b1 poYVwRL3+OYg7w9+6h/Z7O8dd8Ep6/HpOl2ELAm6I85Ra75IIBKqFUEtxsX3mIyf2a78cTKhRRILG 3sR0CiuO2rA+Lq5wodQNjBMvcI0NnYmghVTKxV++dkOLB/9CYi/1IX/rKa8ge1yw8MTqXVN1ERXlC lwZ9XiyhmoOk2rMit2sJUiG1bpmDQwJqV6BOBpKAMYpBndR2ABzVpaWefVqUa6iVpodS7+srvk4Zr W0UgVe/5PSRmLKYY6nH+fewkhNlPQUmm9QRRvy4N7lmXxsPp3sp7hAOWszDjbwkzCZzDWvyJ/ZV3m NN0StxRw==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpJy-0003SY-4A; Thu, 21 May 2020 17:49:30 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 46/49] sctp: pass a kernel pointer to sctp_setsockopt_event Date: Thu, 21 May 2020 19:47:21 +0200 Message-Id: <20200521174724.2635475-47-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 9b22bb4817830..0aa7265c9c9a0 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -4292,29 +4292,23 @@ static int sctp_setsockopt_event(struct sock *sk, struct sctp_event *param, } static int sctp_setsockopt_asconf_supported(struct sock *sk, - char __user *optval, + struct sctp_assoc_value *params, unsigned int optlen) { - struct sctp_assoc_value params; struct sctp_association *asoc; struct sctp_endpoint *ep; int retval = -EINVAL; - if (optlen != sizeof(params)) - goto out; - - if (copy_from_user(¶ms, optval, optlen)) { - retval = -EFAULT; + if (optlen != sizeof(*params)) goto out; - } - asoc = sctp_id2assoc(sk, params.assoc_id); - if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC && + asoc = sctp_id2assoc(sk, params->assoc_id); + if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC && sctp_style(sk, UDP)) goto out; ep = sctp_sk(sk)->ep; - ep->asconf_enable = !!params.assoc_value; + ep->asconf_enable = !!params->assoc_value; if (ep->asconf_enable && ep->auth_enable) { sctp_auth_ep_add_chunkid(ep, SCTP_CID_ASCONF); @@ -4637,7 +4631,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_event(sk, kopt, optlen); break; case SCTP_ASCONF_SUPPORTED: - retval = sctp_setsockopt_asconf_supported(sk, optval, optlen); + retval = sctp_setsockopt_asconf_supported(sk, kopt, optlen); break; case SCTP_AUTH_SUPPORTED: retval = sctp_setsockopt_auth_supported(sk, optval, optlen); From patchwork Thu May 21 17:47:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 218785 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50E54C433E0 for ; Thu, 21 May 2020 17:49:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 248EB207F7 for ; Thu, 21 May 2020 17:49:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Nw49TnXd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730501AbgEURth (ORCPT ); Thu, 21 May 2020 13:49:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730488AbgEURte (ORCPT ); Thu, 21 May 2020 13:49:34 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C74FC061A0E; Thu, 21 May 2020 10:49:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=6e1szokp+5sGjFPI9p84mi3A9SxRIVAJpz4ADIBp7w8=; b=Nw49TnXd2ec332ZuZsUIWMrDcL P8/x2szFNKUSiQLdiJYiqyMyGqam43vUVrlk/V5nVUR4A0YpuL1Fvh3SI05cJbyQ9x0hPTvv6KaWR ROR6CmczjR+fiwyqExKVs+C4HGo1X5iLnJ+kEDoKj2ileErG1rsF+0ekQedlnvYzU9cK8guBhL0Tb 3tqb4vxjJLmfDwq6ALClKmaBWZzntkK4QIfSIyLa7dE6H21St3GbSUdFWow1+B2o2Vg8z0Gu2aHam qFGCTiwJXn8ZBYWl0cUGl8h2L+U1JNgYp+d8Fxf+/g+gqnTalra3eJmk8TN+7OCFlvcsJf8QVMEly lpdKZkxw==; Received: from [2001:4bb8:18c:5da7:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jbpK0-0003Sr-Hj; Thu, 21 May 2020 17:49:32 +0000 From: Christoph Hellwig To: Vlad Yasevich , Neil Horman , Marcelo Ricardo Leitner Cc: "David S. Miller" , Jakub Kicinski , David Laight , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 47/49] sctp: pass a kernel pointer to sctp_setsockopt_auth_supported Date: Thu, 21 May 2020 19:47:22 +0200 Message-Id: <20200521174724.2635475-48-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521174724.2635475-1-hch@lst.de> References: <20200521174724.2635475-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig --- net/sctp/socket.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 0aa7265c9c9a0..755bb23ffa3c9 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -4322,29 +4322,23 @@ static int sctp_setsockopt_asconf_supported(struct sock *sk, } static int sctp_setsockopt_auth_supported(struct sock *sk, - char __user *optval, + struct sctp_assoc_value *params, unsigned int optlen) { - struct sctp_assoc_value params; struct sctp_association *asoc; struct sctp_endpoint *ep; int retval = -EINVAL; - if (optlen != sizeof(params)) - goto out; - - if (copy_from_user(¶ms, optval, optlen)) { - retval = -EFAULT; + if (optlen != sizeof(*params)) goto out; - } - asoc = sctp_id2assoc(sk, params.assoc_id); - if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC && + asoc = sctp_id2assoc(sk, params->assoc_id); + if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC && sctp_style(sk, UDP)) goto out; ep = sctp_sk(sk)->ep; - if (params.assoc_value) { + if (params->assoc_value) { retval = sctp_auth_init(ep, GFP_KERNEL); if (retval) goto out; @@ -4354,7 +4348,7 @@ static int sctp_setsockopt_auth_supported(struct sock *sk, } } - ep->auth_enable = !!params.assoc_value; + ep->auth_enable = !!params->assoc_value; retval = 0; out: @@ -4634,7 +4628,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_asconf_supported(sk, kopt, optlen); break; case SCTP_AUTH_SUPPORTED: - retval = sctp_setsockopt_auth_supported(sk, optval, optlen); + retval = sctp_setsockopt_auth_supported(sk, kopt, optlen); break; case SCTP_ECN_SUPPORTED: retval = sctp_setsockopt_ecn_supported(sk, optval, optlen);