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]
Date:   Mon, 13 Mar 2023 17:24:41 -0700
From:   Jakub Kicinski <kuba@...nel.org>
To:     Anjali Kulkarni <anjali.k.kulkarni@...cle.com>
Cc:     davem@...emloft.net, edumazet@...gle.com, pabeni@...hat.com,
        zbr@...emap.net, brauner@...nel.org, johannes@...solutions.net,
        ecree.xilinx@...il.com, leon@...nel.org, keescook@...omium.org,
        socketcan@...tkopp.net, petrm@...dia.com,
        linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH v1 2/5] connector/cn_proc: Add filtering to fix some
 bugs

On Fri, 10 Mar 2023 14:15:44 -0800 Anjali Kulkarni wrote:
> diff --git a/include/linux/connector.h b/include/linux/connector.h
> index 487350bb19c3..1336a5e7dd2f 100644
> --- a/include/linux/connector.h
> +++ b/include/linux/connector.h
> @@ -96,7 +96,11 @@ void cn_del_callback(const struct cb_id *id);
>   *
>   * If there are no listeners for given group %-ESRCH can be returned.
>   */
> -int cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 portid, u32 group, gfp_t gfp_mask);
> +int cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 portid,
> +			 u32 group, gfp_t gfp_mask,
> +			 int (*filter)(struct sock *dsk, struct sk_buff *skb,
> +				       void *data),
> +			 void *filter_data);

kdoc needs to be extended

> diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
> index 003c7e6ec9be..b311375b8c4c 100644
> --- a/net/netlink/af_netlink.c
> +++ b/net/netlink/af_netlink.c
> @@ -63,6 +63,7 @@
>  #include <linux/net_namespace.h>
>  #include <linux/nospec.h>
>  #include <linux/btf_ids.h>
> +#include <linux/connector.h>
>  
>  #include <net/net_namespace.h>
>  #include <net/netns/generic.h>
> @@ -767,9 +768,14 @@ static int netlink_release(struct socket *sock)
>  	/* must not acquire netlink_table_lock in any way again before unbind
>  	 * and notifying genetlink is done as otherwise it might deadlock
>  	 */
> -	if (nlk->netlink_unbind) {
> +	if (nlk->netlink_unbind && nlk->groups) {
>  		int i;
> -
> +		if (sk->sk_protocol == NETLINK_CONNECTOR) {
> +			if (test_bit(CN_IDX_PROC - 1, nlk->groups)) {
> +				kfree(sk->sk_user_data);
> +				sk->sk_user_data = NULL;
> +			}
> +		}
>  		for (i = 0; i < nlk->ngroups; i++)
>  			if (test_bit(i, nlk->groups))
>  				nlk->netlink_unbind(sock_net(sk), i + 1);

This is clearly a layering violation, right?
Please don't add "if (family_x)" to the core netlink code.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ