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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5711BC433F5 for ; Tue, 12 Oct 2021 11:57:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 73C1960D07 for ; Tue, 12 Oct 2021 11:57:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 73C1960D07 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rasmusvillemoes.dk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id EFAEB6B0071; Tue, 12 Oct 2021 07:57:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA9E36B0073; Tue, 12 Oct 2021 07:57:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D71D16B0074; Tue, 12 Oct 2021 07:57:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0155.hostedemail.com [216.40.44.155]) by kanga.kvack.org (Postfix) with ESMTP id C85216B0071 for ; Tue, 12 Oct 2021 07:57:13 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7424518026102 for ; Tue, 12 Oct 2021 11:57:13 +0000 (UTC) X-FDA: 78687634746.11.A4FF3FB Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) by imf03.hostedemail.com (Postfix) with ESMTP id EFC2630000A6 for ; Tue, 12 Oct 2021 11:57:12 +0000 (UTC) Received: by mail-lf1-f48.google.com with SMTP id n8so84235060lfk.6 for ; Tue, 12 Oct 2021 04:57:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=QkUmGHTpb1fajbLdeLTrVEyMJpMBgokqlmIsT/1TKL8=; b=Cw1UUk3JyWy9GbdrAdWPY7AClg5cTSFBQr/4oFOUVEUgtOmi9OHKYCW1nJWa66rfbc 9DyCzx6UJt9oUU2PwuLhJx+HdVF7gZxYMZRPMUgv1upraZqvDcu5Wsd/4okw4KCh8Uky wLNfaginVrTm8zUCxXdidb7D5el8Z4qyfv4rE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QkUmGHTpb1fajbLdeLTrVEyMJpMBgokqlmIsT/1TKL8=; b=nQILttu5NJwtHwb9NCDABDaF8vIbc6pZN+9sB0RnCaQ7AmGPOznrLy8GOsRWU3SD2v IOFneH94a9Wivd6LvUDjryWh9aJYgrOuBF3lwO0F9BJmmPfadG6fbi1TLwT5hyu1Kzc1 DJ/8Ss7vLdg8NU3jRlY35817sBEfnqKmrt7p0+9DOMUgZyJyWD0OqPqecGtDr66au4Yv ci//DAgZMWwXOKAWRB6zhlWy1ZUa/3Z6Fdtx7SNVk+z3qu2OAm6PgdsuNANpZjt0mHAO 4ReWxwqEb4KDnVh4C85hPKyePvDWJ2+FCO8Nhx/qdb7A2KIDrL7EjIPae9ROqT55kyjn Ot0g== X-Gm-Message-State: AOAM531nVBVeds9AGI589YoBrsIY0Mj9lwZU1qeNrQD7c7f/sV2fkGR2 6cVWc8fSL4Ed5xxK5xTR1vemhafE0fGBs0V8 X-Google-Smtp-Source: ABdhPJxRTG4+9gV6qtfNBpCB3G8qW0TFBH6A0wnZntiBWO0pcaniWlKKkGAyJKu0sgEQOsNzRvqMYw== X-Received: by 2002:a05:6512:31c3:: with SMTP id j3mr30105318lfe.217.1634039831062; Tue, 12 Oct 2021 04:57:11 -0700 (PDT) Received: from [172.16.11.1] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id s13sm1074749ljs.23.2021.10.12.04.57.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Oct 2021 04:57:10 -0700 (PDT) Subject: Re: [PATCH] vsprintf: Make %pGp print the hex value To: Matthew Wilcox Cc: linux-mm@kvack.org, Vlastimil Babka References: <20211008193829.849532-1-willy@infradead.org> <1093c8db-5d96-18ff-cb27-e74cddb757a4@rasmusvillemoes.dk> From: Rasmus Villemoes Message-ID: <2b8bd086-f0cc-80ff-b36a-83b49c523482@rasmusvillemoes.dk> Date: Tue, 12 Oct 2021 13:57:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: EFC2630000A6 X-Stat-Signature: 6meodtkjbkedi7nyhzo9omszzo1p1wyw Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=rasmusvillemoes.dk header.s=google header.b=Cw1UUk3J; dmarc=none; spf=pass (imf03.hostedemail.com: domain of linux@rasmusvillemoes.dk designates 209.85.167.48 as permitted sender) smtp.mailfrom=linux@rasmusvillemoes.dk X-HE-Tag: 1634039832-320914 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000118, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 12/10/2021 13.32, Matthew Wilcox wrote: > On Tue, Oct 12, 2021 at 11:55:50AM +0200, Rasmus Villemoes wrote: >> ...default_flag_spec has '.flags = SPECIAL | SMALL,', i.e. what one >> would get from %#x . I'm guessing that's what upsets 0-day. >> >> Geez it would be nice if 0day actually reported the "Expected foo, but >> bar was emitted to the buffer". > > It's there; you just have to dive into the dmesg.xz to get it: > > [ 48.607787][ T1214] test_printf: vsnprintf(buf, 256, "%pGp", ...) returned 33, expected 29 > [ 48.616106][ T1214] test_printf: vsnprintf(buf, 18, "%pGp", ...) returned 33, expected 29 > [ 48.624292][ T1214] test_printf: vsnprintf(buf, 0, "%pGp", ...) returned 33, expected 29 > [ 48.632403][ T1214] test_printf: kvasprintf(..., "%pGp", ...) returned '0x0(node=0|zone=0|lastcpupid=0x0)', expected 'node=0|zone=0|lastcpupid=0x0)' > [ 48.645741][ T1214] test_printf: vsnprintf(buf, 256, "%pGp", ...) returned 33, expected 29 > [ 48.654023][ T1214] test_printf: vsnprintf(buf, 23, "%pGp", ...) returned 33, expected 29 > [ 48.662218][ T1214] test_printf: vsnprintf(buf, 0, "%pGp", ...) returned 33, expected 29 > [ 48.670327][ T1214] test_printf: kvasprintf(..., "%pGp", ...) returned '0x0(node=0|zone=0|lastcpupid=0x0)', expected 'node=0|zone=0|lastcpupid=0x0)' > [ 48.683670][ T1214] test_printf: vsnprintf(buf, 256, "%pGp", ...) returned 88, expected 71 > [ 48.691937][ T1214] test_printf: vsnprintf(buf, 64, "%pGp", ...) returned 88, expected 71 > [ 48.700128][ T1214] test_printf: vsnprintf(buf, 0, "%pGp", ...) returned 88, expected 71 > [ 48.708249][ T1214] test_printf: kvasprintf(..., "%pGp", ...) returned '0x4fffffc008003c(uptodate|dirty|lru|active|swapbacked|node=1|zone=1|lastcpupid=0x1fffff)', expected 'uptodate|dirty|lru|active|swapbacked|node=1|zone=1|lastcpupid=0x1fffff)' > [ 48.730275][ T1214] test_printf: failed 12 out of 420 tests > > So you're right, it's missing the 0x, Ah, it's actually missing the whole '0xfoo(' because you're not updating 'size' after the first + snprintf(cmp_buf + size, BUF_SIZE - size, "%x(", flags); so the next write to cmp_buf overwrites whatever you wrote here. > but I still don't know how to run this self-test. Neither do I, when I created test_printf.c I made sure it ran on boot if built-in, and that's certainly how I've been testing vsprintf.c patches in the past. Maybe the kstm crowd can explain how to get that to work as expected. Rasmus