From nobody Thu Apr 16 07:11:27 2026 Received: from mailgw2.hygon.cn (unknown [101.204.27.37]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 91E02199FBA for ; Mon, 2 Mar 2026 03:25:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=101.204.27.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772421951; cv=none; b=BaHiZ5Uok8f8+BF7eq60ciGnaXdeUIwSYV/cWxhWAcuxk9Umm4FNtKrqIRwRsofZZt/NW8jsSLhUyiT/Y0KbPkg0sVzmUl4w/1SDxtH15Oz+UFDgsGiSG9SQGB4a2aQ0QfFFDKRhL+HpWP6FTcPtJK5mq361v9CPWwAY5zSPUeY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772421951; c=relaxed/simple; bh=YxEWVR5N0sIrpYyY24trhIBft280xtzXaNHDURArw/w=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=MjmYKeC0I3GjWzsRRoq49FowHtAdEkf9QveoMLB71WZc6171Hg59Qb0y5l8jHvt2ire5iUx6M66UPo1vr/R+yD211lLiJvltQLJKRhxmZePctxkfbDIkvRTL68A4R3Y/lL1sQetQSNCnrdm2COvvViC1+h4935kmuQP6WR1G/Wc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hygon.cn; spf=pass smtp.mailfrom=hygon.cn; arc=none smtp.client-ip=101.204.27.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hygon.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hygon.cn Received: from maildlp1.hygon.cn (unknown [127.0.0.1]) by mailgw2.hygon.cn (Postfix) with ESMTP id 4fPPSr5W6bz1YHN2d; Mon, 2 Mar 2026 11:25:16 +0800 (CST) Received: from maildlp1.hygon.cn (unknown [172.23.18.60]) by mailgw2.hygon.cn (Postfix) with ESMTP id 4fPPSq286nz1YHN2d; Mon, 2 Mar 2026 11:25:15 +0800 (CST) Received: from cncheex04.Hygon.cn (unknown [172.23.18.114]) by maildlp1.hygon.cn (Postfix) with ESMTPS id 0A01A751A; Mon, 2 Mar 2026 11:25:13 +0800 (CST) Received: from BJ-HV00147.Hygon.cn (172.18.22.73) by cncheex04.Hygon.cn (172.23.18.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Mon, 2 Mar 2026 11:25:12 +0800 From: To: , , , , CC: , , , , , , , , wangguangju Subject: [RESEND] x86/pkeys: Convert copy_from_user() + kstrtouint() to kstrtouint_from_user() Date: Mon, 2 Mar 2026 11:24:36 +0800 Message-ID: <20260302032436.197115-1-wangguangju@hygon.cn> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: cncheex06.Hygon.cn (172.23.18.116) To cncheex04.Hygon.cn (172.23.18.114) Content-Type: text/plain; charset="utf-8" From: wangguangju This simplifies the code and avoids open-coded buffer handling. No functional changes intended. Signed-off-by: wangguangju --- arch/x86/mm/pkeys.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/arch/x86/mm/pkeys.c b/arch/x86/mm/pkeys.c index 7418c367e328..c7a2503dfc16 100644 --- a/arch/x86/mm/pkeys.c +++ b/arch/x86/mm/pkeys.c @@ -140,19 +140,12 @@ static ssize_t init_pkru_read_file(struct file *file,= char __user *user_buf, static ssize_t init_pkru_write_file(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - char buf[32]; - ssize_t len; u32 new_init_pkru; + int ret; =20 - len =3D min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, len)) - return -EFAULT; - - /* Make the buffer a valid string that we can not overrun */ - buf[len] =3D '\0'; - if (kstrtouint(buf, 0, &new_init_pkru)) - return -EINVAL; - + ret =3D kstrtouint_from_user(user_buf, count, 0, &new_init_pkru); + if (ret) + return ret; /* * Don't allow insane settings that will blow the system * up immediately if someone attempts to disable access --=20 2.43.0