From patchwork Sat Jun 3 16:29:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 770806 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3wg64D5lXrz9s7B for ; Sun, 4 Jun 2017 02:29:48 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DW0OLgRU"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751177AbdFCQ3a (ORCPT ); Sat, 3 Jun 2017 12:29:30 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:35451 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750876AbdFCQ33 (ORCPT ); Sat, 3 Jun 2017 12:29:29 -0400 Received: by mail-pg0-f66.google.com with SMTP id f127so5056938pgc.2; Sat, 03 Jun 2017 09:29:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kv0Q+jZkHcAKsPE8w5cHboHf4lkn6BooWGfqxWsrWS0=; b=DW0OLgRUETCQcX0iDMU903cydYZAGNwL4rEXiNYbu1OTbM2HJp7voJMphrVV1GMfTq 3z8RFRdVTtavXh0iDfDhJEnACoyWCc8OYYN05WmDikkBxWI0IHno2vxus0zHPN1mRP5S n7xiGzJxiF2fA7SwrWJum8zNhbHj03h9E160Nvut9TTuaKv0ftdLR1IMU7AQG0RLbrsY TvPEdU8w34z1bgm272fOVNNC38Sz95RcOzLnehd74QkUNiLlja+FP/l3QdxdKJzQ1/VK Nqm4Eu4ximedXVd97QGyO5iXWQo/4/xvAvwdUJabA9G9HRWtvf7ispljIRZEEspxGbi6 cv+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kv0Q+jZkHcAKsPE8w5cHboHf4lkn6BooWGfqxWsrWS0=; b=ZDGADwwZA2rdlUSaRqc1LG7y/5A6oPoy/iLOPsZlTNGmyHAx741YWruL1CdN4kcbLo 2i7V6n/cAg9tG8tzPqaUIUMv6m3ID6nme5Pl6jnGHonXuLxCi/+X0HJmXoXuxNfI94OE wI0KH26Ze5lCIcVIG2BEYl/4/wrhqMLui35js1Xcs3cZwFjpzKYGWjG0AqerzfUQXkm2 aE//9mvEQ5WhxiRCo9IUUpsdeJfX2yIBuh1FVvpNBmhogmp4rTGlsHk7jvAn6Mk3elx9 54MKoy9rwVsXFa2UdFMrIiwNWKkchle9OdsSTCvQwGvBJpaAhRYbWSqrreHWv/hcBwDD gyQg== X-Gm-Message-State: AODbwcDuK68haOhJx+/gq+r0Oo7pjr6ss6yhfCmDIRrtuDdljhzy25cj 4Z600QccsH/laA== X-Received: by 10.99.109.73 with SMTP id i70mr12900407pgc.62.1496507368423; Sat, 03 Jun 2017 09:29:28 -0700 (PDT) Received: from [192.168.86.171] (c-73-231-122-98.hsd1.ca.comcast.net. [73.231.122.98]) by smtp.googlemail.com with ESMTPSA id n2sm2540299pgd.26.2017.06.03.09.29.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Jun 2017 09:29:26 -0700 (PDT) Message-ID: <1496507365.5031.16.camel@edumazet-glaptop3.roam.corp.google.com> Subject: [PATCH net] net: ping: do not abuse udp_poll() From: Eric Dumazet To: Eric Dumazet , David Miller , Lorenzo Colitti , Vasiliy Kulikov , Solar Designer Cc: "Levin, Alexander (Sasha Levin)" , "pabeni@redhat.com" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Date: Sat, 03 Jun 2017 09:29:25 -0700 In-Reply-To: References: <20170603051742.m6jtztnn4b3me2co@sasha-lappy> X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric Dumazet 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: c319b4d76b9e ("net: ipv4: add IPPROTO_ICMP socket kind") Fixes: 6d0bfe226116 ("net: ipv6: Add IPv6 support to the ping socket.") Signed-off-by: Eric Dumazet Reported-by: Sasha Levin Cc: Solar Designer Cc: Vasiliy Kulikov Cc: Lorenzo Colitti Acked-By: Lorenzo Colitti Tested-By: Lorenzo Colitti --- include/net/ipv6.h | 1 + net/ipv4/af_inet.c | 2 +- net/ipv6/ping.c | 2 +- net/ipv6/raw.c | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/net/ipv6.h b/include/net/ipv6.h index dbf0abba33b8da21be05abf6e719f69542da80fc..3e505bbff8ca4a41f8d39fefcd59aa01b85424f4 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -1007,6 +1007,7 @@ int inet6_hash_connect(struct inet_timewait_death_row *death_row, */ extern const struct proto_ops inet6_stream_ops; extern const struct proto_ops inet6_dgram_ops; +extern const struct proto_ops inet6_sockraw_ops; struct group_source_req; struct group_filter; diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index f3dad16613437c0c7ac3e9c7518a0929cddb3ca7..58925b6597de83e7d643fb9b1c7e992c9748ae1c 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1043,7 +1043,7 @@ static struct inet_protosw inetsw_array[] = .type = SOCK_DGRAM, .protocol = IPPROTO_ICMP, .prot = &ping_prot, - .ops = &inet_dgram_ops, + .ops = &inet_sockraw_ops, .flags = INET_PROTOSW_REUSE, }, diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c index 9b522fa90e6d8f4a87ebed7cf574a36ceea89c61..ac826dd338ff0825eaf0d2d74cee92d008e018bb 100644 --- a/net/ipv6/ping.c +++ b/net/ipv6/ping.c @@ -192,7 +192,7 @@ static struct inet_protosw pingv6_protosw = { .type = SOCK_DGRAM, .protocol = IPPROTO_ICMPV6, .prot = &pingv6_prot, - .ops = &inet6_dgram_ops, + .ops = &inet6_sockraw_ops, .flags = INET_PROTOSW_REUSE, }; diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 1f992d9e261d8b75226659a4cead95f8dc04dc4f..60be012fe7085cc7a199e84333cef5ee95ed1f04 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -1338,7 +1338,7 @@ void raw6_proc_exit(void) #endif /* CONFIG_PROC_FS */ /* Same as inet6_dgram_ops, sans udp_poll. */ -static const struct proto_ops inet6_sockraw_ops = { +const struct proto_ops inet6_sockraw_ops = { .family = PF_INET6, .owner = THIS_MODULE, .release = inet6_release,