lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZPcDAk81DAqevy43@smile.fi.intel.com>
Date:   Tue, 5 Sep 2023 13:29:22 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Breno Leitao <leitao@...ian.org>
Cc:     sdf@...gle.com, axboe@...nel.dk, asml.silence@...il.com,
        willemdebruijn.kernel@...il.com, martin.lau@...ux.dev,
        krisman@...e.de, Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Song Liu <song@...nel.org>,
        Yonghong Song <yonghong.song@...ux.dev>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>, Hao Luo <haoluo@...gle.com>,
        Jiri Olsa <jolsa@...nel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>, bpf@...r.kernel.org,
        linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
        io-uring@...r.kernel.org, Kuniyuki Iwashima <kuniyu@...zon.com>,
        Alexander Mikhalitsyn <alexander@...alicyn.com>,
        Xin Long <lucien.xin@...il.com>,
        David Howells <dhowells@...hat.com>,
        Jason Xing <kernelxing@...cent.com>
Subject: Re: [PATCH v4 04/10] net/socket: Break down __sys_getsockopt

On Mon, Sep 04, 2023 at 09:24:57AM -0700, Breno Leitao wrote:
> Split __sys_getsockopt() into two functions by removing the core
> logic into a sub-function (do_sock_getsockopt()). This will avoid
> code duplication when doing the same operation in other callers, for
> instance.
> 
> do_sock_getsockopt() will be called by io_uring getsockopt() command
> operation in the following patch.
> 
> The same was done for the setsockopt pair.

...

> +	ops = READ_ONCE(sock->ops);
> +	if (level == SOL_SOCKET) {
> +		err = sk_getsockopt(sock->sk, level, optname, optval, optlen);
> +	} else if (unlikely(!ops->getsockopt)) {
> +		err = -EOPNOTSUPP;
> +	} else {
> +		if (WARN_ONCE(optval.is_kernel || optlen.is_kernel,
> +			      "Invalid argument type"))
> +			return -EOPNOTSUPP;
> +
> +		err = ops->getsockopt(sock, level, optname, optval.user,
> +				      optlen.user);
> +	}

Can be written as

	} else if (WARN_ONCE(optval.is_kernel || optlen.is_kernel,
			     "Invalid argument type"))
		return -EOPNOTSUPP;
	} else {
		err = ops->getsockopt(sock, level, optname, optval.user,
				      optlen.user);
	}

With that done, the {} are not needed anymore.

> +	if (!compat) {

	if (compat)
		return err;

> +		max_optlen = BPF_CGROUP_GETSOCKOPT_MAX_OPTLEN(optlen);

> +		err = BPF_CGROUP_RUN_PROG_GETSOCKOPT(sock->sk, level, optname,
> +						     optval, optlen, max_optlen,
> +						     err);

	return ... ?

> +	}
> +
> +	return err;
> +}

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ