mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Kees Cook <keescook@chromium.org>,
	Josh Triplett <josh@joshtriplett.org>,
	Alexei Starovoitov <ast@kernel.org>,
	linux-kernel@vger.kernel.org, NeilBrown <neilb@suse.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Ingo Molnar <mingo@kernel.org>, Crt Mori <cmo@melexis.com>,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCH v4 1/3] kernel.h: disable type-checks in container_of() for Sparse
Date: Wed, 21 Nov 2018 19:25:07 -0800	[thread overview]
Message-ID: <20181121192507.5199cf95fd2da9573a18ca80@linux-foundation.org> (raw)
In-Reply-To: <1542856462-18836-1-git-send-email-yamada.masahiro@socionext.com>

On Thu, 22 Nov 2018 12:14:20 +0900 Masahiro Yamada <yamada.masahiro@socionext.com> wrote:

> When I tried to enable BUILD_BUG_ON for Sparse, the kbuild test robot
> reported lots of "unknown expression" warnings from container_of(),
> which seemed false positive.
> 
> I addressed this in [1], but fixing Sparse is the right thing to do.
> 
> The issue was fixed by Sparse commit 0eb8175d3e9c ("fix expansion of
> function designator"), but it will take time until the fixed version
> of Sparse is widely available.
> 
> Disable the container_of() type checks for Sparse for now.
> 
> [1] https://lore.kernel.org/lkml/1542623503-3755-1-git-send-email-yamada.masahiro@socionext.com/
> 
> ...
>
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -985,6 +985,21 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
>  #define __CONCAT(a, b) a ## b
>  #define CONCATENATE(a, b) __CONCAT(a, b)
>  
> +/*
> + * TODO:
> + * Sparse emits "unknown expression" warnings.
> + * It was fixed by commit 0eb8175d3e9c0d20354763d07ce3d4c0e543d988 in Sparse.
> + * Remove the following workaround when the fixed Sparse is widely available.
> + */
> +#ifdef __CHECKER__
> +#define TYPE_CHECK_CONTAINER_OF(ptr, type, member)	do {} while (0)
> +#else
> +#define TYPE_CHECK_CONTAINER_OF(ptr, type, member) \
> +	BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&	\
> +			 !__same_type(*(ptr), void),			\
> +			 "pointer type mismatch in container_of()")
> +#endif

I think that's OK.  A few years hence, someone will happen upon this
comment and will perform the obvious cleanup.


  parent reply	other threads:[~2018-11-22  3:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-22  3:14 Masahiro Yamada
2018-11-22  3:14 ` [PATCH v4 2/3] build_bug.h: remove negative-array fallback for BUILD_BUG_ON() Masahiro Yamada
2018-11-24  8:16   ` Miguel Ojeda
2018-11-22  3:14 ` [PATCH v4 3/3] build_bug.h: remove most of dummy BUILD_BUG_ON stubs for Sparse Masahiro Yamada
2018-11-24  8:29   ` Miguel Ojeda
2018-11-22  3:25 ` Andrew Morton [this message]
2018-11-22 14:32 ` [PATCH v4 1/3] kernel.h: disable type-checks in container_of() " Luc Van Oostenryck
2018-11-24  8:24   ` Miguel Ojeda
2018-11-25 13:56     ` Masahiro Yamada
2018-12-01  3:34     ` Masahiro Yamada

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=20181121192507.5199cf95fd2da9573a18ca80@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=ast@kernel.org \
    --cc=cmo@melexis.com \
    --cc=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=josh@joshtriplett.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=mingo@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=neilb@suse.com \
    --cc=yamada.masahiro@socionext.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®