From patchwork Fri Dec 10 22:47:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12671293 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA65BC433F5 for ; Fri, 10 Dec 2021 22:55:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 58DAD6B0093; Fri, 10 Dec 2021 17:47:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 53DC26B0095; Fri, 10 Dec 2021 17:47:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42D596B0096; Fri, 10 Dec 2021 17:47:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0213.hostedemail.com [216.40.44.213]) by kanga.kvack.org (Postfix) with ESMTP id 3410C6B0093 for ; Fri, 10 Dec 2021 17:47:18 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id F2AF08249980 for ; Fri, 10 Dec 2021 22:47:07 +0000 (UTC) X-FDA: 78903371694.07.35FDFFF Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf04.hostedemail.com (Postfix) with ESMTP id 3EAAE40009 for ; Fri, 10 Dec 2021 22:47:06 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D71BDB82A15; Fri, 10 Dec 2021 22:47:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C38DC00446; Fri, 10 Dec 2021 22:47:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1639176423; bh=e371BC48yi+1zkcqf7J8rWC7iV2JeIwQviTRnB13Kls=; h=Date:From:To:Subject:In-Reply-To:From; b=qpY/s0wadtl/IEGFGEEkLlISN9uKcIInlTINk0m2DjQs5BGhAuKhd8kgRCr/Q5Kzt ExOFW5fXLpg4sEkumGTwfamiV/ioV46/NLt1vgiy8drY7LIbTamCPgCU7N22BlR1pV NKbqorpTmn54M2J3Sjpv63prhg7JMlUTJA4khRg0= Date: Fri, 10 Dec 2021 14:47:02 -0800 From: Andrew Morton To: akpm@linux-foundation.org, cl@linux.com, faiyazm@codeaurora.org, gerald.schaefer@linux.ibm.com, gregkh@linuxfoundation.org, iamjoonsoo.kim@lge.com, linux-mm@kvack.org, maier@linux.ibm.com, mm-commits@vger.kernel.org, penberg@kernel.org, rientjes@google.com, stable@vger.kernel.org, torvalds@linux-foundation.org, vbabka@suse.cz Subject: [patch 18/21] mm/slub: fix endianness bug for alloc/free_traces attributes Message-ID: <20211210224702.RW6YwnTh2%akpm@linux-foundation.org> In-Reply-To: <20211210144539.663efee2c80d8450e6180230@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 3EAAE40009 X-Stat-Signature: 8m5ok8mdzfmktgjcwyjopbjw65ku3sma Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="qpY/s0wa"; dmarc=none; spf=pass (imf04.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-HE-Tag: 1639176426-607942 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Gerald Schaefer Subject: mm/slub: fix endianness bug for alloc/free_traces attributes On big-endian s390, the alloc/free_traces attributes produce endless output, because of always 0 idx in slab_debugfs_show(). idx is de-referenced from *v, which points to a loff_t value, with unsigned int idx = *(unsigned int *)v; This will only give the upper 32 bits on big-endian, which remain 0. Instead of only fixing this de-reference, during discussion it seemed more appropriate to change the seq_ops so that they use an explicit iterator in private loc_track struct. This patch adds idx to loc_track, which will also fix the endianness bug. Link: https://lore.kernel.org/r/20211117193932.4049412-1-gerald.schaefer@linux.ibm.com Link: https://lkml.kernel.org/r/20211126171848.17534-1-gerald.schaefer@linux.ibm.com Fixes: 64dd68497be7 ("mm: slub: move sysfs slab alloc/free interfaces to debugfs") Signed-off-by: Gerald Schaefer Reported-by: Steffen Maier Acked-by: Vlastimil Babka Cc: Faiyaz Mohammed Cc: Greg Kroah-Hartman Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Signed-off-by: Andrew Morton --- mm/slub.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) --- a/mm/slub.c~mm-slub-fix-endianness-bug-for-alloc-free_traces-attributes +++ a/mm/slub.c @@ -5081,6 +5081,7 @@ struct loc_track { unsigned long max; unsigned long count; struct location *loc; + loff_t idx; }; static struct dentry *slab_debugfs_root; @@ -6052,11 +6053,11 @@ __initcall(slab_sysfs_init); #if defined(CONFIG_SLUB_DEBUG) && defined(CONFIG_DEBUG_FS) static int slab_debugfs_show(struct seq_file *seq, void *v) { - - struct location *l; - unsigned int idx = *(unsigned int *)v; struct loc_track *t = seq->private; + struct location *l; + unsigned long idx; + idx = (unsigned long) t->idx; if (idx < t->count) { l = &t->loc[idx]; @@ -6105,16 +6106,18 @@ static void *slab_debugfs_next(struct se { struct loc_track *t = seq->private; - v = ppos; - ++*ppos; + t->idx = ++(*ppos); if (*ppos <= t->count) - return v; + return ppos; return NULL; } static void *slab_debugfs_start(struct seq_file *seq, loff_t *ppos) { + struct loc_track *t = seq->private; + + t->idx = *ppos; return ppos; }