Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2174057iof; Tue, 7 Jun 2022 22:10:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxU1Pe8V89VcCJVDtVzcBVwUUCvvTvcWNgQ9+prYIYELfWr0xuhOTU3UEQzVP0M8luXn7fy X-Received: by 2002:a63:d358:0:b0:3fa:f500:4487 with SMTP id u24-20020a63d358000000b003faf5004487mr28620506pgi.595.1654665043897; Tue, 07 Jun 2022 22:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654665043; cv=none; d=google.com; s=arc-20160816; b=OgWBNeuLvFs+FdP4M0jOxk2KvYYIekqtkLUVm7jokYMfk86DrrB2gGjBDm1jYlQtqk I2tdtV7TFyMYgm0uWz0M98fsqmC/XgbUGmW0L1azzg0pN7EnMEkXHAFCgtzv8sJ6TEP/ LREB1sLyTsuEXmiT/qyoXJes8QOBvN5vXdwaANAusvzi/sGKR381FLufchqw6qV3E084 IA9rKZ+kDZDz4mbOp66b062D3KL/JhK6iO56FgaIM63jkGtEIOywzpfrENqIq7F8SnvM ygGsEqYtZE82JEAZu4GGQAWk55EaPB78n4Bd5VGOFBf3mTqP07O/2Il/enjEkSeWIqya fcfg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=jFci08MJtHyZ2Sg0flpZ8o3EZOlPnMJ39ZuIKk5knAc=; b=f5y6bgmVx0pm9f+gjmAfYItaNbNdPjtj1BHP64hqON6Y5ANYsUKSMJgHTTPMf2pGrg R5WmRGRTAj/i35jUHqCRBcSPOuJZh61D6apZZYWcErhH3IV8qmNlfjjnx+kril43GRkT NHCDrYBytTqCUna9onu+/YRDE3OAkxzycMr5rG9knRWbGKuwIeJh2I3yzxPyo7YqMuuz qOVkSoFeguuxLEN/hv/3sZT8nrUMpBzw65SBMgK19Nr/Pe9tCMvl1pot+ep72wsPQCEi BzuEwvSIDRNKiddf/DXseVA27aFdvicTH2bUpWwSL9jyPnN64D/8jGDR0frsGJxCc3b9 Famw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="B/jcmYCN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x23-20020aa79197000000b00518418d73ddsi19945277pfa.333.2022.06.07.22.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:10:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="B/jcmYCN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 409273FB118; Tue, 7 Jun 2022 21:41:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238551AbiFGKSg (ORCPT + 99 others); Tue, 7 Jun 2022 06:18:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240860AbiFGKSb (ORCPT ); Tue, 7 Jun 2022 06:18:31 -0400 Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26A94C0469 for ; Tue, 7 Jun 2022 03:18:29 -0700 (PDT) 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=1654597107; 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=jFci08MJtHyZ2Sg0flpZ8o3EZOlPnMJ39ZuIKk5knAc=; b=B/jcmYCNkTz4nvRVIKjaDlbs77Pg6bBCmMLFXAmfIIdDFJUyTsQ9N059I6T98OFhFnynRR RnY9rYDprleTYUyJtHlFBYLNfpWjSDweZQvzNvPNHtgFdJVGtt00IQXEfBDuDHDT4BIyo+ 1BmWS0GwsB9xOVL1WiwHiv2F70YBj78= From: Yajun Deng To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com Cc: linux-kernel@vger.kernel.org, Yajun Deng Subject: [PATCH v2] sched/deadline: Use proc_douintvec_minmax() limit minimum value Date: Tue, 7 Jun 2022 18:18:07 +0800 Message-Id: <20220607101807.249965-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 sysctl_sched_dl_period_max and sysctl_sched_dl_period_min are unsigned integer, but proc_dointvec() wouldn't return error even if we set a negative number. Use proc_douintvec_minmax() instead of proc_dointvec(). Add extra1 for sysctl_sched_dl_period_max and extra2 for sysctl_sched_dl_period_min. It's just an optimization for match data and proc_handler in struct ctl_table. The 'if (period < min || period > max)' in __checkparam_dl() will work fine even if there hasn't this patch. v2: - update the log message. Signed-off-by: Yajun Deng --- kernel/sched/deadline.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index b5152961b743..5867e186c39a 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -30,14 +30,16 @@ static struct ctl_table sched_dl_sysctls[] = { .data = &sysctl_sched_dl_period_max, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = proc_douintvec_minmax, + .extra1 = (void *)&sysctl_sched_dl_period_min, }, { .procname = "sched_deadline_period_min_us", .data = &sysctl_sched_dl_period_min, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = proc_douintvec_minmax, + .extra2 = (void *)&sysctl_sched_dl_period_max, }, {} }; -- 2.25.1