Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1417722pxx; Fri, 30 Oct 2020 09:29:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJym0Cni/V4COLzYZk5iQqcWRvgTNJ4/Px9Zz+sKMhbFhy8Epuz8oA0wnjna4IlZ6Gm2Awgg X-Received: by 2002:a17:906:134e:: with SMTP id x14mr3136822ejb.173.1604075343536; Fri, 30 Oct 2020 09:29:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604075343; cv=none; d=google.com; s=arc-20160816; b=W4jbfJRFhhupaQ70M1U8ZHmCmIU/jt5MdOlHdB++hPGVwLvqN0QT2ZdDjQ480mGZVu cU4LlTNEeVds5KjkkyX/vISCL3ZoW5m5G79edDoQduuk4uP/Wxo9ionBY6sLIape3CDE a7PkF0tXi2VANeskUVSQGreRDLWk5uee8TGDEyUnffu53j32hGnjoI8FgUMGCouJM5Aj cutpIL8qP0r4rIk/TkIqnxwr3sqMctxarcujjwmK4P0HiVdnKdjV1RJ27vzuyrFMLrOp yssbj5YeUTHoHPLbUBOseDMxrZhbcjIa5UHhGCntVlxEqC5pJCxscCaMARineNuCIylq wYnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+a0eewLbc0DaaRq9NLSkTv7hmXsXsmk9e+rtyuIjTik=; b=bV0M5Hu6II9En9nG0hnwt3jKEL/wQnlL8y5bfcTDyfWoDnEYWa6ShgcClt2IC5Zbul jWYblMNPRwFVtDCZaBxvx+wBtKhQaztLfmk2epAhUsBRMPz/Dxqyy8r4uzfzWWovX1ys JcZnbRbONTCz08vNjIhGolt2d4V3yIBCdU/gldSwl/Fwcb/UcZx/Fz/3BZXOAXTpb1C6 P7jy6d9Lmyby4NiEplp+iwFqpRzxqd6JGIqaVK726JGN0n+JhRkiHs3DLw+66Z8qyuxH CCE5KKOP3hAuS4tBh/yr4vJLldLsgTvJiusTweh39ihsKIUjTsQj/ycCinmV0N6rL5qh EmVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=BYY6aVS5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s2si4814452edy.490.2020.10.30.09.28.38; Fri, 30 Oct 2020 09:29:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=BYY6aVS5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726779AbgJ3Q02 (ORCPT + 99 others); Fri, 30 Oct 2020 12:26:28 -0400 Received: from mx2.suse.de ([195.135.220.15]:40498 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbgJ3Q02 (ORCPT ); Fri, 30 Oct 2020 12:26:28 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1604075186; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+a0eewLbc0DaaRq9NLSkTv7hmXsXsmk9e+rtyuIjTik=; b=BYY6aVS5b0RlbLlk18+GJWhuAxIVAMOJTA0Jqv8FFXa7GY3g6PT9fsNz5PTsyoowCARt57 6ZbXDmw2OfJQuzr4E62ys1OE9EXYklEiIT0BARKx8ywsgRaeG6k4ENUDhiPB9xKf96GOCZ AVBGKHc2Rzlhq+QU5EMFqcHHeF/Jf3A= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 257C7AC1F; Fri, 30 Oct 2020 16:26:26 +0000 (UTC) Date: Fri, 30 Oct 2020 17:26:25 +0100 From: Petr Mladek To: Rasmus Villemoes Cc: Shuah Khan , Kees Cook , Willy Tarreau , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Arpitha Raghunandan <98.arpi@gmail.com>, Andy Shevchenko , Brendan Higgins Subject: Re: [PATCH 4/4] lib/test_printf.c: use deterministic sequence of random numbers Message-ID: <20201030162625.GE20201@alley> References: <20201025214842.5924-1-linux@rasmusvillemoes.dk> <20201025214842.5924-5-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201025214842.5924-5-linux@rasmusvillemoes.dk> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun 2020-10-25 22:48:42, Rasmus Villemoes wrote: > The printf test suite does each test with a few different buffer sizes > to ensure vsnprintf() behaves correctly with respect to truncation and > size reporting. It calls vsnprintf() with a buffer size that is > guaranteed to be big enough, a buffer size of 0 to ensure that nothing > gets written to the buffer, but it also calls vsnprintf() with a > buffer size chosen to guarantee the output gets truncated somewhere in > the middle. > > That buffer size is chosen randomly to increase the chance of finding > some corner case bug (for example, there used to be some %p > extension that would fail to produce any output if there wasn't room > enough for it all, despite the requirement of producing as much as > there's room for). I'm not aware of that having found anything yet, > but should it happen, it's annoying not to be able to repeat the > test with the same sequence of truncated lengths. > > For demonstration purposes, if we break one of the test cases > deliberately, we still get different buffer sizes if we don't pass the > seed parameter: > > root@(none):/# modprobe test_printf > [ 15.317783] test_printf: vsnprintf(buf, 18, "%piS|%pIS", ...) wrote '127.000.000.001|1', expected '127-000.000.001|1' > [ 15.323182] test_printf: failed 3 out of 388 tests > [ 15.324034] test_printf: random seed used was 0x278bb9311979cc91 > modprobe: ERROR: could not insert 'test_printf': Invalid argument > > root@(none):/# modprobe test_printf > [ 13.940909] test_printf: vsnprintf(buf, 22, "%piS|%pIS", ...) wrote '127.000.000.001|127.0', expected '127-000.000.001|127.0' > [ 13.944744] test_printf: failed 3 out of 388 tests > [ 13.945607] test_printf: random seed used was 0x9f72eee1c9dc02e5 > modprobe: ERROR: could not insert 'test_printf': Invalid argument > > but to repeat a specific sequence of tests, we can do > > root@(none):/# modprobe test_printf seed=0x9f72eee1c9dc02e5 > [ 448.328685] test_printf: vsnprintf(buf, 22, "%piS|%pIS", ...) wrote '127.000.000.001|127.0', expected '127-000.000.001|127.0' > [ 448.331650] test_printf: failed 3 out of 388 tests > [ 448.332295] test_printf: random seed used was 0x9f72eee1c9dc02e5 > modprobe: ERROR: could not insert 'test_printf': Invalid argument > > Signed-off-by: Rasmus Villemoes Great feature! Reviewed-by: Petr Mladek Best Regards, Petr