Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754677AbbHXPeB (ORCPT ); Mon, 24 Aug 2015 11:34:01 -0400 Received: from mail-ig0-f196.google.com ([209.85.213.196]:33612 "EHLO mail-ig0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750941AbbHXPd7 (ORCPT ); Mon, 24 Aug 2015 11:33:59 -0400 MIME-Version: 1.0 In-Reply-To: References: Date: Mon, 24 Aug 2015 23:33:58 +0800 Message-ID: Subject: Re: [PATCH] kernel/sysctl.c: If "count" including the terminating byte '\0' the write system call should retrun success. From: Sean Fu To: "Eric W. Biederman" Cc: Andrey Ryabinin , Ulrich Obergfell , "Steven Rostedt (Red Hat)" , Prarit Bhargava , Eric B Munson , "Paul E. McKenney" , Johannes Weiner , Andrew Morton , Thomas Gleixner , Don Zickus , Heinrich Schuchardt , David Rientjes , linux-kernel@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1784 Lines: 53 On Mon, Aug 24, 2015 at 8:27 PM, Eric W. Biederman wrote: > > > On August 24, 2015 1:56:13 AM PDT, Sean Fu wrote: >>when the input argument "count" including the terminating byte "\0", >>The write system call return EINVAL on proc file. >>But it return success on regular file. > > Nonsense. It will write the '\0' to a regular file because it is just data. > > Integers in proc are more than data. > > So I see no justification for this change. In fact, "write(fd, "1\0", 2)" on Integers proc file return success on 2.6 kernel. I already tested it on 2.6.6.60 kernel. So, The latest behavior of "write(fd, "1\0", 2)" is different from old kernel(2.6). This maybe impact the compatibility of some user space program. > > > Eric > >>E.g. Writting two bytes ("1\0") to >>"/proc/sys/net/ipv4/conf/eth0/rp_filter". >>write(fd, "1\0", 2) return EINVAL. >> >>Signed-off-by: Sean Fu >>--- >> kernel/sysctl.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >>diff --git a/kernel/sysctl.c b/kernel/sysctl.c >>index 19b62b5..c2b0594 100644 >>--- a/kernel/sysctl.c >>+++ b/kernel/sysctl.c >>@@ -2004,7 +2004,7 @@ static int do_proc_dointvec_conv(bool *negp, >>unsigned long *lvalp, >> return 0; >> } >> >>-static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; >>+static const char proc_wspace_sep[] = { ' ', '\t', '\n', '\0' }; >> >> static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, >> int write, void __user *buffer, > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/