Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp937269ybz; Wed, 29 Apr 2020 12:03:58 -0700 (PDT) X-Google-Smtp-Source: APiQypIQPC/gl/Oer442E5znq1Wuc5A9EZ7xa65tJxh9mqMAqL2mQ/jc6EWFbR1Ws6Y5GLj4yngG X-Received: by 2002:aa7:cc92:: with SMTP id p18mr3846890edt.166.1588187037959; Wed, 29 Apr 2020 12:03:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588187037; cv=none; d=google.com; s=arc-20160816; b=zGq+HEx8Yo9LtQ1jB5J0QinEI+JOUWhBfExoA1i2o8H9jGd39+mckUTwRHF35+ASbD 1wd4IDNe7L6ad0O0Su8JEdrJbDTXEgsyBi+O61PB2yNwje1vCgsVAyB4gAhWIkY1m6de IiVaBW6EhfFLRvrObqTpLMIAG5IHvlpGhlt9xO8JBKgaxtnITI6Rc7ODhH2lsaw23vg4 1UBhsjIZ2LHWT0LUs9UdYZ6m52IiqldTgv+pog2O/WEFkQ4baffn3zlg36OhbNd+S//x 0InLwzQmJA4ZiQakkbZtmKYz6nIN/EGQCYFVBaSOlI6SmUB0i8pQaX9+x64yw/hHW8US E5ow== 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 :message-id:date:subject:cc:to:from; bh=He4HLuqQjGFODyBS/ddu8TggR04Iqub/LdqaU98hVH8=; b=YnaYOYCSxvSc/+lukzjCuNSBk/8mg1N89+umDwvclP25NY7IfzWnM7TstUYSlHdG59 epPJbAkrEL4HQkPkfzmwzge1ajfxrLr+OmRhsSPvoI21ZlNjdu8wm8M3E+yOEQNPDV5z 70y/OkV8kwQaxUXQRXBQ4SJAh+WAvGZNF7P/Xsy55XIo207dT9ENsm+ZSyR7ZuGBMr+f NmGMV3ooWkV/dye/FNdjDH2YGY6A+jeQVAiTaoQikUe8YOK+idB0Z+QYlWAu7b4qKPiw 98/1DmMNFjAo1bqi7P5R3hkvp63ZkEBhIASFbhBu6EYwaZkTEIbff6l7vDlH5Pa+2EM4 M/tQ== ARC-Authentication-Results: i=1; mx.google.com; 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 df22si4317274edb.272.2020.04.29.12.03.33; Wed, 29 Apr 2020 12:03:57 -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; 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 S1727832AbgD2TBP (ORCPT + 99 others); Wed, 29 Apr 2020 15:01:15 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:55811 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726774AbgD2TBO (ORCPT ); Wed, 29 Apr 2020 15:01:14 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.145]) with ESMTPA (Nemesis) id 1MsZif-1jA82b1Dq7-00tyVc; Wed, 29 Apr 2020 21:00:58 +0200 From: Arnd Bergmann To: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" , Jakub Kicinski Cc: Arnd Bergmann , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] netfilter: nf_osf: avoid passing pointer to local var Date: Wed, 29 Apr 2020 21:00:41 +0200 Message-Id: <20200429190051.27993-1-arnd@arndb.de> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID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nmczVHvZy57zdyfq8TzJCILJcXLEm8YhGgVbuk9WKX8NR U/1+KjsU9R7euiyBM8zym9MwFOMIeVqYo2hdcWDO0IiyWyJeKg= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- net/netfilter/nfnetlink_osf.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/net/netfilter/nfnetlink_osf.c b/net/netfilter/nfnetlink_osf.c index 9f5dea0064ea..916a3c7f9eaf 100644 --- a/net/netfilter/nfnetlink_osf.c +++ b/net/netfilter/nfnetlink_osf.c @@ -165,12 +165,12 @@ static bool nf_osf_match_one(const struct sk_buff *skb, 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, u_int8_t family, 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 *skb, 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; -- 2.26.0