Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2749963imj; Mon, 11 Feb 2019 07:56:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IYiejpjAL02yMIkBt75ERdly7J1Euf1BqUPedNRxJMUw0yz+VAB+8Ys/OFKqKRl3lnDuG7b X-Received: by 2002:a62:4886:: with SMTP id q6mr38295423pfi.182.1549900612170; Mon, 11 Feb 2019 07:56:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549900612; cv=none; d=google.com; s=arc-20160816; b=Sk8dUaN6+6y/z3BfldL1sz42+m2CVmKVYVOMnKTOrnG7/b6bjBkGF2NwMHrHARlk1r 5Z+LDgWHjoitkG7QmCq8Vi/x0KZc0ggCphg+lHEMykNg9PfR6STDOfZVKNv+SWdWuvIX O6Z6i/ijJxnnCwR3FkiZAIidfHIdCGPa8sL44pPXX6Taqrs8VyyVeyRLhLJLAK+PfGtM nUgu3dLZW2hcYoFHcp2rT9OIIv9Bx1AjJCDNdksC7j2btYpqEp4KZnZm0JDsuR5QLoaf B8zo9rH9mnwV/8vRC0MuwzcRsVwZCuxDRxQAeXKRDLFkvRIHOTXvSLlW04fhl6KsJPAq dsUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=svssPod0uAdhlw0RxM9JfqhjDrvPEzi4qZ/QLs4q1Zk=; b=GHVDEYnZJQSriTdyI9PoEYy5exqj/5IdhCsKaUBAOrCzv3xLZI1NzOnfw7YXRYCrdX UlCZxvi6BGUqB7Rk8jL/oQZii5JlVhNK9H6YdytEkPDXZ1suAjuh2F0NTiSRcSdOpjfH fTXcD/y0VjACeLXebfqsOXfmOWOS8voQVfcUMGygSP19MRjuwF4kOayaXW/7JLiwnmx6 BygtFm1RjkjerC6mHWLZSArliCam53XEcIwxW64fYdJT8Ts1P1ylaoUstJ8AC95Drcx+ 9/s7oyWlYnbT7wj+KUjx0d4qp/rNMyal9eKbOIpSBqKO/yOhB/bO7ez/SFzHzSlEKb2F wnLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QOk1XqaI; 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 16si1242415pgt.548.2019.02.11.07.56.35; Mon, 11 Feb 2019 07:56:52 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=QOk1XqaI; 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 S1731284AbfBKPzl (ORCPT + 99 others); Mon, 11 Feb 2019 10:55:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:43522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730938AbfBKOfB (ORCPT ); Mon, 11 Feb 2019 09:35:01 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DDE412081B; Mon, 11 Feb 2019 14:34:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895700; bh=/G1Fl8ht7SsMxQFZfBoijd7LogyKr0CppLm8G5vH/H4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QOk1XqaIdjs9zogW+KVv18vf8GhBzyStI8r6O71FuvtqbLdMZtBY6rpWv09P4ibww FtOs55haTQVY4n0IfgxXG8krqRa5FcIgqASfgvihaTIDpZqlK5Qx91vnXBClj9i5vJ tXu1xhNtfb+YflT3v+JQNdMPNee8qdacayZ83Dqw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Graf , Herbert Xu , netdev@vger.kernel.org, Bart Van Assche , "David S. Miller" Subject: [PATCH 4.20 294/352] lib/test_rhashtable: Make test_insert_dup() allocate its hash table dynamically Date: Mon, 11 Feb 2019 15:18:41 +0100 Message-Id: <20190211141905.595178581@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bart Van Assche [ Upstream commit fc42a689c4c097859e5bd37b5ea11b60dc426df6 ] The test_insert_dup() function from lib/test_rhashtable.c passes a pointer to a stack object to rhltable_init(). Allocate the hash table dynamically to avoid that the following is reported with object debugging enabled: ODEBUG: object (ptrval) is on stack (ptrval), but NOT annotated. WARNING: CPU: 0 PID: 1 at lib/debugobjects.c:368 __debug_object_init+0x312/0x480 Modules linked in: EIP: __debug_object_init+0x312/0x480 Call Trace: ? debug_object_init+0x1a/0x20 ? __init_work+0x16/0x30 ? rhashtable_init+0x1e1/0x460 ? sched_clock_cpu+0x57/0xe0 ? rhltable_init+0xb/0x20 ? test_insert_dup+0x32/0x20f ? trace_hardirqs_on+0x38/0xf0 ? ida_dump+0x10/0x10 ? jhash+0x130/0x130 ? my_hashfn+0x30/0x30 ? test_rht_init+0x6aa/0xab4 ? ida_dump+0x10/0x10 ? test_rhltable+0xc5c/0xc5c ? do_one_initcall+0x67/0x28e ? trace_hardirqs_off+0x22/0xe0 ? restore_all_kernel+0xf/0x70 ? trace_hardirqs_on_thunk+0xc/0x10 ? restore_all_kernel+0xf/0x70 ? kernel_init_freeable+0x142/0x213 ? rest_init+0x230/0x230 ? kernel_init+0x10/0x110 ? schedule_tail_wrapper+0x9/0xc ? ret_from_fork+0x19/0x24 Cc: Thomas Graf Cc: Herbert Xu Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Bart Van Assche Acked-by: Herbert Xu Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- lib/test_rhashtable.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) --- a/lib/test_rhashtable.c +++ b/lib/test_rhashtable.c @@ -541,38 +541,45 @@ static unsigned int __init print_ht(stru static int __init test_insert_dup(struct test_obj_rhl *rhl_test_objects, int cnt, bool slow) { - struct rhltable rhlt; + struct rhltable *rhlt; unsigned int i, ret; const char *key; int err = 0; - err = rhltable_init(&rhlt, &test_rht_params_dup); - if (WARN_ON(err)) + rhlt = kmalloc(sizeof(*rhlt), GFP_KERNEL); + if (WARN_ON(!rhlt)) + return -EINVAL; + + err = rhltable_init(rhlt, &test_rht_params_dup); + if (WARN_ON(err)) { + kfree(rhlt); return err; + } for (i = 0; i < cnt; i++) { rhl_test_objects[i].value.tid = i; - key = rht_obj(&rhlt.ht, &rhl_test_objects[i].list_node.rhead); + key = rht_obj(&rhlt->ht, &rhl_test_objects[i].list_node.rhead); key += test_rht_params_dup.key_offset; if (slow) { - err = PTR_ERR(rhashtable_insert_slow(&rhlt.ht, key, + err = PTR_ERR(rhashtable_insert_slow(&rhlt->ht, key, &rhl_test_objects[i].list_node.rhead)); if (err == -EAGAIN) err = 0; } else - err = rhltable_insert(&rhlt, + err = rhltable_insert(rhlt, &rhl_test_objects[i].list_node, test_rht_params_dup); if (WARN(err, "error %d on element %d/%d (%s)\n", err, i, cnt, slow? "slow" : "fast")) goto skip_print; } - ret = print_ht(&rhlt); + ret = print_ht(rhlt); WARN(ret != cnt, "missing rhltable elements (%d != %d, %s)\n", ret, cnt, slow? "slow" : "fast"); skip_print: - rhltable_destroy(&rhlt); + rhltable_destroy(rhlt); + kfree(rhlt); return 0; }