Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751598AbdGZRKf (ORCPT ); Wed, 26 Jul 2017 13:10:35 -0400 Received: from mail-oi0-f50.google.com ([209.85.218.50]:36007 "EHLO mail-oi0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751450AbdGZRKe (ORCPT ); Wed, 26 Jul 2017 13:10:34 -0400 MIME-Version: 1.0 In-Reply-To: <20170726035036.GA76341@beast> References: <20170726035036.GA76341@beast> From: Linus Torvalds Date: Wed, 26 Jul 2017 10:10:33 -0700 X-Google-Sender-Auth: IDzH3e4NnTGmZ-lBJTdECRRDmJ8 Message-ID: Subject: Re: [PATCH] fortify: Use WARN instead of BUG for now To: Kees Cook Cc: Andrew Morton , Daniel Micay , Dan Williams , Mika Westerberg , Al Viro , David Howells , Heikki Krogerus , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman , Mauro Carvalho Chehab , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 883 Lines: 29 On Tue, Jul 25, 2017 at 8:50 PM, Kees Cook wrote: > + > +void fortify_read_overflow(const char *func) > { > - pr_emerg("detected buffer overflow in %s\n", name); > - BUG(); > + WARN(1, "detected read beyond size of object passed as 1st parameter in %s\n", func); > } Side note: have you actually checked the code generation of this all? In particular, do you have any reason to use the out-of-line functions? Our WARN() code isn't horrible, and isn't likely to be noticeably worse than your own explicit out-of-lining. And you'd get the "unlikely()" for free, so you'll possibly get smaller code that runs better too. And it would even *look* better. This: if (p_size < size) fortify_read_overflow(__func__); would become WARN(p_size < size, "kmemdup size overflow"); or something. Linus