From mboxrd@z Thu Jan 1 00:00:00 1970 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 945C9CF9C6B for ; Tue, 24 Sep 2024 19:46:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D7EC6B0093; Tue, 24 Sep 2024 15:46:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0883E6B00AB; Tue, 24 Sep 2024 15:46:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB8A96B00AC; Tue, 24 Sep 2024 15:46:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id CDC756B0093 for ; Tue, 24 Sep 2024 15:46:05 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 6152D1602EC for ; Tue, 24 Sep 2024 19:46:05 +0000 (UTC) X-FDA: 82600662690.19.B541D9A Received: from smtp.smtpout.orange.fr (smtp-28.smtpout.orange.fr [80.12.242.28]) by imf02.hostedemail.com (Postfix) with ESMTP id 3E01B8000D for ; Tue, 24 Sep 2024 19:46:02 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=wanadoo.fr header.s=t20230301 header.b=bkknMWkU; spf=pass (imf02.hostedemail.com: domain of christophe.jaillet@wanadoo.fr designates 80.12.242.28 as permitted sender) smtp.mailfrom=christophe.jaillet@wanadoo.fr; dmarc=pass (policy=quarantine) header.from=wanadoo.fr ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727207005; 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:in-reply-to:references:references:dkim-signature; bh=TVUQYXiQsfKBwm1bsadNvnge0M4C6PEwh0rK1nOokCw=; b=mOWkvaXy5ztI+Jgjw57YvrZe/uNGhBQXxFjE+aunAao4I8vs8BwxFu8nFTmLCWJPrt4OgX 2JJh2VT4vWNZ+CdybHg4RuIO0NULv9iQw8Ab27j3SeuWgoelJJ9zdpV4ZbeeTuiMjgwIe8 OupltPkh6lk4HLfRBcuwVrZSToSWmeg= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=wanadoo.fr header.s=t20230301 header.b=bkknMWkU; spf=pass (imf02.hostedemail.com: domain of christophe.jaillet@wanadoo.fr designates 80.12.242.28 as permitted sender) smtp.mailfrom=christophe.jaillet@wanadoo.fr; dmarc=pass (policy=quarantine) header.from=wanadoo.fr ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727207005; a=rsa-sha256; cv=none; b=drs0nj/FZvZPTAjK9ajhmIGX9u/etytuyp52v0gBnfOdI/mlF/8nd6/yedXKOn1vXqiCdZ A5hrnwh6z/CF8nvbvk6PiLdRC9gA1oCp/tv/8ld6VRgD6R57goIYYLd67HGOvsiJ4X3O8v v1Q7gK68IDZRH9i7PaxTvZNEQlp530Q= Received: from [192.168.1.37] ([90.11.132.44]) by smtp.orange.fr with ESMTPA id tBTzsVA7RO2lmtBTzsaLou; Tue, 24 Sep 2024 21:46:01 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1727207161; bh=TVUQYXiQsfKBwm1bsadNvnge0M4C6PEwh0rK1nOokCw=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=bkknMWkUG1mR22GldXTwvFx3us4GNWeV/uslbEYEasDG1ULcXRiG8ioYSmyfQvHFB ijQC6XZRJyDsPdjCgt9817/PnknNXUob/ucU5jL8hOiX8dlFCbjHD/qvEnaPIVpPLN 5N/sfuxKmf//jpkBRbS0VgVvzMesOMVS89TDUWIshncjBJpwqPnkpzk7T4OZFAqsvv khmIB8u6UIk7awUmL87OUtrqBvrKK1H6HLp6IN25Vjdcuuz9HKVgFbFX4sZQFSnbY8 it3Z7k4G19SHQfnHYnenXy5IreOJK3iaPDcDGc+5IPm8zI2T152pB6s9EEvGBZfJya VqyRHAbhxjjQA== X-ME-Helo: [192.168.1.37] X-ME-Auth: bWFyaW9uLmphaWxsZXRAd2FuYWRvby5mcg== X-ME-Date: Tue, 24 Sep 2024 21:46:01 +0200 X-ME-IP: 90.11.132.44 Message-ID: <67060a27-5830-4ea1-955f-722f1d2c83b4@wanadoo.fr> Date: Tue, 24 Sep 2024 21:45:59 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCHv2] mm: do not export const kfree and kstrdup variants To: Christoph Hellwig , Sergey Senozhatsky Cc: Andrew Morton , Andrey Skvortsov , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240924050937.697118-1-senozhatsky@chromium.org> <20240924065653.GQ38742@google.com> Content-Language: en-US, fr-FR From: Christophe JAILLET In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3E01B8000D X-Stat-Signature: p35x89swimoymtmzjzyqbho318mwe8fh X-Rspam-User: X-HE-Tag: 1727207162-621887 X-HE-Meta: U2FsdGVkX1//VcnhKuwUv++cADGcuczZHY7UtvZob1XHV52D+6THTaPi8RfVyk5njFTM6Nl8MDl4nWvesxc3m9hmjgeCNzqAMs5jwN/4TvmARR75t1EHQXU+dQMv44078epgBUWXBb3JwkqA5bXEnXyCQflyaMfXMX7o1vHSwrLK+3O185AjJ+xOLzq8V6SSBTvlPVb5bvE3qEKcLkmcAKHT/Uf47qq9JFY1G8Gs8t97vnwaEDUWhWIPEk/lHC0JmmnJbckCKXIa6Nq6CnhBANdR2dkE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MNehoGHQ7mG6gabbQgh84o3hml8wYbZpHZvpTA8lsq0W5 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Le 24/09/2024 à 09:02, Christoph Hellwig a écrit : > On Tue, Sep 24, 2024 at 03:56:53PM +0900, Sergey Senozhatsky wrote: >> Totally agree with all the points, I haven't looked at how >> popular that API was before sending out the patch. Is there >> some sort of "built time const" but for strings that we, perhaps, >> can add to kfree_const() (and make kfree_const() always inline)? >> So that we can turn this >> >> str = "boom"; >> ... >> kfree_const(str); >> >> into a safe scenario for modules. > > Not sure, but even then the API would be horrible as it still would > not work for constants in other modules than the one calling it. > > So, the best is to audit, at least code that can be built as a module for str = "boom" pattern, and fix relevant places? Or, considering that these these _const() versions are only there to save a few bytes of memory, wonder if it really worth it? In other word: 1) apply something like the patch below 2) remove the API At a minimum, I think that devm_kstrdup_const() could be removed. CJ diff --git a/mm/util.c b/mm/util.c index 4f1275023eb7..fd5e98fb6362 100644 --- a/mm/util.c +++ b/mm/util.c @@ -39,8 +39,7 @@ */ void kfree_const(const void *x) { - if (!is_kernel_rodata((unsigned long)x)) - kfree(x); + kfree(x); } EXPORT_SYMBOL(kfree_const); @@ -81,9 +80,6 @@ EXPORT_SYMBOL(kstrdup); */ const char *kstrdup_const(const char *s, gfp_t gfp) { - if (is_kernel_rodata((unsigned long)s)) - return s; - return kstrdup(s, gfp); } EXPORT_SYMBOL(kstrdup_const);