From patchwork Wed Jan 15 15:55:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thorsten Blum X-Patchwork-Id: 13940574 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 5ADE2C02180 for ; Wed, 15 Jan 2025 15:56:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C56416B007B; Wed, 15 Jan 2025 10:56:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C06D86B0082; Wed, 15 Jan 2025 10:56:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF52C280001; Wed, 15 Jan 2025 10:56:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 924B66B007B for ; Wed, 15 Jan 2025 10:56:13 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E47111A0320 for ; Wed, 15 Jan 2025 15:56:12 +0000 (UTC) X-FDA: 83010137826.17.B1FA3BE Received: from out-177.mta1.migadu.com (out-177.mta1.migadu.com [95.215.58.177]) by imf13.hostedemail.com (Postfix) with ESMTP id 65EDF2000E for ; Wed, 15 Jan 2025 15:56:10 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=jx1C7duu; spf=pass (imf13.hostedemail.com: domain of thorsten.blum@linux.dev designates 95.215.58.177 as permitted sender) smtp.mailfrom=thorsten.blum@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736956570; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=iDlX5Gzy2AKY576SbA7XW5gmU33x7DeFH9ESiKU19Z8=; b=Is3wyiIQLt+rfUzFW3c+XEIxYZZHxfJ7zfiGsAdaQwTkw6FHfBBZSswj2wTMvHstOUDISn 7MvLNncEVQl9O8vc0zkLza/0O/4Pm4Ha/wpjbAWjhZroExBORp7wuVDC1UxlRWPsWnIeo4 FCxzZO270CBs1wn6BjslXL41Z8juHe4= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=jx1C7duu; spf=pass (imf13.hostedemail.com: domain of thorsten.blum@linux.dev designates 95.215.58.177 as permitted sender) smtp.mailfrom=thorsten.blum@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736956570; a=rsa-sha256; cv=none; b=JOgM/1VS8+MDvWtKnjqIEE8mwyXI9pm1G6iEfZZWNMTJU0/muVt/zaT0z23/6ipMjaPfuw 1x42W5xVXMxgMsymNoyecDw7PK8OTkaZuBL2etX+abIYbKykPhNZq2qXHmjffRGK29s2Hy NqUqhNzoJ/OqfzJ6MPBVqocXN/FVwZA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1736956568; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=iDlX5Gzy2AKY576SbA7XW5gmU33x7DeFH9ESiKU19Z8=; b=jx1C7duu+SX06oV1lZXUafdrmdn7AUmOZUN73ehbLYGFwgIGTpRgDGhLTGZXq5bPz4/xdS cjwwJNH1tf/EhtdZ3+PyEcBWA00jIXCCs/L2+BRVgx9NH9qEGiLpRLkta4qU/s4OxXE9oL /+CdNXu1OY2cKv4QKjYUoqL47BLv1Eg= From: Thorsten Blum To: Alexander Potapenko , Marco Elver , Dmitry Vyukov , Andrew Morton Cc: Thorsten Blum , Anshuman Khandual , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] mm/kfence: Use str_write_read() helper in get_access_type() Date: Wed, 15 Jan 2025 16:55:12 +0100 Message-ID: <20250115155511.954535-2-thorsten.blum@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 65EDF2000E X-Stat-Signature: 6yzs9esn5b8ahk8mngp39uopszxynsf5 X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1736956570-631416 X-HE-Meta: U2FsdGVkX19QYQIdWwfqNRmbqvILUamwMFNG5zf3V7zzA0X7Y0A+QQkV1vo4mrcEaXYFsVFGmL8RwcqqmK7nnaCaiXAOved6BAotL4NIGRdCU8oxfBQ5geuiW56LE+AnAT/VdXdsU4YeTJhxSp5FJRjrqRCuL8lTOYWOiCNrtVmxBhfE9QYn2RGU9Abbi3Vt93n7Y5PyPEI+njdxVR7/0/bmFTKM+wG/4jFPweUq+bl/WgvO5Io4mcwFclfo6U7M1GCX9O0pBrsy1E9XGVW3XnCysDbdVQYrZGYqRvPOEIf66A/av9wufkMXgGvAawpz3q2XKCM8nmICXBMY0tJEoqjBp1Rt3Pt7LAwWATuPurvIhy9pTg59b7wBD+WeC3xgcwGvQuskPU9A9e1Kmxufza+j3UZoR4hRycOBTwfhYcYKIcmpAO2Od2DUMpAboRKvWgMeDSRFrTGL/WlZ6cGEKZktYy1jXLt7+61E/OIk3kfIVYGcNvRNkNjePBKrKReeKODRLXlnTaH9a9QTDb15PrrqktCycz++Le/TpwyWYlggwN+SpXynD1yQORXtcVEkUYsIkgTkgZVDL3KPItCHS7LasC9JRJ56Mo/9TZg62BmIW0fL61gkD+RrWxifw2o49VNla1cSue6hyJ+kP/4FQuWNZbz195ae9fmUpunHJ598m5RArPr2oEu8bdzV8mpONDFD56FRbMRG1o9LYDAFxdzMdkZxWFsccLAhMMmyjMJGhk907mxRQicFE/3RiVOHd/CwG/0Hv0dbbHGX3UVqs2jtv/0LMOXd8dUBkBxB45zJodw0oA7Gd2vUB4dy9CgdtcCkI7988bdhx55EocfsZkmL03YZzjwuPEzxtng2HvQ5GiJW1z8wh0VjHjK9ULQKVeBfSHW0d+kEIAk580zvPWc+tDkrJbPUEBHUMBPC1zF5ZPjEsoPsKuwu+cSZtAGlSOOo9Co/N69qozQKrbp NRb8e+1t v6BEwpVg3oUJXLtazRfhxabpahpwBgZXdXsDgY04k+X4jKGGvhakvlOSj7BfOzrmrDNq+6AVr2uDgJyVVhmyqNL6j/ZJBCN/8EcfZ2mArXyI/+J8I9N1X0w3glPlvyYbnqu9Umiqik089SL1ZMwczRThBRCwx24r2oqGJBdN8slYaWGDXDpvKy1qS6axJC/gZU05x82mCW45xhjA1fh95EWS1vzi5nlxUd443Zkm5TC4x4ceM5ogGfD5zF2qGpUBVxktHAp+8C3vf9Fc= 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: List-Subscribe: List-Unsubscribe: Remove hard-coded strings by using the str_write_read() helper function. Suggested-by: Anshuman Khandual Signed-off-by: Thorsten Blum Reviewed-by: Marco Elver --- Changes in v2: - Use str_write_read() in report.c as suggested by Marco Elver (thanks!) - Link to v1: https://lore.kernel.org/r/20250115090303.918192-2-thorsten.blum@linux.dev/ --- mm/kfence/kfence_test.c | 3 ++- mm/kfence/report.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c index f65fb182466d..00034e37bc9f 100644 --- a/mm/kfence/kfence_test.c +++ b/mm/kfence/kfence_test.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -88,7 +89,7 @@ struct expect_report { static const char *get_access_type(const struct expect_report *r) { - return r->is_write ? "write" : "read"; + return str_write_read(r->is_write); } /* Check observed report matches information in @r. */ diff --git a/mm/kfence/report.c b/mm/kfence/report.c index 6370c5207d1a..10e6802a2edf 100644 --- a/mm/kfence/report.c +++ b/mm/kfence/report.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -184,7 +185,7 @@ static void print_diff_canary(unsigned long address, size_t bytes_to_show, static const char *get_access_type(bool is_write) { - return is_write ? "write" : "read"; + return str_write_read(is_write); } void kfence_report_error(unsigned long address, bool is_write, struct pt_regs *regs,