From nobody Sat Nov 30 05:41:47 2024 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9AF4AAD24; Wed, 11 Sep 2024 03:19:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726024745; cv=none; b=Wx+uNBDk15A3jysuFIk4vNdv8wp6adu9Ja2rz5QKNha1lpaew9MW4zJ6tv/DcIOQNAHiLN8vBduNFFQkdeok0kRuuU8Tj19pab1wqawbOVqvjdYAcIKIL4N6nSBbe9TSO32JU8zJ3Nc1wZO/pUqjbJJXO1igXKyQMeDAzE7kzto= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726024745; c=relaxed/simple; bh=DADXaN0GIvH5RP/RL4GpJZhFaj4Izo3dYucAmkcJ1q4=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=Tua0RMc03Rxzjh1rZ8fjnfExnCeYq8o3K03B09+mVveEEDOxD17QGl89V5VMIfBLRynjhanSoFO9lQb84BdA52ihi93J4yQxqIe7mI4m3EJzHRmHeGYY2E8nTGPRNo6uQrC9bKmo/V/bMTpsD56WDIuKMwKhktPMOYlByaJiTfs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=KmQG9QV4; arc=none smtp.client-ip=117.135.210.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="KmQG9QV4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:From:Subject:Message-ID:MIME-Version: Content-Type; bh=NCpeqR1K5cHYjuSdgGKlaa6YEWw7IT3OlpHPPl9Jo10=; b=KmQG9QV4tbIsfxm55JpX588cIjEzKYeW72JRTfi0xohjLFjc0U0f0NeEF4iVv1 Gi94PImXMpqsREBXEmKIRaTw+uY91n1jf3e0mZaGyh76gOtrxhni6V0BATPIi/GV C/8fJ540T9PmdBfWrAta3Mba6qPlYIYEIjhZzUf+26LD0= Received: from localhost (unknown [120.26.85.94]) by gzga-smtp-mta-g2-2 (Coremail) with SMTP id _____wD3f2LoC+FmuhyiGg--.42294S2; Wed, 11 Sep 2024 11:18:01 +0800 (CST) Date: Wed, 11 Sep 2024 11:18:00 +0800 From: Qianqiang Liu To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Should the return value of the copy_from_sockptr be checked? Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-CM-TRANSID: _____wD3f2LoC+FmuhyiGg--.42294S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrXr1fZry3uw48GrWfKFy3Jwb_yoWxWrg_Ar yUAryUWFWqqwn8C395CrWrXrWjqFsFgr10g3WDAr43Ca1rta4Ygw4vkrykAr1UGa4xZF1D Cr95Cr9xAay7KjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUepWlPUUUUU== X-CM-SenderInfo: xtld01pldqwhxolxqiywtou0bp/1tbiYAdXamV4JKb83wAAsm Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Hi, Should the return value of the copy_from_sockptr in net/socket.c be checked? The following patch may solve this problem: diff --git a/net/socket.c b/net/socket.c index 0a2bd22ec105..6b9a414d01d5 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2370,8 +2370,11 @@ int do_sock_getsockopt(struct socket *sock, bool com= pat, int level, if (err) return err; =20 - if (!compat) - copy_from_sockptr(&max_optlen, optlen, sizeof(int)); + if (!compat) { + err =3D copy_from_sockptr(&max_optlen, optlen, sizeof(int)); + if (err) + return -EFAULT; + } =20 ops =3D READ_ONCE(sock->ops); if (level =3D=3D SOL_SOCKET) { --=20 Best, Qianqiang Liu