mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Arnd Bergmann' <arnd@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>
Cc: "Arnd Bergmann" <arnd@arndb.de>,
	"Martin KaFai Lau" <kafai@fb.com>,
	"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"KP Singh" <kpsingh@chromium.org>,
	"David Miller" <davem@davemloft.net>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Jakub Sitnicki" <jakub@cloudflare.com>,
	"Björn Töpel" <bjorn.topel@intel.com>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"Pankaj Bharadiya" <pankaj.laxminarayan.bharadiya@intel.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] bpf: suppress -Wcast-function-type warning
Date: Mon, 26 Oct 2020 22:20:27 +0000	[thread overview]
Message-ID: <0f6785599a2f4903bd65c5e498b9a197@AcuMS.aculab.com> (raw)
In-Reply-To: <20201026210332.3885166-1-arnd@kernel.org>

From: Arnd Bergmann
> Sent: 26 October 2020 21:03
> 
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Building with -Wextra shows lots of warnings in the bpf
> code such as
> 
> kernel/bpf/verifier.c: In function ‘jit_subprogs’:
> include/linux/filter.h:345:4: warning: cast between incompatible function types from ‘unsigned int
> (*)(const void *, const struct bpf_insn *)’ to ‘u64 (*)(u64,  u64,  u64,  u64,  u64)’ {aka ‘long long
> unsigned int (*)(long long unsigned int,  long long unsigned int,  long long unsigned int,  long long
> unsigned int,  long long unsigned int)’} [-Wcast-function-type]
>   345 |   ((u64 (*)(u64, u64, u64, u64, u64))(x))
>       |    ^
> kernel/bpf/verifier.c:10706:16: note: in expansion of macro ‘BPF_CAST_CALL’
> 10706 |    insn->imm = BPF_CAST_CALL(func[subprog]->bpf_func) -
>       |                ^~~~~~~~~~~~~
> 
> This appears to be intentional, so change the cast in a way that
> suppresses the warning.

It is also utterly horrid.
If the value is ever cast back then there is a lot of scope
for it going badly wrong somewhere.
It certainly isn't valid to use the target type to call the original function.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply	other threads:[~2020-10-26 22:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26 21:03 Arnd Bergmann
2020-10-26 22:20 ` David Laight [this message]
2020-10-26 22:26 ` Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0f6785599a2f4903bd65c5e498b9a197@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=andrii@kernel.org \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=jakub@cloudflare.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pankaj.laxminarayan.bharadiya@intel.com \
    --cc=songliubraving@fb.com \
    --cc=tglx@linutronix.de \
    --cc=toke@redhat.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®