Skip to content

Commit 77d4b1d

Browse files
edumazetdavem330
authored andcommitted
net: ping: do not abuse udp_poll()
Alexander reported various KASAN messages triggered in recent kernels The problem is that ping sockets should not use udp_poll() in the first place, and recent changes in UDP stack finally exposed this old bug. Fixes: c319b4d ("net: ipv4: add IPPROTO_ICMP socket kind") Fixes: 6d0bfe2 ("net: ipv6: Add IPv6 support to the ping socket.") Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: Sasha Levin <alexander.levin@verizon.com> Cc: Solar Designer <solar@openwall.com> Cc: Vasiliy Kulikov <segoon@openwall.com> Cc: Lorenzo Colitti <lorenzo@google.com> Acked-By: Lorenzo Colitti <lorenzo@google.com> Tested-By: Lorenzo Colitti <lorenzo@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b07ac98 commit 77d4b1d

4 files changed

Lines changed: 4 additions & 3 deletions

File tree

include/net/ipv6.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,7 @@ int inet6_hash_connect(struct inet_timewait_death_row *death_row,
10071007
*/
10081008
extern const struct proto_ops inet6_stream_ops;
10091009
extern const struct proto_ops inet6_dgram_ops;
1010+
extern const struct proto_ops inet6_sockraw_ops;
10101011

10111012
struct group_source_req;
10121013
struct group_filter;

net/ipv4/af_inet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ static struct inet_protosw inetsw_array[] =
10431043
.type = SOCK_DGRAM,
10441044
.protocol = IPPROTO_ICMP,
10451045
.prot = &ping_prot,
1046-
.ops = &inet_dgram_ops,
1046+
.ops = &inet_sockraw_ops,
10471047
.flags = INET_PROTOSW_REUSE,
10481048
},
10491049

net/ipv6/ping.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static struct inet_protosw pingv6_protosw = {
192192
.type = SOCK_DGRAM,
193193
.protocol = IPPROTO_ICMPV6,
194194
.prot = &pingv6_prot,
195-
.ops = &inet6_dgram_ops,
195+
.ops = &inet6_sockraw_ops,
196196
.flags = INET_PROTOSW_REUSE,
197197
};
198198

net/ipv6/raw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ void raw6_proc_exit(void)
13381338
#endif /* CONFIG_PROC_FS */
13391339

13401340
/* Same as inet6_dgram_ops, sans udp_poll. */
1341-
static const struct proto_ops inet6_sockraw_ops = {
1341+
const struct proto_ops inet6_sockraw_ops = {
13421342
.family = PF_INET6,
13431343
.owner = THIS_MODULE,
13441344
.release = inet6_release,

0 commit comments

Comments
 (0)