Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4800406pxj; Wed, 9 Jun 2021 02:03:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmnNf6hV5Lsv4U4LQpA7Kt9Aw9WMQt/oRIOy6Qk/xJ1XI8+MXZJcyQJb1aRlN348b3z4nz X-Received: by 2002:a17:907:628a:: with SMTP id nd10mr27939709ejc.326.1623229436768; Wed, 09 Jun 2021 02:03:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623229436; cv=none; d=google.com; s=arc-20160816; b=pe16ORRrlsnd9BRexNJAbmK0flGIQ42o7iN0VH++rtrCumRmWmhA1XJ5ZSYloEg+Ru Xnx3DjQ5pD7cU94Ps4WlPx1Orv1HnyUTAlB+Bn2ng1B1zGAzkYzfTkLNY0duQEhQH77/ 2DSwPT3db6O5MuZ7VEjb95vHX6DL2JGsUZv3t2PuWSM0b0xwf/zMgpIOX9Ej7kbDR8iH cdPu7pRwf6xO0BzBfwZbpAJMWprEHydUblMhNQT1eu+YUNLIAQplxzKH2Mwd1crkN+o/ Zc/HOtZ5qlfp4vIQPtRhWO4R6WhAgZ7yq2FKtEwPBOjksb/h870axI+NQGDSPnD7qmdF k/BA== 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=r+aXA/PAHIcSrFw1TdMWzeBcLRjHVjO6rj2bOngy1jw=; b=Q2BTcwKlun8x05rWlb4FAaGF8mS+X6ykJGGmurSWuteVn09qBE70kbTUnEcBrr6h9g 6nYeudtNSrPv1Qn5Wx0785YpR08ii9WF8kE9+vvehgJoetb6fd67pZ7uTwIwkwh5W6Xn zjgoOVq9Ff2F4+a5rDf1l/TVzYI+1jeDCb4kfZ7TiVA7NzFqLSGXPp+pAJqq0F6HVYWW HcDpW3UXyIEIFB4R3fhN7/upbIXF61pLvD3PVywMz048j3oS1NHoJFJ6ZpnSp+u31Ds8 xE6QII1cmZWCcDLBtRxdWx55tcNiRo5TfO79y+DikkYgMaHJwgIm2tMck/b67XQGk1N1 bIMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DFlu7pik; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 29si2022294ejf.673.2021.06.09.02.03.32; Wed, 09 Jun 2021 02:03:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DFlu7pik; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232867AbhFHScV (ORCPT + 99 others); Tue, 8 Jun 2021 14:32:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:56244 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230330AbhFHSbh (ORCPT ); Tue, 8 Jun 2021 14:31:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8DDD461376; Tue, 8 Jun 2021 18:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623176984; bh=dHPTvnook4xNYA5OGHAVgeU+E/PrCK4BuJtHzBDss4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DFlu7piktLqjR4lACGDicCUOSeLhqwz61anhEykaLhKaybTyqE9cbHUUwVNoiMYWR 1YqEK0Q89bxw/5hqk/aIOmXXlTAMh9Tk1TUK86cc2cIs1bA38KkVm50Eg1hI4LDnDo thWgY9xuo/IBIRe83twtOEnVWDvJUCgcsymkCsUI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julian Anastasov , Simon Horman , Pablo Neira Ayuso , Sasha Levin , syzbot+e562383183e4b1766930@syzkaller.appspotmail.com Subject: [PATCH 4.9 07/29] ipvs: ignore IP_VS_SVC_F_HASHED flag when adding service Date: Tue, 8 Jun 2021 20:27:01 +0200 Message-Id: <20210608175928.056505553@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175927.821075974@linuxfoundation.org> References: <20210608175927.821075974@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Julian Anastasov [ Upstream commit 56e4ee82e850026d71223262c07df7d6af3bd872 ] syzbot reported memory leak [1] when adding service with HASHED flag. We should ignore this flag both from sockopt and netlink provided data, otherwise the service is not hashed and not visible while releasing resources. [1] BUG: memory leak unreferenced object 0xffff888115227800 (size 512): comm "syz-executor263", pid 8658, jiffies 4294951882 (age 12.560s) 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: [] kmalloc include/linux/slab.h:556 [inline] [] kzalloc include/linux/slab.h:686 [inline] [] ip_vs_add_service+0x598/0x7c0 net/netfilter/ipvs/ip_vs_ctl.c:1343 [] do_ip_vs_set_ctl+0x810/0xa40 net/netfilter/ipvs/ip_vs_ctl.c:2570 [] nf_setsockopt+0x68/0xa0 net/netfilter/nf_sockopt.c:101 [] ip_setsockopt+0x259/0x1ff0 net/ipv4/ip_sockglue.c:1435 [] raw_setsockopt+0x18c/0x1b0 net/ipv4/raw.c:857 [] __sys_setsockopt+0x1b0/0x360 net/socket.c:2117 [] __do_sys_setsockopt net/socket.c:2128 [inline] [] __se_sys_setsockopt net/socket.c:2125 [inline] [] __x64_sys_setsockopt+0x22/0x30 net/socket.c:2125 [] do_syscall_64+0x3a/0xb0 arch/x86/entry/common.c:47 [] entry_SYSCALL_64_after_hwframe+0x44/0xae Reported-and-tested-by: syzbot+e562383183e4b1766930@syzkaller.appspotmail.com Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Julian Anastasov Reviewed-by: Simon Horman Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/ipvs/ip_vs_ctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c index ba9e711f7e3d..4e08305a55c4 100644 --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c @@ -1256,7 +1256,7 @@ ip_vs_add_service(struct netns_ipvs *ipvs, struct ip_vs_service_user_kern *u, ip_vs_addr_copy(svc->af, &svc->addr, &u->addr); svc->port = u->port; svc->fwmark = u->fwmark; - svc->flags = u->flags; + svc->flags = u->flags & ~IP_VS_SVC_F_HASHED; svc->timeout = u->timeout * HZ; svc->netmask = u->netmask; svc->ipvs = ipvs; -- 2.30.2