From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753797AbdGMPzk (ORCPT ); Thu, 13 Jul 2017 11:55:40 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38790 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753572AbdGMPoQ (ORCPT ); Thu, 13 Jul 2017 11:44:16 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liping Zhang , Subash Abhinov Kasiviswanathan , Andrew Morton , "Eric W. Biederman" , Linus Torvalds Subject: [PATCH 4.4 15/57] sysctl: report EINVAL if value is larger than UINT_MAX for proc_douintvec Date: Thu, 13 Jul 2017 17:42:30 +0200 Message-Id: <20170713153958.720403389@linuxfoundation.org> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170713153957.515045341@linuxfoundation.org> References: <20170713153957.515045341@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Liping Zhang commit 425fffd886bae3d127a08fa6a17f2e31e24ed7ff upstream. Currently, inputting the following command will succeed but actually the value will be truncated: # echo 0x12ffffffff > /proc/sys/net/ipv4/tcp_notsent_lowat This is not friendly to the user, so instead, we should report error when the value is larger than UINT_MAX. Fixes: e7d316a02f68 ("sysctl: handle error writing UINT_MAX to u32 fields") Signed-off-by: Liping Zhang Cc: Subash Abhinov Kasiviswanathan Cc: Andrew Morton Cc: Eric W. Biederman Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- kernel/sysctl.c | 2 ++ 1 file changed, 2 insertions(+) --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2067,6 +2067,8 @@ static int do_proc_douintvec_conv(bool * if (write) { if (*negp) return -EINVAL; + if (*lvalp > UINT_MAX) + return -EINVAL; *valp = *lvalp; } else { unsigned int val = *valp;