From patchwork Fri Jun 15 08:08:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Myl=C3=A8ne_Josserand?= X-Patchwork-Id: 929821 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 416Y5h4XFSz9s29 for ; Fri, 15 Jun 2018 18:08:23 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 0918A3E7F22 for ; Fri, 15 Jun 2018 10:08:20 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) by picard.linux.it (Postfix) with ESMTP id 4FDCF3E7D8F for ; Fri, 15 Jun 2018 10:08:18 +0200 (CEST) Received: from mail.bootlin.com (mail.bootlin.com [62.4.15.54]) by in-3.smtp.seeweb.it (Postfix) with ESMTP id 94BB61A0178B for ; Fri, 15 Jun 2018 10:08:17 +0200 (CEST) Received: by mail.bootlin.com (Postfix, from userid 110) id 16A06207B0; Fri, 15 Jun 2018 10:08:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it X-Spam-Level: X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_PASS autolearn=disabled version=3.4.0 Received: from dell-desktop.home (AAubervilliers-681-1-37-30.w90-88.abo.wanadoo.fr [90.88.156.30]) by mail.bootlin.com (Postfix) with ESMTPSA id DE77F207A5; Fri, 15 Jun 2018 10:08:15 +0200 (CEST) From: =?utf-8?q?Myl=C3=A8ne_Josserand?= To: ltp@lists.linux.it Date: Fri, 15 Jun 2018 10:08:10 +0200 Message-Id: <20180615080810.9814-1-mylene.josserand@bootlin.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean Cc: thomas.petazzoni@bootlin.com Subject: [LTP] [PATCH] testcases: cve-2014-0196: Set attempts according to nb of cpus X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This test tries to cause a buffer overflow by doing 0x7000 attempts. In a slow system platform, it leads to a failure because of the timeout even when it is configured with LTP_TIMEOUT_MUL=10. This commit adds a way to configure the number of attempts according to the number of CPUs. In case of 1 CPU and a slow platform, using 0x2000 attempts with a LTP_TIMEOUT_MUL=2 make the test pass. Signed-off-by: Mylène Josserand --- Hello, This is a way to fix the issue I got but let me know what you think of it. There is maybe a better way to handle that. Thank you, Mylène testcases/cve/cve-2014-0196.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/testcases/cve/cve-2014-0196.c b/testcases/cve/cve-2014-0196.c index d18108897..898da1073 100644 --- a/testcases/cve/cve-2014-0196.c +++ b/testcases/cve/cve-2014-0196.c @@ -48,7 +48,7 @@ #define ONEOFF_ALLOCS 200 #define RUN_ALLOCS 30 -#define ATTEMPTS 0x7000 +#define ATTEMPTS 0x2000 #define BUFLEN 512 static volatile int master_fd, slave_fd; @@ -98,11 +98,14 @@ static void *overwrite_thread_fn(void *p LTP_ATTRIBUTE_UNUSED) static void run(void) { struct termios t; - int i, j; + int i, j, total_cpus; - tst_res(TINFO, "Attempting to overflow into a tty_struct..."); + total_cpus = tst_ncpus(); - for (i = 0; i < ATTEMPTS; i++) { + tst_res(TINFO, "Attempting to overflow into a tty_struct during %x attempts...", + ATTEMPTS * total_cpus); + + for (i = 0; i < ATTEMPTS * total_cpus; i++) { create_pty((int *)&master_fd, (int *)&slave_fd); for (j = 0; j < RUN_ALLOCS; j++)