diff mbox series

Should the return value of the copy_from_sockptr be checked?

Message ID ZuEL6LhQ8bszGRdk@iZbp1asjb3cy8ks0srf007Z (mailing list archive)
State Not Applicable
Headers show
Series Should the return value of the copy_from_sockptr be checked? | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff fail author Signed-off-by missing
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 17 this patch: 17
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 13 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 24 this patch: 24
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-09-11--09-01 (tests: 763)

Commit Message

Qianqiang Liu Sept. 11, 2024, 3:18 a.m. UTC
Hi,

Should the return value of the copy_from_sockptr in net/socket.c be checked?
The following patch may solve this problem:

Comments

Cong Wang Sept. 11, 2024, 4:46 a.m. UTC | #1
On Wed, Sep 11, 2024 at 11:18:00AM +0800, Qianqiang Liu wrote:
> Hi,
> 
> Should the return value of the copy_from_sockptr in net/socket.c be checked?
> The following patch may solve this problem:

Yes, please submit a formal patch.
https://www.kernel.org/doc/html/latest/process/submitting-patches.html

Thanks.
diff mbox series

Patch

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 compat, int level,
 	if (err)
 		return err;
 
-	if (!compat)
-		copy_from_sockptr(&max_optlen, optlen, sizeof(int));
+	if (!compat) {
+		err = copy_from_sockptr(&max_optlen, optlen, sizeof(int));
+		if (err)
+			return -EFAULT;
+	}
 
 	ops = READ_ONCE(sock->ops);
 	if (level == SOL_SOCKET) {