From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH net v2 1/5] net/ipv6: fix addrconf_sysctl_addr_gen_mode Date: Mon, 9 Jul 2018 11:20:45 -0600 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Jiri Pirko , Felix Jia To: Sabrina Dubroca , netdev@vger.kernel.org Return-path: Received: from mail-pf0-f195.google.com ([209.85.192.195]:42928 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933489AbeGIRUs (ORCPT ); Mon, 9 Jul 2018 13:20:48 -0400 Received: by mail-pf0-f195.google.com with SMTP id l9-v6so2497974pff.9 for ; Mon, 09 Jul 2018 10:20:48 -0700 (PDT) In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 7/9/18 4:25 AM, Sabrina Dubroca wrote: > addrconf_sysctl_addr_gen_mode() has multiple problems. First, it ignores > the errors returned by proc_dointvec(). > > addrconf_sysctl_addr_gen_mode() calls proc_dointvec() directly, which > writes the value to memory, and then checks if it's valid and may return > EINVAL. If a bad value is given, the value displayed when reading > net.ipv6.conf.foo.addr_gen_mode next time will be invalid. In case the > value provided by the user was valid, addrconf_dev_config() won't be > called since idev->cnf.addr_gen_mode has already been updated. > > Fix this in the usual way we deal with values that need to be checked > after the proc_do*() helper has returned: define a local ctl_table and > storage, call proc_dointvec() on that temporary area, then check and > store. > > addrconf_sysctl_addr_gen_mode() also writes the new value to the global > ipv6_devconf_dflt, when we're writing to some netns's default, so that > new netns will inherit the value that was set by the change occuring in > any netns. That doesn't make any sense, so let's drop this assignment. > > Finally, since addr_gen_mode is a __u32, switch to proc_douintvec(). > > Fixes: d35a00b8e33d ("net/ipv6: allow sysctl to change link-local address generation mode") > Signed-off-by: Sabrina Dubroca > --- > net/ipv6/addrconf.c | 27 ++++++++++++++------------- > 1 file changed, 14 insertions(+), 13 deletions(-) > Reviewed-by: David Ahern