Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4006940ybi; Tue, 18 Jun 2019 10:05:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqyj5VCCxGnC2Topobuh1tkSBhiWtUupXTzMfJsg/UNtpZOm1599TelK4Qs53owdyAXHoWWA X-Received: by 2002:a17:902:a60d:: with SMTP id u13mr46463843plq.144.1560877525800; Tue, 18 Jun 2019 10:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560877525; cv=none; d=google.com; s=arc-20160816; b=eFz0l6cWT4EKrCLtWlpoQXm58SOc3F4gy5cAH8jOaWRpCWSbVDHz3NoF2IYjkgAD1B PjZDrIh4cpNY8dx0L7hLkSjFJ1jBmu35XuMeNGsWNNYca2ik5MNZiVdRSz2JOGT9ZqbW t42WUdJQJ8quCti7DVqO/4QmAbcCK7ikmcJQjrx5IQ5bFtWR7DFDXTq8HmGuXLensoH+ c/8vQPD92jlBCXMdQxrqsqRGnFtEy6qxm4eNC6FtWNEP7azydjFBPu71uHZk+r7QFLsF /YOkcHCA72MoAysXWuFZip9/N0adHK46a64s4zVo2/I8vVvO64J43RlZRWFVVxbYxMdr iquQ== 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 :references:in-reply-to:from:subject:cc:to:message-id:date; bh=6Xv9c0qKwjMW/nnVFfXPO6dfPl+gU4rWRIaBLsF55WQ=; b=hv2G4eYIriev1Zo4tVzYtwkRMUfqLsfdgRQFRI+VzsUb2IypIX9MY3Jk81MshYDcPv Jfp/YW/3mVbWLuIEh1y8aKEvLtOzEFI3ErVJiydpEoAJKqBehn+hq93VJzSvO2bmhRAD UWfIkXT5BxJ79V/xn+b7EUv8nr0w/Xq4UBui5MNIzI7og4PrLJ2lQTkjh3MRZJkRpOcW 8stMmUsiGFU9yH2lpmXMj3GpKQoTY2ePdhUEZLW6jdgUY+XQfrTjqaVGQHI8mYlGi3Hb D7TFkodfhj8dAVVZSpBSQvcD1sUckObwVmsc+N3mKXdWuSsni5oo0dVQkM+o0UgpjOdq iPXA== ARC-Authentication-Results: i=1; mx.google.com; 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 y6si644444pgg.386.2019.06.18.10.05.09; Tue, 18 Jun 2019 10:05:25 -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; 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 S1730047AbfFRRE5 (ORCPT + 99 others); Tue, 18 Jun 2019 13:04:57 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:50146 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729541AbfFRRE5 (ORCPT ); Tue, 18 Jun 2019 13:04:57 -0400 Received: from localhost (unknown [IPv6:2601:601:9f80:35cd::3d5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id C36E8150AFBD5; Tue, 18 Jun 2019 10:04:56 -0700 (PDT) Date: Tue, 18 Jun 2019 10:04:56 -0700 (PDT) Message-Id: <20190618.100456.509667574835376076.davem@davemloft.net> To: houjingyi647@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: remove duplicate fetch in sock_getsockopt From: David Miller In-Reply-To: <20190617065605.GA5924@hjy-HP-Notebook> References: <20190617065605.GA5924@hjy-HP-Notebook> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Tue, 18 Jun 2019 10:04:56 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: JingYi Hou Date: Mon, 17 Jun 2019 14:56:05 +0800 > 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 Applied and queued up for -stable, thanks.