Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753462AbeAJVPU (ORCPT + 1 other); Wed, 10 Jan 2018 16:15:20 -0500 Received: from mail-ua0-f195.google.com ([209.85.217.195]:38367 "EHLO mail-ua0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752276AbeAJVPQ (ORCPT ); Wed, 10 Jan 2018 16:15:16 -0500 X-Google-Smtp-Source: ACJfBovVLi/jntGsAl6hl7yALlyDL4DkALj5OMFcr6mudpYYI1s/kUryVPuwSeKzC8gh1BYQkllqNYaHg7BnhP9rcmw= MIME-Version: 1.0 In-Reply-To: References: <1515531365-37423-1-git-send-email-keescook@chromium.org> <1515531365-37423-3-git-send-email-keescook@chromium.org> From: Kees Cook Date: Wed, 10 Jan 2018 13:15:14 -0800 X-Google-Sender-Auth: b0LBttzMfFaZUyePTkCz0juMjq8 Message-ID: Subject: Re: [PATCH 02/36] usercopy: Include offset in overflow report To: Christopher Lameter Cc: LKML , Linus Torvalds , David Windsor , Alexander Viro , Andrew Morton , Andy Lutomirski , Christoph Hellwig , "David S. Miller" , Laura Abbott , Mark Rutland , "Martin K. Petersen" , Paolo Bonzini , Christian Borntraeger , Christoffer Dall , Dave Kleikamp , Jan Kara , Luis de Bethencourt , Marc Zyngier , Rik van Riel , Matthew Garrett , "linux-fsdevel@vger.kernel.org" , linux-arch , Network Development , Linux-MM , kernel-hardening@lists.openwall.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Wed, Jan 10, 2018 at 7:25 AM, Christopher Lameter wrote: > On Tue, 9 Jan 2018, Kees Cook wrote: > >> -static void report_usercopy(unsigned long len, bool to_user, const char *type) >> +int report_usercopy(const char *name, const char *detail, bool to_user, >> + unsigned long offset, unsigned long len) >> { >> - pr_emerg("kernel memory %s attempt detected %s '%s' (%lu bytes)\n", >> + pr_emerg("kernel memory %s attempt detected %s %s%s%s%s (offset %lu, size %lu)\n", >> to_user ? "exposure" : "overwrite", >> - to_user ? "from" : "to", type ? : "unknown", len); >> + to_user ? "from" : "to", >> + name ? : "unknown?!", >> + detail ? " '" : "", detail ? : "", detail ? "'" : "", >> + offset, len); >> /* >> * For greater effect, it would be nice to do do_group_exit(), >> * but BUG() actually hooks all the lock-breaking and per-arch >> * Oops code, so that is used here instead. >> */ >> BUG(); > > Should this be a WARN() or so? Or some configuration that changes > BUG() behavior? Otherwise This BUG() is the existing behavior, with the new behavior taking the WARN() route in a following patch. >> + >> + return -1; > > This return code will never be returned. > > Why a return code at all? Maybe I will see that in the following patches? I was trying to simplify the callers, but I agree, the result is rather ugly. I'll see if I can fix this up. -Kees -- Kees Cook Pixel Security