Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp441626ybk; Wed, 13 May 2020 04:18:24 -0700 (PDT) X-Google-Smtp-Source: APiQypIIO1uSiiQ6gA8rMAGTl9MnU2HISTK7ZjV6aDKbj9iQ7GaLxL1tAZe34DSrvaOZLISLTxsj X-Received: by 2002:a17:907:9481:: with SMTP id dm1mr22756323ejc.268.1589368704777; Wed, 13 May 2020 04:18:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589368704; cv=none; d=google.com; s=arc-20160816; b=vzbVu7RqeZpCiOtG4DQlj2EklJvGkx1NWq3Fh9CbNsUvyHsfyZUSuM/ruh7lVcZ2gm uVEmoNE7mJATmSoaSVbSmNd2emAFr07zMegv3P29o0pmPy+aPXCffx0hkey/o2tdxrJ+ XBwWoKAU7RbscFrokZL+dT2sN0XYTqz6WiS4sqGeWuRy9JnI5wUKkuWgQp54udoDmmYf +RqAHQ7vdT/muSeMBhZwAtyDFTfTa0EdQBe9LrCi8glKzrAzVUhgMTR+4wv/leHKtKDH g0EGz6h5YwxuL3IQeKNdGU91QuOvrBgROmj1yOZUcIQpaHk42Y5MvRGdFV2Ls32DtfyU UjFQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=js3QmghThxT3OZOyDJjxEKyTRqqHV4ztjMNsc/GDK+4=; b=pA/MTxj6mKGgDQRdI/ai3Tf6+PIftaVPpS7zXGLDFIaMdwltWkkAePD+qipRjKB7ly gU8qjREp21UVCj9cTFxeKFU65l2x9q96FwAqdoWvkSoMBAM9pp0yZ0XR94jGxUKTb5JM gvjXvLhD0SMRCMJxPzJqGAqeZ6lixT/LYC47AHbUVKmThZjXWKwdNvynbbOgRq88XacO IOVCchlVfq1AQYDFH2OCmtgiF3llVuX9qOUagJUWkX/cpgPlQ/KFWY+/GaL/xFVubxML JO1DNJUuHnHkms1KH6RQjE3v20ofQWyH6/MBHq5h3Tqo3jAlwC7CLn8Gg/f/6oMYyjHA bieQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OLX7GabJ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp5si10827709ejc.344.2020.05.13.04.18.01; Wed, 13 May 2020 04:18:24 -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=OLX7GabJ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733061AbgEMJ4v (ORCPT + 99 others); Wed, 13 May 2020 05:56:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:59680 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732964AbgEMJ4J (ORCPT ); Wed, 13 May 2020 05:56:09 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 01625205ED; Wed, 13 May 2020 09:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589363768; bh=rKeULQkRxUhRHLjybAHWdbegXlR743VjXvWhU6otZ+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OLX7GabJALJe2h+/QeI9rC4H8T48BDQFbGqJUenLsvjSe6sVHqWh/gapmDi8C3Owd 4sI6etYKQnh53calmDUcBB8XnIqd3f3fddVWh0bwS4GtO7TGwFTh0x/avLfqM229gj 7384kdaRBtHtaGJwC3NHdE/LAiFoFBjT67ID3NuI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Florian Westphal , Pablo Neira Ayuso Subject: [PATCH 5.6 108/118] netfilter: nf_osf: avoid passing pointer to local var Date: Wed, 13 May 2020 11:45:27 +0200 Message-Id: <20200513094427.531893899@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200513094417.618129545@linuxfoundation.org> References: <20200513094417.618129545@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann commit c165d57b552aaca607fa5daf3fb524a6efe3c5a3 upstream. gcc-10 points out that a code path exists where a pointer to a stack variable may be passed back to the caller: net/netfilter/nfnetlink_osf.c: In function 'nf_osf_hdr_ctx_init': cc1: warning: function may return address of local variable [-Wreturn-local-addr] net/netfilter/nfnetlink_osf.c:171:16: note: declared here 171 | struct tcphdr _tcph; | ^~~~~ I am not sure whether this can happen in practice, but moving the variable declaration into the callers avoids the problem. Fixes: 31a9c29210e2 ("netfilter: nf_osf: add struct nf_osf_hdr_ctx") Signed-off-by: Arnd Bergmann Reviewed-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nfnetlink_osf.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- a/net/netfilter/nfnetlink_osf.c +++ b/net/netfilter/nfnetlink_osf.c @@ -165,12 +165,12 @@ static bool nf_osf_match_one(const struc static const struct tcphdr *nf_osf_hdr_ctx_init(struct nf_osf_hdr_ctx *ctx, const struct sk_buff *skb, const struct iphdr *ip, - unsigned char *opts) + unsigned char *opts, + struct tcphdr *_tcph) { const struct tcphdr *tcp; - struct tcphdr _tcph; - tcp = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(struct tcphdr), &_tcph); + tcp = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(struct tcphdr), _tcph); if (!tcp) return NULL; @@ -205,10 +205,11 @@ nf_osf_match(const struct sk_buff *skb, int fmatch = FMATCH_WRONG; struct nf_osf_hdr_ctx ctx; const struct tcphdr *tcp; + struct tcphdr _tcph; memset(&ctx, 0, sizeof(ctx)); - tcp = nf_osf_hdr_ctx_init(&ctx, skb, ip, opts); + tcp = nf_osf_hdr_ctx_init(&ctx, skb, ip, opts, &_tcph); if (!tcp) return false; @@ -265,10 +266,11 @@ bool nf_osf_find(const struct sk_buff *s const struct nf_osf_finger *kf; struct nf_osf_hdr_ctx ctx; const struct tcphdr *tcp; + struct tcphdr _tcph; memset(&ctx, 0, sizeof(ctx)); - tcp = nf_osf_hdr_ctx_init(&ctx, skb, ip, opts); + tcp = nf_osf_hdr_ctx_init(&ctx, skb, ip, opts, &_tcph); if (!tcp) return false;