Received: by 10.213.65.68 with SMTP id h4csp1813034imn; Thu, 29 Mar 2018 11:30:27 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/K6SmUtD1i+8tyk1HqZS8v6dcEoTuqXunWb9iRDC+lhWT0z5IoFemUYUZRzan6Lt1yvbP3 X-Received: by 10.98.57.143 with SMTP id u15mr7247533pfj.79.1522348227018; Thu, 29 Mar 2018 11:30:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522348226; cv=none; d=google.com; s=arc-20160816; b=ctyOwfNkHOb9Ut59CL8PVyHZTLaRBLooryKvCukbCatlX7du1y1kk4hRMEr+HAb2k0 zwmnH+lda0AxlY8YF955mMSpmT7omUoBclIL89Nxh/9vx63R4aCbCLbso8TB+xllLyY6 NqT+pL1L2glUIDwqD3y/aokOdehccomLHx3Zc3vBYNVaUZt1gh7z5EhkwMVFBsiZjps+ dXRtUioCsQY0oDBGRmSTvxKoZXG19wlVvv0N5oiqtOnm78bxZkXQkW8C9mvsC7i5g+x/ lqr+RvSbphKLuEIMhNfdKlAlZeEYGoM8W3NV8xcUEf3XeeesQSo+aDdhJwmKcUZuhTUE dOBQ== 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=U4N98ONfecZpLNqhW9OGyBkPf5kZ5yFUxzNjUylybbM=; b=JXs2CfJNUPikP2xg3ZglWumP2W3eYxChyWUC6zXoGCIS+KU9+bGe8yL1C/jNm/5blf Y9IwrcGWm4Dmq1lCZ7gRilTCDB1aq4quWTp2yQMra5yEwMX5fXVqxZ10Wdawp7kgGKIO wxGq+b/T8/lFoB5coxvPex2NcRXTJFE1yaVN5DkwdZfRpnTqto4wR+0o3BWKCypaNnud yy0h6bJBvDB8euV9G2pMXKaLkg4f7ysDp2wIrhb0e5x7B2yFpYC2X9kdcdsCt3/vcMd1 okeegIW/Ut7/RDRj/zNmgjEv26bC85hQgfswuJi7UYvn12R9pqIN/9q96dZ76FeRIBew 9A7Q== 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 h67si4283719pgc.353.2018.03.29.11.30.13; Thu, 29 Mar 2018 11:30:26 -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 S1753329AbeC2S3L (ORCPT + 99 others); Thu, 29 Mar 2018 14:29:11 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58790 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753213AbeC2SE0 (ORCPT ); Thu, 29 Mar 2018 14:04:26 -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 0540EC7F; Thu, 29 Mar 2018 18:04:25 +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.14 16/43] rhashtable: Fix rhlist duplicates insertion Date: Thu, 29 Mar 2018 20:00:11 +0200 Message-Id: <20180329175731.778320923@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180329175730.190353692@linuxfoundation.org> References: <20180329175730.190353692@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.14-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);