From patchwork Thu Aug 11 08:59:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imran Khan X-Patchwork-Id: 12941267 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 DDF75C19F2A for ; Thu, 11 Aug 2022 09:00:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 294ED6B0073; Thu, 11 Aug 2022 05:00:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21EBA8E0002; Thu, 11 Aug 2022 05:00:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 048B48E0001; Thu, 11 Aug 2022 05:00:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E4C776B0073 for ; Thu, 11 Aug 2022 05:00:05 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A3852ABE5C for ; Thu, 11 Aug 2022 09:00:05 +0000 (UTC) X-FDA: 79786714770.18.0A46CC7 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf19.hostedemail.com (Postfix) with ESMTP id 532C61A015F for ; Thu, 11 Aug 2022 09:00:03 +0000 (UTC) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27B8k3if031585; Thu, 11 Aug 2022 08:59:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=qAM0pn4UF0rTJdPp3mQT8Fre9fDAqiSMo99z3uMd/ao=; b=A9sIssYtWYpABlvSwvbO+cqzG4VXH/7CDdmnlB3phVAKSjiS0Q/Tuz+dX0J5nsPuZhIp 1WhCc2g2+KyUXR23RNsRZK1twI2Hv+6q/y837XL4P1Dq4OF4/t7caJcWGuLGgbY1aCVy OE+re8obMGrEVBeIDvsc1W6263DxeqvLTpntVmjjtNqr5GF7swR4r8SWdlJx4ew5Nc/m sxnZyywIWfDdS0rwWGWRbIT+Y0PTUwxBKMT3Jc4zU6wOwyxcttk7A71gvxoj4C5r4Cxh EQDaXHjISmXurjhx049hzvaQ5LC3xF1DIXPEdY56eOQMD4P3S1OtpLJ3h0tIv42cDczR fw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3huwqdv7g5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Aug 2022 08:59:56 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 27B5ZHbM040694; Thu, 11 Aug 2022 08:59:55 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2046.outbound.protection.outlook.com [104.47.51.46]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3huwqgnyea-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Aug 2022 08:59:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WdPXrLvjJ8mHf2B2wqtewTYPfHxKx2Rz3EBoArPiMpjlCwqAd2Y/M0Z+s8fyN/MQUfa6cIge0W0fLiuM9WCbjviZo+BZuQMNjDfgFs9PWHU7WXrWlBzNiCCenJCJGaVENmga1e2IUhuzsFLQykcDqcI/vqadY98tKpxptcqHXOT5FXTf9kvOWeZjcDeMij+L9E8zjsSVNlb/lbWNLZxHnsjVkGOrsJzrDHuFyhiHfWiYUzjlnpw9nuaJx+jf1j5tASrBfZsQPo1spWtFWessXsfWZ4m9VnZWLMBBhORTwaER/8m5NaHj5O0ep40rVVW5BD1VoXtjhFiwrPM3oggyzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qAM0pn4UF0rTJdPp3mQT8Fre9fDAqiSMo99z3uMd/ao=; b=GOeIIPWF3oy5C6i6xIGzIKef1xwVJ/43lnhFpkALELi1y8BY0+9oIPEglQmdWZaUgRcICkeNjEKX27fy8Abj2I3Gw+s9Ii6e/eTdFxy+WXc3vx5zL1m4/mfFANkXUFNe6zDYbMWB/AwyockSS/LjxR6GgzbUUQmMi0o9LBNSuOOINVdtMjMmAwQjyMd4wekCMsic94zp+PUwhw8D8Gm5JSRWWIiCvhcQ+g4s03ydKHXgnD7SP/qmVs85Ihb8cNxOLs+1HPd/uB17OXqZcbCookp/UkirCTSfDMX5hONTZTyw6ihl2myK78DeivKF3vQETuHxccvf62I9NXM5LSU2UQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qAM0pn4UF0rTJdPp3mQT8Fre9fDAqiSMo99z3uMd/ao=; b=LME0GOPdmnkwzirZ2oKQ+fs84PrfCPWopE2LtX11YN6IHGy12GEzI3AJIKkjvaOJ6TYNTb7fvCpqfeo+yEAFJbwbbxLJohW+hjHcFESHxA5AFRs7Dh5vFpwkztLzyC560eyZh/NbaUkm+3of6BchqGv1Fl2xJ0+YFq4w2NhwEfI= Received: from CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) by BYAPR10MB2744.namprd10.prod.outlook.com (2603:10b6:a02:ae::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Thu, 11 Aug 2022 08:59:53 +0000 Received: from CO1PR10MB4468.namprd10.prod.outlook.com ([fe80::c504:bfd6:7940:544f]) by CO1PR10MB4468.namprd10.prod.outlook.com ([fe80::c504:bfd6:7940:544f%5]) with mapi id 15.20.5525.011; Thu, 11 Aug 2022 08:59:52 +0000 From: Imran Khan To: glider@google.com, elver@google.com, dvyukov@google.com, cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, vbabka@suse.cz, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org Subject: [PATCH v2] Introduce sysfs interface to disable kfence for selected slabs. Date: Thu, 11 Aug 2022 18:59:38 +1000 Message-Id: <20220811085938.2506536-1-imran.f.khan@oracle.com> X-Mailer: git-send-email 2.30.2 X-ClientProxiedBy: SYYP282CA0018.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:b4::28) To CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7d27ce05-7068-404d-187a-08da7b77daa0 X-MS-TrafficTypeDiagnostic: BYAPR10MB2744:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cpkK/Gc3vzbFQYx0CoQKzzlnfoofAD6xKkTAtL7LIj2lRu1880VdhwS2BNFxqExa6tONingnBg5sTxocyjBxaUX8L550StLFMnlcBd2OcfLz4ZdkJLfE4qQulomdoJ+7WPIzkEq0v2dCGjO6svP2Mk9J88BY0QfVc+rOayULpo27nc93aK8csh4Bfi/gcaXVExrKgBmXEv5WkcwWkT+XNAnPvB0GmPlCjYpSNN9MD3UDYlMdoAh4/RNsNJUJZPAuWV8Kfe1hP5vkD0nnzedLTIwYRIopGodrMCJN2Si7fPWxz5TvBOOncyBt5hGqD5QcfGwsdw+WBR+4SEuvjMGRMW3T1XqBgu1jvg7Vvqi/Lo/wDgN9jo8ufaKP+XYbrFQPF1Xd+YniIhoVdaDge4gEYWATD7ia3OTGMr5AfK2PNqjjOG6u5nu5ONem3JdCQLrg2O8NRwqAZRFPmk8bUVj/nZHVjTRaPbcG03AlMgUMT9xP85jcbm5sj4jDffe96MR3p34yV/WJ2j/96ggIwnF43mAL49bqkbBM4PKnl+kR5BzdP8LJkqZ8MinUrqMwvuCSTcproE4Qcnb2FpEtUwm305Ek1m070v3iptJazvh/5drl4IpZ8lHC03zXh5pImytktWdBTUqT7pjsTS6RV8NFCwYrIk9/Ht8xT4aAx8iRzGCcgF8Zu+f21Whpy/e+wVAAuE8gtXspLzaeUDZsf/cHk8sKe266gMnqOrKL2UO5Z9V7Nlhmtwh0v2Z7ARr9yir0li4UuC4dw51InYUsOF0xrTzUp3TOmlwjCEzGzLihqnQlthhbgnCQSAhfsf80SY98 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4468.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(136003)(376002)(39860400002)(366004)(396003)(346002)(66476007)(8676002)(5660300002)(66946007)(1076003)(66556008)(36756003)(4326008)(478600001)(7416002)(186003)(2616005)(8936002)(103116003)(52116002)(38100700002)(86362001)(6486002)(26005)(316002)(6666004)(41300700001)(921005)(38350700002)(6512007)(83380400001)(2906002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9GqUdBWyOAN5hMc1++zQvan46+BQq49DgtPH+Pj3WjmkGHVFvsTIWhoKy3eGC0ycTxmIYvTAnqW140WqdjD4uhpsEI0XpZ/aFsZASx+YbuPcVI6i2Mvl3VSpbT0vDdMA/7QQZSzH7NIoUOvCEl2GtM9flZkjyy0S0VF5sUcr8DhSL0sukop5aijfMYqtkXGHepmeAiTvKtIOhD+2sfDc2gRuzbB5Ph2NUH1V+rxCNcPvI9l7eYL0RAnvNyD3yzEDlnr/7+LwryZyizeEURtMsQm3X59N8O+OLaTYDzVVHfjaZ7AblR7Uw+Pc4+2o/ufrDhGDksBfvZzaYjyTg0nC8Drclb+plLCJUQWy2Lrd0Z0RUFO2hFQZdRC1Lio+CS2U0BMV71TWv0tW6LCE4iGhfnTJ6+YSGKQoi4y28C8Hrjoch6kYiIq5O3ky9irsg86ZYsh/eW9Zhn6qMVIvQJsOl7x6iJzgckkIj5BP1jjg1wkZKF94wwE1UYAWlyvE6cqKcKQHgxZCRqGUFs0cPPY4Se7z5ta0grxn1rtG+jIVkJh9KwmFGEUxgI8vgSBsmkAD5Y5vKqd8lEA3wslzB2FNvVzjOCZURI4sF1+TN6DyXdPiih8ok7/DonpAvXb/p9m63Gxqdtz2YBcuq5gDxYvwkmhBntwCD/F5d8Og/u8BrydO3o0wFjqrxbXI476N4bDPAUHoMmjDXcz9gFMZ1euPl4S8gpbtqzozqWES/Q0sSa22mn41/cX7KbBeuHnARFxQJo59Oi4sNvkxpY0up/Wj/TkiwlueS9nLcVf1XVp0CJi6aLnog3GbmPoP1WGtXnMsrAIKmfmIazQvmNKeESMJuYwIene4Pe6XNdCrayolgIq63MqdGXLGY8XqivXvYqjcbB/Gxoct7T4aAZ0YWFE7uS+KmxKZ/jww0SvPNdd6uKx8unmrloBbskYL7OiwmIYuh1urJyYq9bi3UVJDXSmvgstIsEnjcO25sfBHsHyXFegMt+De251ven0MPo5Uvx+bKaRY/CTYveUNdujahy28y3VOiGn9aHpgJ+yejkGUch4AlPo1fMcINynYIztzw5BGGqb0Xq/sN0P/wtMqLzoswyg+3e5yO1LbJYjcBcT1Vj/IbEWvnUHbrsOdrwNOe5tkX2f0AIVvRr9rJCJjlq3F1KBbAxEly/SK9F5eeP4fqkNmMdjc5LImzFto0xVHmPKPUdXur6wW5Uiv1Pe87qpT0oZw6mw+utNQGRW3/DypL8T+c7FAYDNweLX6jYteBcudkvTbd+rYFmiMngvtg3hGAt4CriO2DH4SM5GG+kL86FA4I+3QYpyW43rakcHQgHD/kgQ7cx41BulboZML2OtDVD6PCNBD/bYvc+mlo0GLwoxP5baO1skDQphYsbYbT+4K2DlVA1X8eut3gprxQ/j/GQXAUMPyvsZ2u91RLkPKhUUdFWBL18YcN0ODWzZnKgVk0iPTm8KkbU1q5KeqbFZCi6UvXPq4gGm/nIqxike6rG8X3jnwYg3kFNMtnlQOI/AFfUFLM8GdZovOiTOejyY9D/MIYeGVMyiCuieDdbT7iKdZQ0it1fq0YCd69WYMowUe+VoGIbr8tAOmqPJpQSwGGw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d27ce05-7068-404d-187a-08da7b77daa0 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4468.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2022 08:59:52.8720 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hxyXyzPho+HDe8qFggmu1tFnvdULqc0G3McV/X3CwSO2xmHBuRpeUbWR3HgJVoojzODbr1LBlQNUA6Yei4aZvA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2744 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-11_04,2022-08-10_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208110025 X-Proofpoint-GUID: I5rzd45phqQAHhlue27uqgBrxxq93oWo X-Proofpoint-ORIG-GUID: I5rzd45phqQAHhlue27uqgBrxxq93oWo ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1660208403; a=rsa-sha256; cv=pass; b=s1akILeFOxW+pBJ3fEAwr0CFB8UKT1lx1WXzw99IU4odC0+ZNRa5H1g5r5WwhgGu/Q2N9G 18gZHOKynafCqO6TW95oM1pjFFuS2F7gr3IOhS6AiFv3KWPEXBb/Pe4MFPlEeVnNZftBEf 0ed12SgPztZL6gnebrdqnv5tdaqSel8= ARC-Authentication-Results: i=2; imf19.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=A9sIssYt; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=LME0GOPd; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf19.hostedemail.com: domain of imran.f.khan@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=imran.f.khan@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660208403; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=qAM0pn4UF0rTJdPp3mQT8Fre9fDAqiSMo99z3uMd/ao=; b=Sl3HiyiiKB75gWHEujrCWv1YY556JleoTIw+pmSAcwWx+Lz0tIhOcLvUKeIkchqmgmB3bh EynxiRefGgp1LjAdhPU5lV1tE8xpOOeAgpp/bN0fZBGxxo2WIsWCDVHyT7k24SycvyQfY0 PkOYdnB7iVx/rrf0arI3J0JhRSe+W6I= X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 532C61A015F Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=A9sIssYt; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=LME0GOPd; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf19.hostedemail.com: domain of imran.f.khan@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=imran.f.khan@oracle.com X-Stat-Signature: 6g7noynbsm4ufy4b6qehwuhfp6tks6qy X-Rspam-User: X-HE-Tag: 1660208403-485111 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: By default kfence allocation can happen for any slab object, whose size is up to PAGE_SIZE, as long as that allocation is the first allocation after expiration of kfence sample interval. But in certain debugging scenarios we may be interested in debugging corruptions involving some specific slub objects like dentry or ext4_* etc. In such cases limiting kfence for allocations involving only specific slub objects will increase the probablity of catching the issue since kfence pool will not be consumed by other slab objects. This patch introduces a sysfs interface '/sys/kernel/slab//skip_kfence' to disable kfence for specific slabs. Having the interface work in this way does not impact current/default behavior of kfence and allows us to use kfence for specific slabs (when needed) as well. The decision to skip/use kfence is taken depending on whether kmem_cache.flags has (newly introduced) SLAB_SKIP_KFENCE flag set or not. Signed-off-by: Imran Khan Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Marco Elver Reviewed-by: Vlastimil Babka --- Changes since v1: - Remove RFC tag include/linux/slab.h | 6 ++++++ mm/kfence/core.c | 7 +++++++ mm/slub.c | 27 +++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) base-commit: 40d43a7507e1547dd45cb02af2e40d897c591870 diff --git a/include/linux/slab.h b/include/linux/slab.h index 0fefdf528e0d..947d912fd08c 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -119,6 +119,12 @@ */ #define SLAB_NO_USER_FLAGS ((slab_flags_t __force)0x10000000U) +#ifdef CONFIG_KFENCE +#define SLAB_SKIP_KFENCE ((slab_flags_t __force)0x20000000U) +#else +#define SLAB_SKIP_KFENCE 0 +#endif + /* The following flags affect the page allocator grouping pages by mobility */ /* Objects are reclaimable */ #define SLAB_RECLAIM_ACCOUNT ((slab_flags_t __force)0x00020000U) diff --git a/mm/kfence/core.c b/mm/kfence/core.c index c252081b11df..8c08ae2101d7 100644 --- a/mm/kfence/core.c +++ b/mm/kfence/core.c @@ -1003,6 +1003,13 @@ void *__kfence_alloc(struct kmem_cache *s, size_t size, gfp_t flags) return NULL; } + /* + * Skip allocations for this slab, if KFENCE has been disabled for + * this slab. + */ + if (s->flags & SLAB_SKIP_KFENCE) + return NULL; + if (atomic_inc_return(&kfence_allocation_gate) > 1) return NULL; #ifdef CONFIG_KFENCE_STATIC_KEYS diff --git a/mm/slub.c b/mm/slub.c index 862dbd9af4f5..ee8b48327536 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5745,6 +5745,30 @@ STAT_ATTR(CPU_PARTIAL_NODE, cpu_partial_node); STAT_ATTR(CPU_PARTIAL_DRAIN, cpu_partial_drain); #endif /* CONFIG_SLUB_STATS */ +#ifdef CONFIG_KFENCE +static ssize_t skip_kfence_show(struct kmem_cache *s, char *buf) +{ + return sysfs_emit(buf, "%d\n", !!(s->flags & SLAB_SKIP_KFENCE)); +} + +static ssize_t skip_kfence_store(struct kmem_cache *s, + const char *buf, size_t length) +{ + int ret = length; + + if (buf[0] == '0') + s->flags &= ~SLAB_SKIP_KFENCE; + else if (buf[0] == '1') + s->flags |= SLAB_SKIP_KFENCE; + else + ret = -EINVAL; + + return ret; +} +SLAB_ATTR(skip_kfence); + +#endif + static struct attribute *slab_attrs[] = { &slab_size_attr.attr, &object_size_attr.attr, @@ -5812,6 +5836,9 @@ static struct attribute *slab_attrs[] = { &failslab_attr.attr, #endif &usersize_attr.attr, +#ifdef CONFIG_KFENCE + &skip_kfence_attr.attr, +#endif NULL };