From patchwork Tue Oct 27 13:50:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 313056 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, 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 6A7C9C55178 for ; Tue, 27 Oct 2020 14:08:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C40721D7B for ; Tue, 27 Oct 2020 14:08:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807699; bh=JJMGL4RLKtpAn/y/8PlbHmUpiZ8y01jpw7+6DC6Squk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=b/piVg/s3g4IBJgrcJlWtcHZHSCnsHuR/kpx54pmy7Fms4WON1Eqhue/1ocOro31+ o1Nf9jpDqOKpEuf1q+o3d6+AKnbvuWiMtas99caO5q1NbQzG1mk1b3y97mgobhLm43 WAGu02R1rTy7ejSiTcdoVfCjL6unaUzGmXpd39tY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755090AbgJ0OIS (ORCPT ); Tue, 27 Oct 2020 10:08:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:57264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755083AbgJ0OIQ (ORCPT ); Tue, 27 Oct 2020 10:08:16 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BD15C218AC; Tue, 27 Oct 2020 14:08:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807696; bh=JJMGL4RLKtpAn/y/8PlbHmUpiZ8y01jpw7+6DC6Squk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1i7h5goWpZkhhgY5a1p92e85XJcs6YyFpBES/y/kBJgPBPyvJqcNSaihAEppl7x3d wyyzDAK5Em0FaJMrYz4rchUE8MNt7GGTs5+RSsvhfCy35thwQLnuaPwj39L+UCTO+C N6lpmxkjS11oDDMsw1NpNQPOBtA4BoJZp77m487g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+23b5f9e7caf61d9a3898@syzkaller.appspotmail.com, Julian Anastasov , Peilin Ye , Simon Horman , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.9 130/139] ipvs: Fix uninit-value in do_ip_vs_set_ctl() Date: Tue, 27 Oct 2020 14:50:24 +0100 Message-Id: <20201027134908.324688782@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134902.130312227@linuxfoundation.org> References: <20201027134902.130312227@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Peilin Ye [ Upstream commit c5a8a8498eed1c164afc94f50a939c1a10abf8ad ] do_ip_vs_set_ctl() is referencing uninitialized stack value when `len` is zero. Fix it. Reported-by: syzbot+23b5f9e7caf61d9a3898@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?id=46ebfb92a8a812621a001ef04d90dfa459520fe2 Suggested-by: Julian Anastasov Signed-off-by: Peilin Ye Acked-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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c index 33125fc009cfd..ba9e711f7e3d6 100644 --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c @@ -2424,6 +2424,10 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) /* Set timeout values for (tcp tcpfin udp) */ ret = ip_vs_set_timeout(ipvs, (struct ip_vs_timeout_user *)arg); goto out_unlock; + } else if (!len) { + /* No more commands with len == 0 below */ + ret = -EINVAL; + goto out_unlock; } usvc_compat = (struct ip_vs_service_user *)arg; @@ -2500,9 +2504,6 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) break; case IP_VS_SO_SET_DELDEST: ret = ip_vs_del_dest(svc, &udest); - break; - default: - ret = -EINVAL; } out_unlock: