Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6570875ybx; Mon, 11 Nov 2019 11:07:56 -0800 (PST) X-Google-Smtp-Source: APXvYqyaGzsXkZnHpxL22lDCB0h50oc+x7bIUGKEWW77PL9Jf7mAwnSWkiEUeQZZWlVFEZBl84f0 X-Received: by 2002:a17:906:3d2:: with SMTP id c18mr24498249eja.111.1573499276388; Mon, 11 Nov 2019 11:07:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573499276; cv=none; d=google.com; s=arc-20160816; b=UImOg+sn4S7prd3LqrUEkzQtsE9JUkA1euZzv5E6wAO2FGRA6OVH7pOD92lifdsvJt EbaXZbxVQTqEBavj06FjdPT2SAsFTn602pKyq94VgBTtU9jg6MnwytR79U/RHh1jjcIB EdiG1b32x9trOMkirT4OYFYQ2b7y36biti8vKUonx0M+DkmuZlTuL0r2NOx6NmHcjPsv OOGNwBgro1YHJc3KKJnnKK17l9MKvWC6izGTPJ7AUtmTJjHY7cOVmMaPDemoaL/GcqVw 4ueSzcOUbWScAOhGgv4nuoTK7OBtaDEcxf8QFZnAsB2/40InmefgCQVTk918HBohYk/u V1bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=i61l/xXSdStQtOHt39XKe9gg9TVv67S/n15BjDQcOtM=; b=K8csKm2M6blEUrBSJ75l56ZuVppdOw1jGt5qlAYyntjHnvD6U9gSWFifGh+Dk2sBOH RmSLjz+8spAoTygqXN+m/6V/07JG2ulc9EqDB49pZ+A4/UxkbSzp6JbSLjNJvJEF7OUS riYCTd2V/HPhkjHEf3/4ptf/uRbq9BL0UtIuy16HIJbox+yW/+7MPpjjuQM8F6fHR1D2 2l71bOzJ2rMrm3PcHtbEVB5LtzqRKZX24CWvvcbBha/+XioDgdkkOPheB9fR1xqkI+1H 0quAvvvVjcv+2GfYkX0fNgmnx6fK2z8E86AF+dCfEFZFH3wQFuBHnIP59Qu2i3p2aolk BBqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hjXxfJ0h; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h12si10042943ejf.418.2019.11.11.11.07.31; Mon, 11 Nov 2019 11:07:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hjXxfJ0h; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727904AbfKKTEF (ORCPT + 99 others); Mon, 11 Nov 2019 14:04:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:34978 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729644AbfKKSnf (ORCPT ); Mon, 11 Nov 2019 13:43:35 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 1B039204FD; Mon, 11 Nov 2019 18:43:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573497815; bh=q7GsNm40S/DiKtFTZ0JcwUyWixm0EX+jJcNR3wLwS98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hjXxfJ0htm7NpOPbD7vAOBeFUCgk/ItMgCaRYS2y+HT3X/Ddg68PwYhM1/CoRqLCn j8WwcpEG+qb//N2U52xHHTYjbzI7XJQjZ6LwJnlKFl60IIiLcHz06/GlK8usrK9+Ix emVSoMbTmvUjTspNNz3HxnKLvhEhhAdqgVK5+GQs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Jozsef Kadlecsik Subject: [PATCH 4.19 038/125] netfilter: ipset: Fix an error code in ip_set_sockfn_get() Date: Mon, 11 Nov 2019 19:27:57 +0100 Message-Id: <20191111181445.637037706@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181438.945353076@linuxfoundation.org> References: <20191111181438.945353076@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter commit 30b7244d79651460ff114ba8f7987ed94c86b99a upstream. The copy_to_user() function returns the number of bytes remaining to be copied. In this code, that positive return is checked at the end of the function and we return zero/success. What we should do instead is return -EFAULT. Fixes: a7b4f989a629 ("netfilter: ipset: IP set core support") Signed-off-by: Dan Carpenter Signed-off-by: Jozsef Kadlecsik Signed-off-by: Greg Kroah-Hartman --- net/netfilter/ipset/ip_set_core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/net/netfilter/ipset/ip_set_core.c +++ b/net/netfilter/ipset/ip_set_core.c @@ -1977,8 +1977,9 @@ ip_set_sockfn_get(struct sock *sk, int o } req_version->version = IPSET_PROTOCOL; - ret = copy_to_user(user, req_version, - sizeof(struct ip_set_req_version)); + if (copy_to_user(user, req_version, + sizeof(struct ip_set_req_version))) + ret = -EFAULT; goto done; } case IP_SET_OP_GET_BYNAME: { @@ -2035,7 +2036,8 @@ ip_set_sockfn_get(struct sock *sk, int o } /* end of switch(op) */ copy: - ret = copy_to_user(user, data, copylen); + if (copy_to_user(user, data, copylen)) + ret = -EFAULT; done: vfree(data);