Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1450696ybx; Tue, 5 Nov 2019 16:36:32 -0800 (PST) X-Google-Smtp-Source: APXvYqz5E5iKKESQRdln+QisHmhiGCvFTfc7X/hZC26mWVzv86fBjXA0eGoLdYw0b72hmox+wEm9 X-Received: by 2002:a17:906:a40e:: with SMTP id l14mr11416600ejz.168.1573000592644; Tue, 05 Nov 2019 16:36:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573000592; cv=none; d=google.com; s=arc-20160816; b=gDvZw3xR4NL5BM6IuPAn9vBW4F8K21VyA0L/pSMUFFqLvsEPhZsl9ZtSJ7e4YW9DOz fg9l740bGrkMNC3h3pE/uXjBgiWhOppVFjzHqqgb/emUuatlDcEzDynHuWVXtDcOOWWQ 6T5jvtJbaPoONUjx5W2ageZW+6IBuXxK0mBjhZpQ3saFu9SM2LmJy6cWPoY9BWff/Vz3 o2xBwH9qilRsfIMzTbWROAhPzO9vLe1xaI4DSxfYcg5oeXX7mMYJCBJxRb8TjPmGNXDG kawT9j0w/C6CkMwchrBzOwcaTxjwllmq7+6Y9oYv45Xn8+xtOH4t2TX/CvS4BCRouigc 9Gww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=nV6+nAXCqKLxAkJ73MkPjCdygA/6kDv8a5/d5YqbKKM=; b=DPX2wDJ/dpvVuJPltXVVMy1T8MVPHUS3iM4pMJjXNOuE/eTeY8KBo3TvBfGYRqR9Ni 2bTR3Jc5eGVF5BdnJqJ+1i4wYuoUv+azYPMf5RWXm0mS21C70WUqtOsDh1ADkPmHMWrp fIY7/pyXKe+zQN+AzK0BDRalUbElkBD/WSAu+0KDZSVgaR+Il0rRKjsqqmlxedsQsDod WV8adCfXAZL+zRl5DIHpMg/m2cz+nFuaYMX9oqrQ6F9XWGIL/ZTcZHC30O0jB+WzSL++ l9Rd3drP/PqaVuQvrtOjEuboxI3GrVIgtdVmFzLj8+086WF9J57rjm6/fxYkJFrpxB3v irsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=iwk05Z47; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d21si11728432edb.180.2019.11.05.16.36.08; Tue, 05 Nov 2019 16:36:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=iwk05Z47; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729563AbfKFAff (ORCPT + 99 others); Tue, 5 Nov 2019 19:35:35 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:44715 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729494AbfKFAff (ORCPT ); Tue, 5 Nov 2019 19:35:35 -0500 Received: by mail-pf1-f193.google.com with SMTP id q26so17409940pfn.11 for ; Tue, 05 Nov 2019 16:35:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nV6+nAXCqKLxAkJ73MkPjCdygA/6kDv8a5/d5YqbKKM=; b=iwk05Z47ymun6qVZ2ZqvWQVrNbyrFI4pKJaqVPuEkPVoeZ8TkgQOMYeUjohJyfTxHy i35BEo94zplaDsUpCIniLT2yVpRSn0rD/LIMZNRRDFvwzV2sw5aV+CntsHEXnIS5QRWU credwKAD1iKpgmUDD//nXU9d/JxDgA1iEl62DNLFnu4wvD4qkNgQ8PPueRPgDYOLgbG/ wRQ40/pTEPmrga86TUsN55Q89f3ccHt/vgpMxsPdm95ao3HIHGPXqJhoiqMN+sz2D0kx L5TvL5vphZGSYA4WnzDDvIMRkLoCjBCDf84EfTVmSdk0cpkisx4MeLqnP8yYmbqeUxse 0Yng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nV6+nAXCqKLxAkJ73MkPjCdygA/6kDv8a5/d5YqbKKM=; b=MpoK2I5N+qO3U5cjBUMZhfpSHURnfoP6Rw9bOu5FOa04o2erKLyHdlk4TKWeEDJNjZ 6vuykOJlc9SqQKBB3aEYhTihdwm708tIPATOZCgh0VHrB+79Jvv5NdguzJ5FabATtk4i 7gvVcHnx/1v9wiLjYH5ivrAvWdGE40aMQpuWMROUuX33UuJS1L5lTsAAJVv2AxzwXHg0 VksHY4YqEB+jTXvH2nDzgJUnJR09DUk2L8o9Uj3o++rUXOHETeS06xnxnYVPiONdGR+3 Ph7bZDtHaQqr2s+Ai5nhF/t+r+vzlNeQe0BKmtsbzMiA20m2/C9UF2WXD+1E9qpxx1D+ c5cQ== X-Gm-Message-State: APjAAAUrwZOys6X0p5saBr+9xFCzL5NfLn7QDhrGZ7xMUTqZfH5ywLEk WazWkahiE/AukopN2KFXmNS9En24CRWjIYH4vmeEFA== X-Received: by 2002:a63:234c:: with SMTP id u12mr38258741pgm.384.1573000534052; Tue, 05 Nov 2019 16:35:34 -0800 (PST) MIME-Version: 1.0 References: <20191018001816.94460-1-brendanhiggins@google.com> <201910301157.58D0CE4D3@keescook> In-Reply-To: <201910301157.58D0CE4D3@keescook> From: Brendan Higgins Date: Tue, 5 Nov 2019 16:35:22 -0800 Message-ID: Subject: Re: [PATCH linux-kselftest/test v1] apparmor: add AppArmor KUnit tests for policy unpack To: Kees Cook Cc: Iurii Zaikin , shuah , John Johansen , jmorris@namei.org, serge@hallyn.com, Alan Maguire , David Gow , Luis Chamberlain , "Theodore Ts'o" , Linux Kernel Mailing List , linux-security-module@vger.kernel.org, KUnit Development , "open list:KERNEL SELFTEST FRAMEWORK" , Mike Salvatore Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 30, 2019 at 11:59 AM Kees Cook wrote: > > On Thu, Oct 17, 2019 at 05:33:56PM -0700, Iurii Zaikin wrote: > > On Thu, Oct 17, 2019 at 5:19 PM Brendan Higgins > > wrote: > > > > > +config SECURITY_APPARMOR_TEST > > > + bool "Build KUnit tests for policy_unpack.c" > > > + default n > > New options already already default n, this can be left off. > > > > + depends on KUNIT && SECURITY_APPARMOR > > > + help > > > > > select SECURITY_APPARMOR ? > > "select" doesn't enforce dependencies, so just a "depends ..." is > correct. > > > > + KUNIT_EXPECT_EQ(test, size, TEST_BLOB_DATA_SIZE); > > > + KUNIT_EXPECT_TRUE(test, > > > + memcmp(blob, TEST_BLOB_DATA, TEST_BLOB_DATA_SIZE) == 0); > > I think this must be KUNIT_ASSERT_EQ(test, size, TEST_BLOB_DATA_SIZE);, > > otherwise there could be a buffer overflow in memcmp. All tests that > > follow such pattern > > Agreed. > > > are suspect. Also, not sure about your stylistic preference for > > KUNIT_EXPECT_TRUE(test, > > memcmp(blob, TEST_BLOB_DATA, TEST_BLOB_DATA_SIZE) == 0); > > vs > > KUNIT_EXPECT_EQ(test, > > 0, > > memcmp(blob, TEST_BLOB_DATA, TEST_BLOB_DATA_SIZE)); > > I like == 0. Oh, I almost missed this. I think the *_EQ(...) is better than the *_TRUE(...) because the EQ is able to provide more debug information if the test fails (otherwise there would really be no point in providing all these variants). Any objections? Thanks for the catch Iurii!