From patchwork Wed Dec 9 02:01:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Yufen X-Patchwork-Id: 554192 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C730614030D for ; Wed, 9 Dec 2015 13:02:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752141AbbLICCj (ORCPT ); Tue, 8 Dec 2015 21:02:39 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:36952 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750797AbbLICCi (ORCPT ); Tue, 8 Dec 2015 21:02:38 -0500 Received: from 172.24.1.48 (EHLO szxeml432-hub.china.huawei.com) ([172.24.1.48]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BSK29805; Wed, 09 Dec 2015 10:02:04 +0800 (CST) Received: from localhost (10.177.25.132) by szxeml432-hub.china.huawei.com (10.82.67.209) with Microsoft SMTP Server id 14.3.235.1; Wed, 9 Dec 2015 10:01:53 +0800 From: Wang Yufen To: , CC: , , , , Yufen Wang , Eric Dumazet , "Eric W. Biederman" Subject: [PATCH net] net:sysctl fix the confusing corner of tcp_mem Date: Wed, 9 Dec 2015 10:01:49 +0800 Message-ID: <1449626509-3736-1-git-send-email-wangyufen@huawei.com> X-Mailer: git-send-email 1.8.1.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.177.25.132] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.56678B9D.01F6, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 455b5eb132b4d4ee6d142e54266a9421 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Yufen Wang I tried on linux-4.1: linux:~# cat /proc/sys/net/ipv4/tcp_mem 8388608 12582912 16777216 linux:~# echo 1234 >/proc/sys/net/ipv4/tcp_mem -bash: echo: write error: Invalid argument linux:~# cat /proc/sys/net/ipv4/tcp_mem 1234 12582912 16777216 the echo operation got error, but value already written to tcp_mem. If a write() returns an error like EINVAL, we expect no change occurred. This patch fix the confusing corner and makes __do_proc_doulongvec_minmax works the same as __do_proc_dointvec Signed-off-by: Yufen Wang Cc: Eric Dumazet Cc: "Eric W. Biederman" Nacked-by: "Eric W. Biederman" --- kernel/sysctl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/sysctl.c b/kernel/sysctl.c index c3eee4c..e3ee4be 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2318,6 +2318,8 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int bool neg; left -= proc_skip_spaces(&kbuf); + if (!left) + break; err = proc_get_long(&kbuf, &left, &val, &neg, proc_wspace_sep,