Received: by 10.213.65.68 with SMTP id h4csp1823129imn; Thu, 29 Mar 2018 11:41:31 -0700 (PDT) X-Google-Smtp-Source: AIpwx497jWwlEfZTWQ8P9IjI+BZhzOH1heuaGZm7PeDvu/BJ69ynZoHbl5zFvG3e9UKTnJOobSwL X-Received: by 10.99.167.78 with SMTP id w14mr6282721pgo.408.1522348891516; Thu, 29 Mar 2018 11:41:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522348891; cv=none; d=google.com; s=arc-20160816; b=BvhHVwyh1+82u7VWAZTQr1c8zc70thp6IX8eh9WcdVyKKj6rzOUtClnr5b+GewWXWB cn7c75Apa2uUf4JC6l+MJKkXwle2fcJjB3C0lVu+yskdOp6gebHWyvVJ8ori+I9WQ3p6 /bigtBze+79PFGJFvab2Agsx1QdFJshr6IJ/poNytQwBBJeQ9aBfdeWWlNXkTSqlPXdT h+Hoo4AEwVhUdDgoBZThLXRlkyMGbk+clXx6BIkof2PPzCaoAvYQ1S0JjwzG33jqu2uF zFaGLFw4IcSPOeGV7XPQIG/cz7qZ0DKlQw9m0ELRnIy+DGoCMjVDRHK10GwpR02Zyfl1 sr7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=P20PrqN0elL6RExRjdoiSPKhtyM8im7a7fK8SC54f44=; b=DISUkLRceWKvnhLi5/4LeYZSPzt2YmxFpaJIfhBeDcuTq6akUL+xlMOPUcfbwYhQeb 6flokkBXzffAIBnc77XHqzXTKdxBqnfHUzFGfzZqv3Pu2LlTBmW0S23LqK/otRCIFyON sKGp/39MatSrlQqPu1gVbfXUQOs6YPg0BnV4MHwuX6mekgZzPfb5U6Di0loHIiHZ9qhi EB758SUPW9Gvxo2D9mC5w8d4JTqyWg97c92TxUzvmfyGx7o0LqOf2/JPb0VTuD/nL6QP aGr0kS+2L/AS7BfvV0NhzNt7f9h6Br9ZxCGqh2CkK7EBveHvzt1V4QS8VfG0Jv3TQ6zC OULQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2-v6si6301894plh.121.2018.03.29.11.41.13; Thu, 29 Mar 2018 11:41:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752728AbeC2SkK (ORCPT + 99 others); Thu, 29 Mar 2018 14:40:10 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58132 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750866AbeC2SCO (ORCPT ); Thu, 29 Mar 2018 14:02:14 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A9D0AC12; Thu, 29 Mar 2018 18:02:13 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Blakey , Herbert Xu , "David S. Miller" Subject: [PATCH 4.15 19/47] rhashtable: Fix rhlist duplicates insertion Date: Thu, 29 Mar 2018 20:00:00 +0200 Message-Id: <20180329175730.507661079@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180329175729.225211114@linuxfoundation.org> References: <20180329175729.225211114@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paul Blakey [ Upstream commit d3dcf8eb615537526bd42ff27a081d46d337816e ] When inserting duplicate objects (those with the same key), current rhlist implementation messes up the chain pointers by updating the bucket pointer instead of prev next pointer to the newly inserted node. This causes missing elements on removal and travesal. Fix that by properly updating pprev pointer to point to the correct rhash_head next pointer. Issue: 1241076 Change-Id: I86b2c140bcb4aeb10b70a72a267ff590bb2b17e7 Fixes: ca26893f05e8 ('rhashtable: Add rhlist interface') Signed-off-by: Paul Blakey Acked-by: Herbert Xu Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- include/linux/rhashtable.h | 4 +++- lib/rhashtable.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) --- a/include/linux/rhashtable.h +++ b/include/linux/rhashtable.h @@ -750,8 +750,10 @@ slow_path: if (!key || (params.obj_cmpfn ? params.obj_cmpfn(&arg, rht_obj(ht, head)) : - rhashtable_compare(&arg, rht_obj(ht, head)))) + rhashtable_compare(&arg, rht_obj(ht, head)))) { + pprev = &head->next; continue; + } data = rht_obj(ht, head); --- a/lib/rhashtable.c +++ b/lib/rhashtable.c @@ -537,8 +537,10 @@ static void *rhashtable_lookup_one(struc if (!key || (ht->p.obj_cmpfn ? ht->p.obj_cmpfn(&arg, rht_obj(ht, head)) : - rhashtable_compare(&arg, rht_obj(ht, head)))) + rhashtable_compare(&arg, rht_obj(ht, head)))) { + pprev = &head->next; continue; + } if (!ht->rhlist) return rht_obj(ht, head);