From patchwork Thu Apr 13 11:47:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 82941 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp975058vqo; Thu, 13 Apr 2023 04:59:08 -0700 (PDT) X-Google-Smtp-Source: AKy350bjCSW8uDz5ZSLZINrEOT5JrPBt5ugIZx3cVafM0IzsqLEMKTNdnWGuama+dPLSX0ekE9BM X-Received: by 2002:a17:902:e88a:b0:1a2:1a5b:cc69 with SMTP id w10-20020a170902e88a00b001a21a5bcc69mr2103787plg.32.1681387148530; Thu, 13 Apr 2023 04:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681387148; cv=none; d=google.com; s=arc-20160816; b=kwHmh8DZJAdmLcMDYA+1t2/dpkS1EAlV3CiDNbhZaoIgwx19zrH8X2jyUU+0FTi9yl ShNtrhkA0GfmRKtlh4QoNr4TZBKM5k+sdtwFNQqbCfCra8D0mVb78wU9v3DITmAmWHlV SOafEKDAe6ulE2Vbg3wj2rOSQQnfIuqX4SrxdLHlWfYHJWK26DXE31py6CnUXupgtVJx d9z7t0ycrpGOeMMKPK3hVHcignVJJMHnKuIyhDWhA9wrw6lAhHZQsD96bvhyWIbuw36I dHHMWwnkdW+dA/kTkLcoGWI/WOn15Xd744Fv7SKPcZwzcy9AWs7thyLlEwnlR+qcd4Df 1ePQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=IkWNlz3b7FYk1PEMHsbAhYkzgVVeGDybT/ne34LAR4g=; b=pROPHAiGyxKrvRt3OWoW57+rw0KVhBu0FF2yGOs+vRCEBZzB+c83JpqWig+EkxmNK9 tG/CespjOIjFQ9z+c4+OeusCGYVwxGq7NmmoqFeNDjTShnyS6XOWuP7wYrEOLY6zWTZh /ySJ+za8R1JMcl2g4qrXuxrwsUlC+99BZ8pbmf1ex3SR9AqeaggtLCo3Ml9gyMJ5/gvv EZtba6FTclF1/gaTVr0eZKdDgjDpGetGIK5vNnkYiRHxtXbg7/S90/t9ZGXb7j5gvg78 dwjOTgaxzwCtJDZUeeZnxlxiqMg3l9+kCHPJAZTWXPstSSB08RHYnIaB5mEO22/hpsKD hTyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d6-20020a170902b70600b001a507d6feb8si1687545pls.628.2023.04.13.04.58.56; Thu, 13 Apr 2023 04:59:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230060AbjDMLsL (ORCPT + 99 others); Thu, 13 Apr 2023 07:48:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231137AbjDMLr6 (ORCPT ); Thu, 13 Apr 2023 07:47:58 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9AA60AD09; Thu, 13 Apr 2023 04:47:34 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7EC3211FB; Thu, 13 Apr 2023 04:48:03 -0700 (PDT) Received: from e123572-lin.arm.com (e123572-lin.cambridge.arm.com [10.1.194.65]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0E2C93F73F; Thu, 13 Apr 2023 04:47:17 -0700 (PDT) From: Kevin Brodsky To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Kevin Brodsky , Christoph Hellwig , Eric Dumazet , "David S. Miller" , Jakub Kicinski Subject: [PATCH v2 1/3] net: Ensure ->msg_control_user is used for user buffers Date: Thu, 13 Apr 2023 12:47:03 +0100 Message-Id: <20230413114705.157046-2-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230413114705.157046-1-kevin.brodsky@arm.com> References: <20230413114705.157046-1-kevin.brodsky@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763062210568003173?= X-GMAIL-MSGID: =?utf-8?q?1763062210568003173?= Since commit 1f466e1f15cf ("net: cleanly handle kernel vs user buffers for ->msg_control"), pointers to user buffers should be stored in struct msghdr::msg_control_user, instead of the msg_control field. Most users of msg_control have already been converted (where user buffers are involved), but not all of them. This patch attempts to address the remaining cases. An exception is made for null checks, as it should be safe to use msg_control unconditionally for that purpose. Cc: Christoph Hellwig Cc: Eric Dumazet Cc: "David S. Miller" Cc: Jakub Kicinski Signed-off-by: Kevin Brodsky Reviewed-by: Christoph Hellwig --- net/compat.c | 12 ++++++------ net/core/scm.c | 9 ++++++--- net/ipv4/tcp.c | 4 ++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/net/compat.c b/net/compat.c index 161b7bea1f62..000a2e054d4c 100644 --- a/net/compat.c +++ b/net/compat.c @@ -113,7 +113,7 @@ int get_compat_msghdr(struct msghdr *kmsg, #define CMSG_COMPAT_FIRSTHDR(msg) \ (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \ - (struct compat_cmsghdr __user *)((msg)->msg_control) : \ + (struct compat_cmsghdr __user *)((msg)->msg_control_user) : \ (struct compat_cmsghdr __user *)NULL) #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \ @@ -126,7 +126,7 @@ static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *ms struct compat_cmsghdr __user *cmsg, int cmsg_len) { char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len); - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) > + if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control_user) > msg->msg_controllen) return NULL; return (struct compat_cmsghdr __user *)ptr; @@ -225,7 +225,7 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk, int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data) { - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control; + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control_user; struct compat_cmsghdr cmhdr; struct old_timeval32 ctv; struct old_timespec32 cts[3]; @@ -274,7 +274,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat cmlen = CMSG_COMPAT_SPACE(len); if (kmsg->msg_controllen < cmlen) cmlen = kmsg->msg_controllen; - kmsg->msg_control += cmlen; + kmsg->msg_control_user += cmlen; kmsg->msg_controllen -= cmlen; return 0; } @@ -289,7 +289,7 @@ static int scm_max_fds_compat(struct msghdr *msg) void scm_detach_fds_compat(struct msghdr *msg, struct scm_cookie *scm) { struct compat_cmsghdr __user *cm = - (struct compat_cmsghdr __user *)msg->msg_control; + (struct compat_cmsghdr __user *)msg->msg_control_user; unsigned int o_flags = (msg->msg_flags & MSG_CMSG_CLOEXEC) ? O_CLOEXEC : 0; int fdmax = min_t(int, scm_max_fds_compat(msg), scm->fp->count); int __user *cmsg_data = CMSG_COMPAT_DATA(cm); @@ -313,7 +313,7 @@ void scm_detach_fds_compat(struct msghdr *msg, struct scm_cookie *scm) cmlen = CMSG_COMPAT_SPACE(i * sizeof(int)); if (msg->msg_controllen < cmlen) cmlen = msg->msg_controllen; - msg->msg_control += cmlen; + msg->msg_control_user += cmlen; msg->msg_controllen -= cmlen; } } diff --git a/net/core/scm.c b/net/core/scm.c index acb7d776fa6e..3cd7dd377e53 100644 --- a/net/core/scm.c +++ b/net/core/scm.c @@ -250,7 +250,10 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data) } cmlen = min(CMSG_SPACE(len), msg->msg_controllen); - msg->msg_control += cmlen; + if (msg->msg_control_is_user) + msg->msg_control_user += cmlen; + else + msg->msg_control += cmlen; msg->msg_controllen -= cmlen; return 0; @@ -299,7 +302,7 @@ static int scm_max_fds(struct msghdr *msg) void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm) { struct cmsghdr __user *cm = - (__force struct cmsghdr __user *)msg->msg_control; + (__force struct cmsghdr __user *)msg->msg_control_user; unsigned int o_flags = (msg->msg_flags & MSG_CMSG_CLOEXEC) ? O_CLOEXEC : 0; int fdmax = min_t(int, scm_max_fds(msg), scm->fp->count); int __user *cmsg_data = CMSG_USER_DATA(cm); @@ -332,7 +335,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm) cmlen = CMSG_SPACE(i * sizeof(int)); if (msg->msg_controllen < cmlen) cmlen = msg->msg_controllen; - msg->msg_control += cmlen; + msg->msg_control_user += cmlen; msg->msg_controllen -= cmlen; } } diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 288693981b00..6fa7a3fa9abd 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2164,7 +2164,7 @@ static void tcp_zc_finalize_rx_tstamp(struct sock *sk, struct msghdr cmsg_dummy; msg_control_addr = (unsigned long)zc->msg_control; - cmsg_dummy.msg_control = (void *)msg_control_addr; + cmsg_dummy.msg_control_user = (void __user *)msg_control_addr; cmsg_dummy.msg_controllen = (__kernel_size_t)zc->msg_controllen; cmsg_dummy.msg_flags = in_compat_syscall() @@ -2175,7 +2175,7 @@ static void tcp_zc_finalize_rx_tstamp(struct sock *sk, zc->msg_controllen == cmsg_dummy.msg_controllen) { tcp_recv_timestamp(&cmsg_dummy, sk, tss); zc->msg_control = (__u64) - ((uintptr_t)cmsg_dummy.msg_control); + ((uintptr_t)cmsg_dummy.msg_control_user); zc->msg_controllen = (__u64)cmsg_dummy.msg_controllen; zc->msg_flags = (__u32)cmsg_dummy.msg_flags; From patchwork Thu Apr 13 11:47:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 82943 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp976136vqo; Thu, 13 Apr 2023 05:00:53 -0700 (PDT) X-Google-Smtp-Source: AKy350aHfAu1QzbuQDmNhd5yG0MYEgGeoubuyL56q32KljaRiG3oseYNxj9JT2ComlkXD8a9tzZH X-Received: by 2002:a05:6a20:4c89:b0:d8:f312:b3b with SMTP id fq9-20020a056a204c8900b000d8f3120b3bmr2033424pzb.3.1681387252964; Thu, 13 Apr 2023 05:00:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681387252; cv=none; d=google.com; s=arc-20160816; b=UmuIu/K8D8I9hDgrB6b/saYfHW3l/n3fyAz56wOYbHFZ3MwijdUJbYTdr4ahOvX6dy 4/cUuNRnZPATREQPG2cTDvTI9qhV2rZydzA7EwxNgw24a/diPUReEKCCTWo9FE+3rZPx 7dVsebnppbMZEEP6DUNql0C5qx07sUW0fdjU648nRGBXgS+L9wYDBK7njl3SrMQmbY9p zQFMvl8ctWame9R24Hth4om+ZeQ6wb+tCgIQjjcfooNOcD8i33aM407JpKhSzmNsOa8i IKDY5tUSadOpD6U735kfH0J2LVmDaPsw6fx1S4+XT3AYNMR2bMRzpPsWgPyF//B3GGrm XFaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=pCwWEmhODFV1GCAYiZOHwoCnCnyp14wfEjTZBpmh2lA=; b=mLqzeAlN8Jax4LuovkC6xKIC9XCI3uN4aWQiU9ZxKN29EHvRxRFcLIDa5xwatufBM+ sV0JIfC8FNGpUcWqvxg10FnXVV+pKpw2LRk3UU1w2CtRt+Mw1mS4NdE0R7UFtKQCOOse IQZDtirB6OkXoyuOM7insL1ZIMobm4JlF462wRFYW8xzvFbZeIg/1EXDlhtRcX149XvC LV4Vb1TP+Y2ri4LhjqbEmv0+IhgN2xyZJTaGpy+XYbV/Moe1vfkZy7FobDoWSKK4tWPM YymgkaStgRoQwMLjGK3jQiU2PyKUgQ1wJyWQrgXmVY586ZrIgmxT1dQrvisz1/nJ2qb9 GMqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l24-20020a656818000000b0051b2893b8c0si2053728pgt.548.2023.04.13.05.00.38; Thu, 13 Apr 2023 05:00:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231181AbjDMLsO (ORCPT + 99 others); Thu, 13 Apr 2023 07:48:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230469AbjDMLsC (ORCPT ); Thu, 13 Apr 2023 07:48:02 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 68B75A5D0; Thu, 13 Apr 2023 04:47:37 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B0E9B13D5; Thu, 13 Apr 2023 04:48:04 -0700 (PDT) Received: from e123572-lin.arm.com (e123572-lin.cambridge.arm.com [10.1.194.65]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3FFCC3F73F; Thu, 13 Apr 2023 04:47:19 -0700 (PDT) From: Kevin Brodsky To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Kevin Brodsky , Christoph Hellwig , Eric Dumazet , "David S. Miller" , Jakub Kicinski Subject: [PATCH v2 2/3] net/compat: Update msg_control_is_user when setting a kernel pointer Date: Thu, 13 Apr 2023 12:47:04 +0100 Message-Id: <20230413114705.157046-3-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230413114705.157046-1-kevin.brodsky@arm.com> References: <20230413114705.157046-1-kevin.brodsky@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763062320334114841?= X-GMAIL-MSGID: =?utf-8?q?1763062320334114841?= cmsghdr_from_user_compat_to_kern() is an unusual case w.r.t. how the kmsg->msg_control* fields are used. The input struct msghdr holds a pointer to a user buffer, i.e. ksmg->msg_control_user is active. However, upon success, a kernel pointer is stored in kmsg->msg_control. kmsg->msg_control_is_user should therefore be updated accordingly. Cc: Christoph Hellwig Cc: Eric Dumazet Cc: "David S. Miller" Cc: Jakub Kicinski Signed-off-by: Kevin Brodsky Reviewed-by: Christoph Hellwig --- net/compat.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/compat.c b/net/compat.c index 000a2e054d4c..6564720f32b7 100644 --- a/net/compat.c +++ b/net/compat.c @@ -211,6 +211,7 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk, goto Einval; /* Ok, looks like we made it. Hook it up and return success. */ + kmsg->msg_control_is_user = false; kmsg->msg_control = kcmsg_base; kmsg->msg_controllen = kcmlen; return 0; From patchwork Thu Apr 13 11:47:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 82938 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp970976vqo; Thu, 13 Apr 2023 04:50:19 -0700 (PDT) X-Google-Smtp-Source: AKy350bik2IXtDxl1qkBJxeG8XcWfEYcY+wAsUxuMVPN/n4Ahc3HMQ+RihMK87WyHFG8XhqDVa9F X-Received: by 2002:a05:6a20:8987:b0:d9:dfc:4cb6 with SMTP id h7-20020a056a20898700b000d90dfc4cb6mr1847329pzg.35.1681386619559; Thu, 13 Apr 2023 04:50:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681386619; cv=none; d=google.com; s=arc-20160816; b=mj825bhyRtVgv8h7eFzdEv0Y9zAXDBLMOY4Yjeu0G+vo6B82JzKWTGUpJQpIEAoRNz 9d+NjKJgp439uOizkv/odn9obC3jboTusIubt6a8rxVvRR74fjysWqzOV0NMiiVIG8Nk eDqD5P8HfGzySWJ3myVhlA1yhMSMRk9508espJ2aOSNs3HJ9vgILztRuuExeMX2p4Tw+ Xhx9naD4GscymzR5LYtgM30Qs5woDo4Uqv01axXg5rD0qDQL3F5bMyumcQmUGpHdiPhX 98IhIYsa55408BthaMpvM6AK9XS/I2Vit6K7SpYoEAbH89V+TJ7onFDEQEWz8hHdalhD ZSgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Ynf/PWSOSIWvKRvm/dopf02SDVOtm+hyQqKDswVVODY=; b=AiOT6mENg+FmecJO68NqIVQ5dGtjG7gupLpVrw+TX8hKWAe3nVacb6L9DZkxXQag0c iTUIEmvLyVqZups6oi6jMoUY6zr+hhkODbE9BKlLVEVhIUcqDJ6Pz+9j0wIe7IGZEbwA ybbL2O4wEAJI1eH7nNe/lDyMqmsLcrnOVlGpdPfpZm7QeuOg3Z4thncq33ugvCUlftsa 4RjNR+LSm/bzpP0TkLB4cPCMMy+ahPBOM/DsFii5dRRAk7IO1kjaoMvp5mR9AC2ejKZF YBGLDamY1M0Gn2LejK4tEqJooJuLeyI9+5ZZ3ToAx834AKNx9ofMBW8tN17sYctN5U1E uTTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l185-20020a6391c2000000b0051b4a135853si1747804pge.686.2023.04.13.04.50.06; Thu, 13 Apr 2023 04:50:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231342AbjDMLs1 (ORCPT + 99 others); Thu, 13 Apr 2023 07:48:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231204AbjDMLsG (ORCPT ); Thu, 13 Apr 2023 07:48:06 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C82C7AF37; Thu, 13 Apr 2023 04:47:40 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E2377153B; Thu, 13 Apr 2023 04:48:05 -0700 (PDT) Received: from e123572-lin.arm.com (e123572-lin.cambridge.arm.com [10.1.194.65]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 721B33F73F; Thu, 13 Apr 2023 04:47:20 -0700 (PDT) From: Kevin Brodsky To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Kevin Brodsky , Christoph Hellwig , Eric Dumazet , "David S. Miller" , Jakub Kicinski Subject: [PATCH v2 3/3] net/ipv6: Initialise msg_control_is_user Date: Thu, 13 Apr 2023 12:47:05 +0100 Message-Id: <20230413114705.157046-4-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230413114705.157046-1-kevin.brodsky@arm.com> References: <20230413114705.157046-1-kevin.brodsky@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763061656054186064?= X-GMAIL-MSGID: =?utf-8?q?1763061656054186064?= do_ipv6_setsockopt() makes use of struct msghdr::msg_control in the IPV6_2292PKTOPTIONS case. Make sure to initialise msg_control_is_user accordingly. Cc: Christoph Hellwig Cc: Eric Dumazet Cc: "David S. Miller" Cc: Jakub Kicinski Signed-off-by: Kevin Brodsky Reviewed-by: Christoph Hellwig --- net/ipv6/ipv6_sockglue.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 2917dd8d198c..ae818ff46224 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -716,6 +716,7 @@ int do_ipv6_setsockopt(struct sock *sk, int level, int optname, goto done; msg.msg_controllen = optlen; + msg.msg_control_is_user = false; msg.msg_control = (void *)(opt+1); ipc6.opt = opt;