From patchwork Tue Nov 1 21:14:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13889 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3213749wru; Tue, 1 Nov 2022 14:18:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM46GUgB0h/OyMmElG5TqtYADX0ukIBUREZ374EeYlIDjOt1d39HrDJ9NpciSbLpZhPOc+a2 X-Received: by 2002:a17:90b:4b4e:b0:214:9b2:423c with SMTP id mi14-20020a17090b4b4e00b0021409b2423cmr6337082pjb.125.1667337509877; Tue, 01 Nov 2022 14:18:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667337509; cv=none; d=google.com; s=arc-20160816; b=TETkJUCO6k2Il5u82NR2NPY0TDq7Dx0RZbNW+Xfo15ofVVbA9wy3z0Vu4nQ3XkhuPM 7QF4PzM0MPxkWKDcWQ0hyCikK7a7dPJXkaNJqMfa/zDDsG70Hs/yBrhGCgB47qOy6Mdy dtW6MbgcvFVeEywUiHCwGOQ3cKyrjl83cEWnwvxO4ZlSMmEHBxw5r+fqdcW20UQI89cZ yLWnbbMAM+kP/0SAXSj03kC/GrEL4Y7nYtmaNCbe8xr+biuaus+GOW08mkhHU1+4mets tXOq/4YQ3J/wFS8ODBvN8sb9AHO1yUuhbGEmG7Yx8y2RCKER9/jOlVGh+tGcHpDXQscr VJ2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=pI0R7ahbwYCPKtvjPQzg5QzcH2XvT3CW8LFnB87t8Nk=; b=pR4qmf8BhESPHnh3+5k5m9LONaphW2axt8xJU6LA+KC3CioYhs5n/ocA0MGLoUY1kP eqd9YBl5BwHsFMzfEMoAj2rEZTFyQhYQgwnmAwVZqlxn8DXK01XA3yrqhBoSmzVxDPsO diT/yW3+BzTK/rrtwmLSFPb8KUuG3HNXieUEuAcz1YKPIAP1hkOjP1KQbazwr7JTYsbv NgqSEfnl5wA3/CsZZ0+bXHe5WHKV+QZSaU+bV9SaN7QlwFTmz9xQ7b62cUD3J4vkkCFr vUPa7P5SOEnOduC0zL1dqsYgcJlLRzYaZAaqoS6iU59EXV0pPNEowEYyJPXr8UdWruqs A48w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i7-20020a170902cf0700b00186a394aed8si14433295plg.147.2022.11.01.14.18.17; Tue, 01 Nov 2022 14:18:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230338AbiKAVQk (ORCPT + 99 others); Tue, 1 Nov 2022 17:16:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230155AbiKAVQA (ORCPT ); Tue, 1 Nov 2022 17:16:00 -0400 Received: from smtp.smtpout.orange.fr (smtp-16.smtpout.orange.fr [80.12.242.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6C5A1DA78 for ; Tue, 1 Nov 2022 14:15:26 -0700 (PDT) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id pyanoKD2rsfCIpybUoWfKf; Tue, 01 Nov 2022 22:15:24 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 01 Nov 2022 22:15:24 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: Pasha Tatashin , Andrew Morton , Kees Cook Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-mm@kvack.org, linux-hardening@vger.kernel.org Subject: [PATCH 21/30] mm: Use kstrtobool() instead of strtobool() Date: Tue, 1 Nov 2022 22:14:09 +0100 Message-Id: <03f9401a6c8b87a1c786a2138d16b048f8d0eb53.1667336095.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748330096742585581?= X-GMAIL-MSGID: =?utf-8?q?1748330096742585581?= strtobool() is the same as kstrtobool(). However, the latter is more used within the kernel. In order to remove strtobool() and slightly simplify kstrtox.h, switch to the other function name. While at it, include the corresponding header file () Signed-off-by: Christophe JAILLET Reviewed-by: Kees Cook Acked-by: Pasha Tatashin --- This patch is part of a serie that axes all usages of strtobool(). Each patch can be applied independently from the other ones. The last patch of the serie removes the definition of strtobool(). You may not be in copy of the cover letter. So, if needed, it is available at [1]. [1]: https://lore.kernel.org/all/cover.1667336095.git.christophe.jaillet@wanadoo.fr/ --- mm/page_table_check.c | 3 ++- mm/usercopy.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/page_table_check.c b/mm/page_table_check.c index 433dbce13fe1..93e633c1d587 100644 --- a/mm/page_table_check.c +++ b/mm/page_table_check.c @@ -4,6 +4,7 @@ * Copyright (c) 2021, Google LLC. * Pasha Tatashin */ +#include #include #include @@ -23,7 +24,7 @@ EXPORT_SYMBOL(page_table_check_disabled); static int __init early_page_table_check_param(char *buf) { - return strtobool(buf, &__page_table_check_enabled); + return kstrtobool(buf, &__page_table_check_enabled); } early_param("page_table_check", early_page_table_check_param); diff --git a/mm/usercopy.c b/mm/usercopy.c index c1ee15a98633..4c3164beacec 100644 --- a/mm/usercopy.c +++ b/mm/usercopy.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -258,7 +259,7 @@ static bool enable_checks __initdata = true; static int __init parse_hardened_usercopy(char *str) { - if (strtobool(str, &enable_checks)) + if (kstrtobool(str, &enable_checks)) pr_warn("Invalid option string for hardened_usercopy: '%s'\n", str); return 1;