From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8A3AC433DB for ; Tue, 19 Jan 2021 20:18:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 587D723107 for ; Tue, 19 Jan 2021 20:18:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 587D723107 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EC4886B0006; Tue, 19 Jan 2021 15:18:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E75126B0007; Tue, 19 Jan 2021 15:18:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB2F66B0008; Tue, 19 Jan 2021 15:18:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0074.hostedemail.com [216.40.44.74]) by kanga.kvack.org (Postfix) with ESMTP id C52636B0006 for ; Tue, 19 Jan 2021 15:18:35 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 9013A8249980 for ; Tue, 19 Jan 2021 20:18:35 +0000 (UTC) X-FDA: 77723637390.30.rings59_020b06027554 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id 57FD1180B3C8E for ; Tue, 19 Jan 2021 20:18:35 +0000 (UTC) X-HE-Tag: rings59_020b06027554 X-Filterd-Recvd-Size: 4011 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Tue, 19 Jan 2021 20:18:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description; bh=9BB3e4UOa89CNZRt/E7K2g+oaXMqtqe9Q/oLhFogx1k=; b=Azet/fAOXpIaVhDt6xN2dW+n2b NqMosDlyUbMALkIWccg5H4tO1SDLbdeyIVM5AdM9OtPzmvA3XePUeKGzWrepgk/tmv+aGF6znJZ9D 36XmkLRTjQHdPIX40wi3+39a8WSp643iUpwqH3Svd7MP/wyEQuOuIxDazdaaotTjyW/xMQA1dtxrD 3svt36BGHaPhChAjiiKrS91usls3C1NkhsPGWa3KbUtNc6ouevTCrcw2ZG9uZkr6EyUNAYtaAPquY PerdJlcTffwEAcnLExsPPh+5o1yGOehI5i65UQSspDcSqZiAPQ/8u0HeDGOrSb/CE/p7xz7QxqCtD gIav+2Lg==; Received: from [2601:1c0:6280:3f0::9abc] by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1l1xSK-0007gM-Vw; Tue, 19 Jan 2021 20:18:25 +0000 Subject: Re: [PATCH 0/2] introduce DUMP_PREFIX_UNHASHED for hex dumps To: Kees Cook , Matthew Wilcox Cc: Sergey Senozhatsky , Timur Tabi , Andrew Morton , linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, Petr Mladek , roman.fietze@magna.com, Steven Rostedt , John Ogness , linux-mm@kvack.org, Akinobu Mita References: <20210116220950.47078-1-timur@kernel.org> <20210118182635.GD2260413@casper.infradead.org> <20210119014725.GH2260413@casper.infradead.org> <202101191135.A78A570@keescook> From: Randy Dunlap Message-ID: <82e1f2f3-77c3-ffb4-34b2-0e6f23e6195d@infradead.org> Date: Tue, 19 Jan 2021 12:18:17 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <202101191135.A78A570@keescook> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 1/19/21 11:45 AM, Kees Cook wrote: > > How about this so the base address is hashed once, with the offset added > to it for each line instead of each line having a "new" hash that makes > no sense: Yes, good patch. Should have been like this to begin with IMO. > diff --git a/lib/hexdump.c b/lib/hexdump.c > index 9301578f98e8..20264828752d 100644 > --- a/lib/hexdump.c > +++ b/lib/hexdump.c > @@ -242,12 +242,17 @@ void print_hex_dump(const char *level, const char *prefix_str, int prefix_type, > const void *buf, size_t len, bool ascii) > { > const u8 *ptr = buf; > + const u8 *addr; > int i, linelen, remaining = len; > unsigned char linebuf[32 * 3 + 2 + 32 + 1]; > > if (rowsize != 16 && rowsize != 32) > rowsize = 16; > > + if (prefix_type == DUMP_PREFIX_ADDRESS && > + ptr_to_hashval(ptr, &addr)) > + addr = 0; > + > for (i = 0; i < len; i += rowsize) { > linelen = min(remaining, rowsize); > remaining -= rowsize; > @@ -258,7 +263,7 @@ void print_hex_dump(const char *level, const char *prefix_str, int prefix_type, > switch (prefix_type) { > case DUMP_PREFIX_ADDRESS: > printk("%s%s%p: %s\n", > - level, prefix_str, ptr + i, linebuf); > + level, prefix_str, addr + i, linebuf); Is 'addr' always set here? It is only conditionally set above. > break; > case DUMP_PREFIX_OFFSET: > printk("%s%s%.8x: %s\n", level, prefix_str, i, linebuf); > > -Kees > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#p-format-specifier > -- ~Randy "He closes his eyes and drops the goggles. You can't get hurt by looking at a bitmap. Or can you?" (Neal Stephenson: Snow Crash)