Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3051262ybi; Tue, 2 Jul 2019 01:10:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1KpCDujmKMqn721WBmaeFDAAUBMzf/vWIAgt5/UJhQRsrv7cCuYUvENWjSAPqw66dB72w X-Received: by 2002:a17:902:8509:: with SMTP id bj9mr34145156plb.79.1562055013572; Tue, 02 Jul 2019 01:10:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562055013; cv=none; d=google.com; s=arc-20160816; b=eBOQhd9WDmxY5V3HP6kkoBZqE+h8fcmzrekmSbZ71oYRbA/tHIj9wHXcKt281S11Jr Z5MA+SLJook32XszBr0Ujj6/XfmriGBoqONXcD7BUuiIHFov5y6qJuJgaR0WmFumai5j UdbFyp9y2SIHH8ULfsNGDddtxjVJNdZ7NAk0BrxT7WF/Bq2Vv58Nm8BThKJW48fikdJO KqE8Wtt4nKkHVlGWFOkOrcltX6BcAeSG22725KI/ABG0z5/1TiqedDWG5NpKwTd9OQNK uis19xEQKfP6lEo783E94PkyVCfN9Jsovbpia+SC9YkQw6QWCIJZkdnkyiS4rSZxfZPw ncWQ== 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=+l6LA4gClF9wqMNikQ0roat041bnrvdkjZ+x6EYQJTE=; b=NBWFQ9oPOe3OI23CGy32tlBPGd9OvCeRrYiZQux6KgKzyWA4GIsTwHOeaLqn2ZaXnJ mz61axXOooD5skr45ApWr3+O+ny3s1noqJ03WIRj+CIayPSDV0QYkEOx8JDWizPFXvDP JaXxLmVWot9pnkP4JfDfXSsxfW+egP/3LhbCj4plFRzqLj8M1dfVqEW/oGVOsJsfMkIl 57V0qEKR9eWbgiZhvzL1+EAN1aV7xT8rWt6Pj1kPeqHlnHyEc0vShTu7rqmxuPwoZUOR BmnvhGuoXmOe7RBTGv9GVwLpXvdz4xZYbA+bgpgvSIEkHVeaoTMv/p3yv+0zT/XRy+TS uDjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=x09wJTuc; 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 e24si11647323pgh.408.2019.07.02.01.09.58; Tue, 02 Jul 2019 01:10:13 -0700 (PDT) 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=x09wJTuc; 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 S1728285AbfGBIHf (ORCPT + 99 others); Tue, 2 Jul 2019 04:07:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:54866 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727724AbfGBIHe (ORCPT ); Tue, 2 Jul 2019 04:07:34 -0400 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 9257C21479; Tue, 2 Jul 2019 08:07:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562054853; bh=mqaPR9roc8u1JqDgLA/WT7+JVA2ReSlXZxt8V+6uY8g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x09wJTucT1s0XAw063SyAfdWmpHNxKNw82OikI0GfV/uCn5szNy1dyRetGTYQVtc6 Gqe2hTHnAeScJ1De+zcLiQ5WUxRCtKNkeQl/Wh2kzgnM+NxOJgty8jfMYnqv/vTisk RUV+ybdZ+/GFem4KKc35eV3Btd8NrO/yF9BUmGY0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, JingYi Hou , "David S. Miller" Subject: [PATCH 4.19 54/72] net: remove duplicate fetch in sock_getsockopt Date: Tue, 2 Jul 2019 10:01:55 +0200 Message-Id: <20190702080127.383587532@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702080124.564652899@linuxfoundation.org> References: <20190702080124.564652899@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: JingYi Hou [ Upstream commit d0bae4a0e3d8c5690a885204d7eb2341a5b4884d ] In sock_getsockopt(), 'optlen' is fetched the first time from userspace. 'len < 0' is then checked. Then in condition 'SO_MEMINFO', 'optlen' is fetched the second time from userspace. If change it between two fetches may cause security problems or unexpected behaivor, and there is no reason to fetch it a second time. To fix this, we need to remove the second fetch. Signed-off-by: JingYi Hou Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/core/sock.c | 3 --- 1 file changed, 3 deletions(-) --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1348,9 +1348,6 @@ int sock_getsockopt(struct socket *sock, { u32 meminfo[SK_MEMINFO_VARS]; - if (get_user(len, optlen)) - return -EFAULT; - sk_get_meminfo(sk, meminfo); len = min_t(unsigned int, len, sizeof(meminfo));