From: Sebastian Ott <sebott@linux.ibm.com>
To: Kees Cook <keescook@chromium.org>
Cc: Sebastian Ott <sebott@linux.vnet.ibm.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
Martin Uecker <Martin.Uecker@med.uni-goettingen.de>,
Ingo Molnar <mingo@kernel.org>,
Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Subject: Re: [bisected] 3c8ba0d61d04ced9f8d9ff93977995a9e4e96e91 oopses on s390
Date: Mon, 9 Apr 2018 19:00:36 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.21.1804091854290.1698@schleppi> (raw)
In-Reply-To: <alpine.LFD.2.21.1804091809310.1698@schleppi>
[-- Attachment #1: Type: text/plain, Size: 1214 bytes --]
On Mon, 9 Apr 2018, Sebastian Ott wrote:
> On Fri, 6 Apr 2018, Kees Cook wrote:
> > On Fri, Apr 6, 2018 at 2:47 AM, Sebastian Ott <sebott@linux.vnet.ibm.com> wrote:
> > > Today's kernel oopsed on s390. Bisect points to:
> > > 3c8ba0d61d04 ("kernel.h: Retain constant expression output for max()/min()")
> > >
> > > [ 1.898277] dasd-eckd 0.0.3304: DASD with 4 KB/block, 21636720 KB total size, 48 KB/track, compatible disk layout
> > > [ 1.898308] ------------[ cut here ]------------
> > > [ 1.898310] kernel BUG at block/bio.c:1798!
> >
> > Well that's extremely bad. :(
>
> What happened is that the bio build by the partition detection code was
> attempted to be split by the block layer because the block queue had a
> max_sector setting of 0. blk_queue_max_hw_sectors uses min_not_zero.
>
> Both of the following return 0 on my machine:
> + pr_warn("%u\n", min_not_zero(100, 1000));
> + pr_warn("%u\n", min_not_zero(1000, 100));
>
> So, we now know what failed...the question is why?
I copied these macros to a userspace program to easily test it on other
machines/compilers. ....maybe I did something wrong but min_not_zero did
not work - even on fedora on an x86 laptop.
Sebastian
[-- Attachment #2: Type: text/plain, Size: 1184 bytes --]
#include <stdio.h>
#define __typecheck(x, y) \
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
#define __is_constexpr(x) \
(sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
#define __no_side_effects(x, y) \
(__is_constexpr(x) && __is_constexpr(y))
#define __safe_cmp(x, y) \
(__typecheck(x, y) && __no_side_effects(x, y))
#define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
#define __cmp_once(x, y, op) ({ \
typeof(x) __x = (x); \
typeof(y) __y = (y); \
__cmp(__x, __y, op); })
#define __careful_cmp(x, y, op) \
__builtin_choose_expr(__safe_cmp(x, y), \
__cmp(x, y, op), __cmp_once(x, y, op))
#define min(x, y) __careful_cmp(x, y, <)
#define max(x, y) __careful_cmp(x, y, >)
#define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <)
#define max_t(type, x, y) __careful_cmp((type)(x), (type)(y), >)
#define min_not_zero(x, y) ({ \
typeof(x) __x = (x); \
typeof(y) __y = (y); \
__x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
int main()
{
printf("test %u\n", min_not_zero(100, 1000));
return 0;
}
next prev parent reply other threads:[~2018-04-09 17:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-06 9:47 [bisected] 3c8ba0d61d04ced9f8d9ff93977995a9e4e96e91 oopses on s390 Sebastian Ott
2018-04-06 16:47 ` Kees Cook
2018-04-06 18:02 ` Kees Cook
2018-04-06 18:10 ` Sebastian Ott
2018-04-09 16:18 ` Sebastian Ott
2018-04-09 17:00 ` Sebastian Ott [this message]
2018-04-09 17:03 ` Linus Torvalds
2018-04-09 17:11 ` Sebastian Ott
2018-04-09 17:15 ` Linus Torvalds
2018-04-09 17:14 ` Linus Torvalds
2018-04-09 17:27 ` Sebastian Ott
2018-04-09 17:32 ` Linus Torvalds
2018-04-09 18:00 ` Kees Cook
2018-04-09 18:17 ` Linus Torvalds
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=alpine.LFD.2.21.1804091854290.1698@schleppi \
--to=sebott@linux.ibm.com \
--cc=Martin.Uecker@med.uni-goettingen.de \
--cc=heiko.carstens@de.ibm.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=mingo@kernel.org \
--cc=sebott@linux.vnet.ibm.com \
--cc=torvalds@linux-foundation.org \
/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