Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp120487ybk; Fri, 8 May 2020 20:54:38 -0700 (PDT) X-Google-Smtp-Source: APiQypJCvy17Nqvpv5mPzYjXWJfczWzQ7w8o5YLl4YVmjwuzURoPG9hye9ME0ncCVdnVG6+lF7ay X-Received: by 2002:a05:6402:22d9:: with SMTP id dm25mr1644742edb.380.1588996478051; Fri, 08 May 2020 20:54:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588996478; cv=none; d=google.com; s=arc-20160816; b=LDOsFbvQisNelcCyBMJYr7FHA14F1tAwFDtQhbRtb/xRTt1uTSXZtafyxB11JRq73C D3Ylp31CYvP0NKvq5xmyC3ZVvLbi6+Pa8tgr34+hoZAuNrCEPa5oLhKoOZlDH5NSO8hC Qs2XIlcXM2Fw2a71HDVKzObs5JZCn86mENmA6r23AV9/ZrGtZXW+i4KhLgtzQqmmH31t HM7kXEDm1+XPwsoRNPRBfF4Og0ATKy9Y//WszdB/vg63tqXNFNOEwOKf0O3tsRcGgZtN EakHWK6JmRPh4n5bivgl4z1qqlSKwcqQuajC2tPoP2JTd+vRsaTXLXzrs7FBdHJcF6Ce D+Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=0qeqc7jhb6XO/tXfUg7chOifJJK3I6SBatxTbvTEfzM=; b=RBy6S1OiSoWMq2c5eEBbThW7Ao3E8j3aujs/TiKu9B3ALyg7a0UCZwHHV09lN4iM74 zr9MmgV4z4v7sFN4GvuVe/4VkpMizHyDlGL/46cKIpnGjziQQkHP5y/Yfo5A/SotJSgu OehtQ2yPkED2LX9hOBBw2NSgx9xPoDTdyicnobos4dP6RQVFMvf4+EYURbxnbLWzeBko MictLdyT5lkY+0NJ5570AgUciJxmpHufsnsyI4lKeJJI3SmJsTxyHtfTgJGlbXVaAzTM /uDv3NAz75fGKLzrJbTpHo2BfQL9ZFGpmvMbVubtrCp52L6yx/kH1Whs2uRpjeDHIjq2 0RYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=v+NOZ9ih; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ss10si2154553ejb.103.2020.05.08.20.54.15; Fri, 08 May 2020 20:54:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=v+NOZ9ih; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728765AbgEIDu2 (ORCPT + 99 others); Fri, 8 May 2020 23:50:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:42172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726415AbgEIDu2 (ORCPT ); Fri, 8 May 2020 23:50:28 -0400 Received: from kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com (unknown [163.114.132.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 112AF20722; Sat, 9 May 2020 03:50:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588996227; bh=XcyjVYykYKddPdKIWQPw8Qg8eEX39q7s1fcySboBfXw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=v+NOZ9ihS91D0GxdpfKFJeEKdSr3cMUz5sMum2mQtJ7ZDtDW/DEN19kUpISGgJ0XS cuTQqwZuNX6c+To2TPjtHxABkyGArm+PA3b5EHotmBBAigvinDiYxDkiBxFLBqPJAM wdKOdjwEJ2U4dA8pie5kE537dnD042DOnLQnGTmM= Date: Fri, 8 May 2020 20:50:25 -0700 From: Jakub Kicinski To: Stephen Kitt Cc: "David S . Miller" , Joe Perches , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] net: Protect INET_ADDR_COOKIE on 32-bit architectures Message-ID: <20200508205025.3207a54e@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20200508120457.29422-1-steve@sk2.org> References: <20200508120457.29422-1-steve@sk2.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 8 May 2020 14:04:57 +0200 Stephen Kitt wrote: > Commit c7228317441f ("net: Use a more standard macro for > INET_ADDR_COOKIE") added a __deprecated marker to the cookie name on > 32-bit architectures, with the intent that the compiler would flag > uses of the name. However since commit 771c035372a0 ("deprecate the > '__deprecated' attribute warnings entirely and for good"), > __deprecated doesn't do anything and should be avoided. > > This patch changes INET_ADDR_COOKIE to declare a dummy struct so that > any subsequent use of the cookie's name will in all likelihood break > the build. It also removes the __deprecated marker. > > Signed-off-by: Stephen Kitt > --- > Changes since v1: > - use a dummy struct rather than a typedef > > include/net/inet_hashtables.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h > index ad64ba6a057f..889d9b00c905 100644 > --- a/include/net/inet_hashtables.h > +++ b/include/net/inet_hashtables.h > @@ -301,8 +301,9 @@ static inline struct sock *inet_lookup_listener(struct net *net, > ((__sk)->sk_bound_dev_if == (__sdif))) && \ > net_eq(sock_net(__sk), (__net))) > #else /* 32-bit arch */ > +/* Break the build if anything tries to use the cookie's name. */ I think the macro is supposed to cause a warning when the variable itself is accessed. And I don't think that happens with your patch applied. diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index 2bbaaf0c7176..6c4a3904ed8b 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -360,6 +360,8 @@ struct sock *__inet_lookup_established(struct net *net, unsigned int slot = hash & hashinfo->ehash_mask; struct inet_ehash_bucket *head = &hashinfo->ehash[slot]; + kfree(&acookie); begin: sk_nulls_for_each_rcu(sk, node, &head->chain) { if (sk->sk_hash != hash) $ make ARCH=i386 make[1]: Entering directory `/netdev/net-next/build_allmodconfig_warn_32bit' GEN Makefile CALL ../scripts/atomic/check-atomics.sh CALL ../scripts/checksyscalls.sh CHK include/generated/compile.h CC net/ipv4/inet_hashtables.o CHK kernel/kheaders_data.tar.xz AR net/ipv4/built-in.a AR net/built-in.a GEN .version CHK include/generated/compile.h UPD include/generated/compile.h CC init/version.o AR init/built-in.a LD vmlinux.o MODPOST vmlinux.o Builds fine. > #define INET_ADDR_COOKIE(__name, __saddr, __daddr) \ > - const int __name __deprecated __attribute__((unused)) > + struct {} __name __attribute__((unused)) > > #define INET_MATCH(__sk, __net, __cookie, __saddr, __daddr, __ports, __dif, __sdif) \ > (((__sk)->sk_portpair == (__ports)) && \