Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp266866ybg; Mon, 8 Jun 2020 23:23:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSsn71LiYfErn7drHM6SdUHKMgVoN7jz2btL+PrVIGhJuBzb216ovYJ02u5rg4DagdB2tz X-Received: by 2002:aa7:c6c4:: with SMTP id b4mr26339238eds.210.1591683819697; Mon, 08 Jun 2020 23:23:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591683819; cv=none; d=google.com; s=arc-20160816; b=Ak4ks/QvNyr8kFsSGdifFi+JLimAODo54apNDkjD+oeFB+IuipdccV2M2lp1CjBgNq E0JTIhjcKI2VLHL1Ohg31/mOn198GmB3k4VX1lgmOmMD4xLckOwyNSUIbvvOsqNgA6zA zVoXy+imKAjqgnLewvf07ZSodHU2frWBH0YEtkssMIS3vl6bkLN3nVK9opi3VPE3QnTq pNdhIE0Gwr2AJavG5xPKxDP2QtXGzemuRUta2fTHC9RfolXx6IWNfsis2mKg3cWUZCV8 +dN/24hhFPuMWIQLwI9fLoE17DjDX0O82Lk0n02CFKbNoNw2iTcrJ3HeormnDC0Qq2U2 WoYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=LjD7cozrZCIWR6QvvWbPKLzrk5BYwisdAKMNEsFcGTM=; b=Gha+0ycG7o2D2xaq1QaCDmydG3aqgUNGvQoMIjdA7/CgnNXTQbqQ+7uvZAF/R3QUZZ gsz8i17CptQ9oRt5c+uVjbZ8NsZjzit7lKlNVlUYFs0JNkmEy7Y7eMPuiXONBEemPuhj MKLfWVFnl2E56jcn4pdz19VFqR+kNrIyakVEqf/V/NIw3fF4bSGLYZrzHHepQu7RBFZM CtCvlTCVrk+1gndzzmca/mNRVEvSMuyplhuPN8rAfXB0VZ3gIGawOwKkETKONEIcenpA PxyDXo/zZKWQlKBQl3VVd05mMzITVy98EizJB8ZnzwJxUT6h499oZ032pb3kSpr466Yp 6yiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p9si9344673edx.554.2020.06.08.23.22.55; Mon, 08 Jun 2020 23:23:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727844AbgFIGUW (ORCPT + 99 others); Tue, 9 Jun 2020 02:20:22 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:54024 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726886AbgFIGUU (ORCPT ); Tue, 9 Jun 2020 02:20:20 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 60BDBDA984993C9E617F; Tue, 9 Jun 2020 14:20:17 +0800 (CST) Received: from use12-sp2.huawei.com (10.67.189.174) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Tue, 9 Jun 2020 14:20:08 +0800 From: Xiaoming Ni To: , , CC: , , , Subject: [PATCH] sysctl: Delete the code of sys_sysctl Date: Tue, 9 Jun 2020 14:20:05 +0800 Message-ID: <1591683605-8585-1-git-send-email-nixiaoming@huawei.com> X-Mailer: git-send-email 1.8.5.6 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.189.174] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since the commit 61a47c1ad3a4dc ("sysctl: Remove the sysctl system call"), sys_sysctl has lost its actual role: any input can only return an error. Delete the code and return -ENOSYS directly at the function entry Signed-off-by: Xiaoming Ni --- kernel/sysctl_binary.c | 146 +------------------------------------------------ 1 file changed, 2 insertions(+), 144 deletions(-) diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c index 7d550cc..41a88f8 100644 --- a/kernel/sysctl_binary.c +++ b/kernel/sysctl_binary.c @@ -1,126 +1,11 @@ // SPDX-License-Identifier: GPL-2.0 -#include #include -#include "../fs/xfs/xfs_sysctl.h" -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -static ssize_t binary_sysctl(const int *name, int nlen, - void __user *oldval, size_t oldlen, void __user *newval, size_t newlen) -{ - return -ENOSYS; -} - -static void deprecated_sysctl_warning(const int *name, int nlen) -{ - int i; - - /* - * CTL_KERN/KERN_VERSION is used by older glibc and cannot - * ever go away. - */ - if (nlen >= 2 && name[0] == CTL_KERN && name[1] == KERN_VERSION) - return; - - if (printk_ratelimit()) { - printk(KERN_INFO - "warning: process `%s' used the deprecated sysctl " - "system call with ", current->comm); - for (i = 0; i < nlen; i++) - printk(KERN_CONT "%d.", name[i]); - printk(KERN_CONT "\n"); - } - return; -} - -#define WARN_ONCE_HASH_BITS 8 -#define WARN_ONCE_HASH_SIZE (1<nlen. */ - if (nlen < 0 || nlen > CTL_MAXNAME) - return -ENOTDIR; - /* Read in the sysctl name for simplicity */ - for (i = 0; i < nlen; i++) - if (get_user(name[i], args_name + i)) - return -EFAULT; - - warn_on_bintable(name, nlen); - - return binary_sysctl(name, nlen, oldval, oldlen, newval, newlen); -} - SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args) { - struct __sysctl_args tmp; - size_t oldlen = 0; - ssize_t result; - - if (copy_from_user(&tmp, args, sizeof(tmp))) - return -EFAULT; - - if (tmp.oldval && !tmp.oldlenp) - return -EFAULT; - - if (tmp.oldlenp && get_user(oldlen, tmp.oldlenp)) - return -EFAULT; - - result = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, oldlen, - tmp.newval, tmp.newlen); - - if (result >= 0) { - oldlen = result; - result = 0; - } - - if (tmp.oldlenp && put_user(oldlen, tmp.oldlenp)) - return -EFAULT; - - return result; + return -ENOSYS; } @@ -138,34 +23,7 @@ struct compat_sysctl_args { COMPAT_SYSCALL_DEFINE1(sysctl, struct compat_sysctl_args __user *, args) { - struct compat_sysctl_args tmp; - compat_size_t __user *compat_oldlenp; - size_t oldlen = 0; - ssize_t result; - - if (copy_from_user(&tmp, args, sizeof(tmp))) - return -EFAULT; - - if (tmp.oldval && !tmp.oldlenp) - return -EFAULT; - - compat_oldlenp = compat_ptr(tmp.oldlenp); - if (compat_oldlenp && get_user(oldlen, compat_oldlenp)) - return -EFAULT; - - result = do_sysctl(compat_ptr(tmp.name), tmp.nlen, - compat_ptr(tmp.oldval), oldlen, - compat_ptr(tmp.newval), tmp.newlen); - - if (result >= 0) { - oldlen = result; - result = 0; - } - - if (compat_oldlenp && put_user(oldlen, compat_oldlenp)) - return -EFAULT; - - return result; + return -ENOSYS; } #endif /* CONFIG_COMPAT */ -- 1.8.5.6