Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp954951pxb; Wed, 6 Apr 2022 05:14:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDAs6EGOePHUOf4MFmQSx806Zh572UM7hUU7d4Z4ZmeB6wqxkrComccNRzjngmSUMs5MUk X-Received: by 2002:a63:e0a:0:b0:380:fba9:f6e4 with SMTP id d10-20020a630e0a000000b00380fba9f6e4mr6836456pgl.481.1649247281057; Wed, 06 Apr 2022 05:14:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649247281; cv=none; d=google.com; s=arc-20160816; b=fxFvexrJO3sKKjI46ze7WTNoxKRQuZfYTFSZhrcRg67JdOdrEZ4thhEvu28ALjIVKo m0pwU6IyVyRBO+/mieG1zzKT2B0eSnhuWwwbZonsHygls9s3hu34DzU9+LJ/KvF9HlQY edKnaIUJMYHNiSsC5JY8YP+mkVllAxbyTEG21iwwxXf+wXfamFU2s3F9xzo9hHaNGdDd oJe+1LrTCkfyjcEaJJJeRWn4ED3JntgRAlVigmCaK+gBlhdOZGgyC2Z6XcwTB1NnHYNs zyIBKRWy+tzQcTl/2ikGv4QP/dPEwFfygPx1Nwe86WuAvsTTDB8kd8mNI3T4wK9cBAvQ qhAA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Myc9PgzWyqgxDkAbxImqCfr3pDMxMns7U5KIPpGew2w=; b=H+k+g1BobJgMRx7UXL98j/eg3BnnminLNkTmJlH7Jjabk7qFkoThWm39bd1Aig4mtj /AbUv50shCo+z3NGGpHB3u018Obx0rmklAn1Q4tWmtMvjt2rrqky7m5ZyuZZowQcSktM +ogmuagE8wN9/hpCPno0k9qN3ijkXyFBwcKT9ehYKKA/56ayh61YB/YTN9Nk2VwYcb+h 2TCfOAN9sjObdhCjh8nVk5wu3d98dltQfX2lRXlXXwfelUnW01dOQM+80KvFADx835f2 bAdFXIieTlXMLjTaDkJ8/gcYx+U7S7Wu+L11XoyxJgEdb/xCfQjx3U79/h3ieB1wdTlP Q+ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JJeUIFf5; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d21-20020aa78e55000000b004fa842a4794si14464443pfr.214.2022.04.06.05.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:14:41 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JJeUIFf5; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D82BEB1DE; Wed, 6 Apr 2022 03:53:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347577AbiDFB2n (ORCPT + 99 others); Tue, 5 Apr 2022 21:28:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354182AbiDEKMP (ORCPT ); Tue, 5 Apr 2022 06:12:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CD3B52B17; Tue, 5 Apr 2022 02:58:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EE2556172B; Tue, 5 Apr 2022 09:58:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 098CFC385A2; Tue, 5 Apr 2022 09:58:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152688; bh=5zlb1hptJ2v/BAudDlnKXkagzh8LBcBz6czfaqR09DE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JJeUIFf50R1R2Zivvgp2dhiJay9QM1p/kmuLFcewmOr7KEx8kw0EYaADo812GPPGW EesrgBac/OwIrPm+KEgLSRFyEZwFsLWz15kI5SUrsJF7P9xH2D5QdVJBLgs2Mtmo1t P4Ej1fDKEBb5qRXB+RpGyA+iJ/n5JQjVoFI28M3s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wang Hai , "Jason A. Donenfeld" , Jakub Kicinski Subject: [PATCH 5.15 829/913] wireguard: socket: free skb in send6 when ipv6 is disabled Date: Tue, 5 Apr 2022 09:31:31 +0200 Message-Id: <20220405070404.679959400@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Wang Hai commit bbbf962d9460194993ee1943a793a0a0af4a7fbf upstream. I got a memory leak report: unreferenced object 0xffff8881191fc040 (size 232): comm "kworker/u17:0", pid 23193, jiffies 4295238848 (age 3464.870s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [] slab_post_alloc_hook+0x84/0x3b0 [] kmem_cache_alloc_node+0x167/0x340 [] __alloc_skb+0x1db/0x200 [] wg_socket_send_buffer_to_peer+0x3d/0xc0 [] wg_packet_send_handshake_initiation+0xfa/0x110 [] wg_packet_handshake_send_worker+0x21/0x30 [] process_one_work+0x2e8/0x770 [] worker_thread+0x4a/0x4b0 [] kthread+0x120/0x160 [] ret_from_fork+0x1f/0x30 In function wg_socket_send_buffer_as_reply_to_skb() or wg_socket_send_ buffer_to_peer(), the semantics of send6() is required to free skb. But when CONFIG_IPV6 is disable, kfree_skb() is missing. This patch adds it to fix this bug. Signed-off-by: Wang Hai Fixes: e7096c131e51 ("net: WireGuard secure network tunnel") Signed-off-by: Jason A. Donenfeld Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireguard/socket.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/net/wireguard/socket.c +++ b/drivers/net/wireguard/socket.c @@ -160,6 +160,7 @@ out: rcu_read_unlock_bh(); return ret; #else + kfree_skb(skb); return -EAFNOSUPPORT; #endif }