Commit 1d070720 authored by Ziyang Xuan's avatar Ziyang Xuan Committed by Jialin Zhang
Browse files

raw: fix KABI for backporting raw RCU conversion patches

Offering: HULK
hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6ECEK


CVE: NA

--------------------------------

In order to fix softlockup problem in raw sockets because global rwlock,
backport "raw: RCU conversion" series patches. That will introduce KABI
changes. This patch is to fix KABI changes.

Signed-off-by: default avatarZiyang Xuan <william.xuanziyang@huawei.com>
Reviewed-by: default avatarYue Haibing <yuehaibing@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parent 512fcae2
Loading
Loading
Loading
Loading
+4 −14
Original line number Diff line number Diff line
@@ -15,11 +15,12 @@

#include <net/inet_sock.h>
#include <net/protocol.h>
#include <net/raw_common.h>
#include <linux/icmp.h>

extern struct proto raw_prot;

extern struct raw_hashinfo raw_v4_hashinfo;
extern struct raw_hashinfo_new raw_v4_hashinfo;
bool raw_v4_match(struct net *net, struct sock *sk, unsigned short num,
		  __be32 raddr, __be32 laddr, int dif, int sdif);

@@ -29,22 +30,11 @@ int raw_local_deliver(struct sk_buff *, int);

int raw_rcv(struct sock *, struct sk_buff *);

#define RAW_HTABLE_SIZE	MAX_INET_PROTOS

struct raw_hashinfo {
	spinlock_t lock;
	struct hlist_nulls_head ht[RAW_HTABLE_SIZE];
	rwlock_t lock;
	struct hlist_head ht[RAW_HTABLE_SIZE];
};

static inline void raw_hashinfo_init(struct raw_hashinfo *hashinfo)
{
	int i;

	spin_lock_init(&hashinfo->lock);
	for (i = 0; i < RAW_HTABLE_SIZE; i++)
		INIT_HLIST_NULLS_HEAD(&hashinfo->ht[i], i);
}

#ifdef CONFIG_PROC_FS
int raw_proc_init(void);
void raw_proc_exit(void);
+22 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-or-later */

#ifndef _RAW_COMMON_H
#define _RAW_COMMON_H

#define RAW_HTABLE_SIZE	MAX_INET_PROTOS

struct raw_hashinfo_new {
	spinlock_t lock;
	struct hlist_nulls_head ht[RAW_HTABLE_SIZE];
};

static inline void raw_hashinfo_init(struct raw_hashinfo_new *hashinfo)
{
	int i;

	spin_lock_init(&hashinfo->lock);
	for (i = 0; i < RAW_HTABLE_SIZE; i++)
		INIT_HLIST_NULLS_HEAD(&hashinfo->ht[i], i);
}

#endif	/* _RAW_COMMON_H */
+1 −2
Original line number Diff line number Diff line
@@ -3,9 +3,8 @@
#define _NET_RAWV6_H

#include <net/protocol.h>
#include <net/raw.h>

extern struct raw_hashinfo raw_v6_hashinfo;
extern struct raw_hashinfo_new raw_v6_hashinfo;
bool raw_v6_match(struct net *net, struct sock *sk, unsigned short num,
		  const struct in6_addr *loc_addr,
		  const struct in6_addr *rmt_addr, int dif, int sdif);
+3 −1
Original line number Diff line number Diff line
@@ -1155,6 +1155,7 @@ struct request_sock_ops;
struct timewait_sock_ops;
struct inet_hashinfo;
struct raw_hashinfo;
struct raw_hashinfo_new;
struct smc_hashinfo;
struct module;

@@ -1269,7 +1270,8 @@ struct proto {
	union {
		struct inet_hashinfo	*hashinfo;
		struct udp_table	*udp_table;
		struct raw_hashinfo	*raw_hash;
		KABI_REPLACE(struct raw_hashinfo *raw_hash,
			     struct raw_hashinfo_new *raw_hash)
		struct smc_hashinfo	*smc_hash;
	} h;

+4 −4
Original line number Diff line number Diff line
@@ -85,12 +85,12 @@ struct raw_frag_vec {
	int hlen;
};

struct raw_hashinfo raw_v4_hashinfo;
struct raw_hashinfo_new raw_v4_hashinfo;
EXPORT_SYMBOL_GPL(raw_v4_hashinfo);

int raw_hash_sk(struct sock *sk)
{
	struct raw_hashinfo *h = sk->sk_prot->h.raw_hash;
	struct raw_hashinfo_new *h = sk->sk_prot->h.raw_hash;
	struct hlist_nulls_head *hlist;

	hlist = &h->ht[inet_sk(sk)->inet_num & (RAW_HTABLE_SIZE - 1)];
@@ -107,7 +107,7 @@ EXPORT_SYMBOL_GPL(raw_hash_sk);

void raw_unhash_sk(struct sock *sk)
{
	struct raw_hashinfo *h = sk->sk_prot->h.raw_hash;
	struct raw_hashinfo_new *h = sk->sk_prot->h.raw_hash;

	spin_lock(&h->lock);
	if (__sk_nulls_del_node_init_rcu(sk))
@@ -944,7 +944,7 @@ struct proto raw_prot = {
#ifdef CONFIG_PROC_FS
static struct sock *raw_get_first(struct seq_file *seq, int bucket)
{
	struct raw_hashinfo *h = PDE_DATA(file_inode(seq->file));
	struct raw_hashinfo_new *h = PDE_DATA(file_inode(seq->file));
	struct raw_iter_state *state = raw_seq_private(seq);
	struct hlist_nulls_head *hlist;
	struct hlist_nulls_node *hnode;
Loading