From patchwork Fri Nov 26 17:18:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Schaefer X-Patchwork-Id: 12641183 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 412E3C433EF for ; Fri, 26 Nov 2021 17:19:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 939566B0075; Fri, 26 Nov 2021 12:19:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E7E16B0078; Fri, 26 Nov 2021 12:19:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 73B046B007B; Fri, 26 Nov 2021 12:19:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 61AC56B0075 for ; Fri, 26 Nov 2021 12:19:13 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1EF3118351D7A for ; Fri, 26 Nov 2021 17:19:03 +0000 (UTC) X-FDA: 78851741766.02.777C52F Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf09.hostedemail.com (Postfix) with ESMTP id 7F24F3000125 for ; Fri, 26 Nov 2021 17:18:58 +0000 (UTC) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1AQHFqXi030074; Fri, 26 Nov 2021 17:19:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=b7ntKJBdYE4PWhHtmSjJVHxK46N8CKvYSfv9jWeLfCM=; b=pT+uMYM7mEjQfSnJddWOyOm9ODic3jf0CJ/pKnI42iYIj15/LZyViqkHdCrTBGnbhYGH YP4tyQ3xebUSYwvU+2mJSs1oKqPmGXfSnuU42DhvOBmamaPlTXRzYwcAS1beTtf+prrI Txz+XX0Q4ZyN2m7A+A52pwwvIShpLkzOZJXfmxYkJ/ZpoN2AtCB3BuyeXnSPH+hG1O07 Ih9FmNMwZ7ZAU/xXcF1wqO49rkxUDKVmothGdzq7nnZJttD4lUFRuIof3cfzLJctPbE0 OYBmI5rQYqiqlqXH38yTCIoP9p0XIBujqW0s7UpPWDLlbPDiIjpopdFM+CS59vTCT6fB tQ== Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com with ESMTP id 3ck3u1820g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Nov 2021 17:19:00 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1AQHCoGt013600; Fri, 26 Nov 2021 17:18:57 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma01fra.de.ibm.com with ESMTP id 3cernab6sf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Nov 2021 17:18:57 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1AQHBdsl64225782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Nov 2021 17:11:39 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 38DFA4C040; Fri, 26 Nov 2021 17:18:55 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EB8234C052; Fri, 26 Nov 2021 17:18:54 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 26 Nov 2021 17:18:54 +0000 (GMT) From: Gerald Schaefer To: Vlastimil Babka Cc: linux-mm , LKML , linux-s390 , Faiyaz Mohammed , Greg Kroah-Hartman , Andrew Morton Subject: [PATCH] mm/slub: fix endianness bug for alloc/free_traces attributes Date: Fri, 26 Nov 2021 18:18:48 +0100 Message-Id: <20211126171848.17534-1-gerald.schaefer@linux.ibm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <7c909b82-8e1c-a8ce-516d-e3aa9bc2fd81@suse.cz> References: <7c909b82-8e1c-a8ce-516d-e3aa9bc2fd81@suse.cz> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 5FYrfJZA68Nx5hNKW32gQhs0rNmK-4d1 X-Proofpoint-ORIG-GUID: 5FYrfJZA68Nx5hNKW32gQhs0rNmK-4d1 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-26_04,2021-11-25_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 clxscore=1015 adultscore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111260099 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 7F24F3000125 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=pT+uMYM7; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf09.hostedemail.com: domain of gerald.schaefer@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=gerald.schaefer@linux.ibm.com X-Stat-Signature: yzz183yxkbw411qp6osw4qxikqndiii7 X-HE-Tag: 1637947138-657246 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: 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 Fixes: 64dd68497be7 ("mm: slub: move sysfs slab alloc/free interfaces to debugfs") Cc: # v5.14+ Reported-by: Steffen Maier Signed-off-by: Gerald Schaefer Acked-by: Vlastimil Babka --- mm/slub.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index a8626825a829..abe7db581d68 100644 --- a/mm/slub.c +++ b/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 seq_file *seq, void *v, loff_t *ppos) { 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; }