From patchwork Wed Oct 19 13:25:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Bohac X-Patchwork-Id: 684238 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 3szclt0Cw6z9s3s for ; Thu, 20 Oct 2016 03:27:06 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936132AbcJSONx (ORCPT ); Wed, 19 Oct 2016 10:13:53 -0400 Received: from mx2.suse.de ([195.135.220.15]:38643 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936131AbcJSONt (ORCPT ); Wed, 19 Oct 2016 10:13:49 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A4A20ADCA; Wed, 19 Oct 2016 13:25:39 +0000 (UTC) Date: Wed, 19 Oct 2016 15:25:39 +0200 From: Jiri Bohac To: David Miller Cc: julia.lawall@lip6.fr, kuznet@ms2.inr.ac.ru, jmorris@namei.org, yoshfuji@linux-ipv6.org, kaber@trash.net, netdev@vger.kernel.org, kbuild-all@01.org Subject: Re: [PATCH] ipv6: don't check for tmp_prefered_lft underflow Message-ID: <20161019132539.x2ou3hfgutxe6d57@dwarf.suse.cz> References: <20161018150154.4tpivtvxygp7kjpd@dwarf.suse.cz> <20161018.142525.1262217492229127435.davem@davemloft.net> <20161019131636.zhusbqh63qlbq5vy@dwarf.suse.cz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20161019131636.zhusbqh63qlbq5vy@dwarf.suse.cz> User-Agent: Mutt/1.6.2-neo (2016-06-11) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The check for an underflow of tmp_prefered_lft is always false because tmp_prefered_lft is unsigned. The intention of the check was to guard against racing with an update of the temp_prefered_lft sysctl, potentially resulting in an underflow and a very large preferred lifetime. However, the result of the check in such a situation would be not creating the temporary address at all, which might be an even worse outcome than the bogus lifetime. Drop the faulty check. Signed-off-by: Jiri Bohac Reported-by: Julia Lawall Fixes: 76506a986dc3 ("IPv6: fix DESYNC_FACTOR") diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index cc7c26d..f7c7c2b 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -1247,9 +1247,6 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *i idev->cnf.temp_valid_lft + age); tmp_prefered_lft = idev->cnf.temp_prefered_lft + age - idev->desync_factor; - /* guard against underflow in case of concurrent updates to cnf */ - if (unlikely(tmp_prefered_lft < 0)) - tmp_prefered_lft = 0; tmp_prefered_lft = min_t(__u32, ifp->prefered_lft, tmp_prefered_lft); tmp_plen = ifp->prefix_len; tmp_tstamp = ifp->tstamp;