From patchwork Tue Oct 18 15:01:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Bohac X-Patchwork-Id: 683736 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 3syywL1Kydz9s9x for ; Wed, 19 Oct 2016 02:02:10 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935055AbcJRPCE (ORCPT ); Tue, 18 Oct 2016 11:02:04 -0400 Received: from mx2.suse.de ([195.135.220.15]:54638 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932186AbcJRPCC (ORCPT ); Tue, 18 Oct 2016 11:02:02 -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 EBC18AC31; Tue, 18 Oct 2016 15:01:56 +0000 (UTC) Date: Tue, 18 Oct 2016 17:01:54 +0200 From: Jiri Bohac To: Julia Lawall , "David S. Miller" , Alexey Kuznetsov , James Morris , Hideaki YOSHIFUJI , Patrick McHardy Cc: netdev@vger.kernel.org, kbuild-all@01.org Subject: [PATCH] ipv6: fix signedness of tmp_prefered_lft underflow check Message-ID: <20161018150154.4tpivtvxygp7kjpd@dwarf.suse.cz> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: 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 Commit 76506a986dc31394fd1f2741db037d29c7e57843 (IPv6: fix DESYNC_FACTOR) introduced a buggy check for underflow of tmp_prefered_lft. tmp_prefered_lft is unsigned, so the condition is always false. 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..7a043a4 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -1248,7 +1248,7 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *i 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)) + if (unlikely((long)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;