Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp121008ybx; Wed, 30 Oct 2019 12:16:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZ1+NUtEolwW8AMdm6DI3z6xACcZZYxTaA7MIPAuGvMyVc7LDHUcNytQ6tG/9JXp2cUZB0 X-Received: by 2002:a17:907:2130:: with SMTP id qo16mr1176159ejb.183.1572463017833; Wed, 30 Oct 2019 12:16:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572463017; cv=none; d=google.com; s=arc-20160816; b=eoH5h1NwhCcfKgbwxQ7VjFJWqVZPF8bFfpqTXrAX+oKHZs7MXVl10NX5PHXYm5tgL5 d/3mtoNp3ahs4nAl8tS2YIaPCMtCHJtCLCIl6Jub5/9Bob5nMrr/81wsXtacM+piAwel UQOuZnmX+mlqdFPMWLV5Plo1Uzc+I+bPH1/sXTajqiy7k46CEHtJRLPznRmR3ufiXvPL pzEWfDmRdmAOmOt+SGPjEaDjI42Gqdvax1KGtZlruAnPa/H26IlOOYGpL2cgMDhnNmrx b9y7TIiPKugwivK7zoiMhtpCTsD7xm+DU+45/lQFP+yZzTsan5jpRuzYSdWezgAmevlR gBJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=dufKW7ailST27XmBsRzEjUu5gldQC2+JQubS/xpnsTo=; b=ckoMjVRSKa28mvSGAkORDK7BxbrSsN7FY3zavWqj4wpUqjG3gsIZ/7LHRv7RJjQ5I2 Nz4ihUMIupYnSay7JyoBSoCiPswA6YYlKIY1u3GDcYacQlVijMelR/Jghh+lY4++VVOL 0Ygvq4I3HoEhgA4PbHC0iXBTWRFGFov6kWHyECnYlCw91xDsCWtCR3/Jcf/ChXq8zV5X j8LiJdivklihdj1OIdh4n4rKg92LE/HRHWvgtUiff96gBT2nzaxagO+h9eKZZuKFvr/S G6XGImqD45jlV03xLTCQ68wk/XHyO7XOQ4eHSyL/thSfGm8GBUpotVxSzzNGDZycJPW5 +3PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IgR3AvNb; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e2si2565422edc.97.2019.10.30.12.16.34; Wed, 30 Oct 2019 12:16:57 -0700 (PDT) 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=@chromium.org header.s=google header.b=IgR3AvNb; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726962AbfJ3TJn (ORCPT + 99 others); Wed, 30 Oct 2019 15:09:43 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:43148 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726823AbfJ3TJm (ORCPT ); Wed, 30 Oct 2019 15:09:42 -0400 Received: by mail-pg1-f196.google.com with SMTP id l24so2087716pgh.10 for ; Wed, 30 Oct 2019 12:09:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=dufKW7ailST27XmBsRzEjUu5gldQC2+JQubS/xpnsTo=; b=IgR3AvNb/IW+SuaYisEPvGgQ1N2CpDUOZAYg3Bs1VILV+oQkm3mFZj1IcMwvtNGnDL yeG/doPiWKeFY3yEF0o2hjznX9oxZms0D8u3x06ENtLStfpt0E7OnXbnVS1h8Gnqe7Ln znKBLsdqnjwo/9KJQEFt73HS/yRu0B+AJ1Qpc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dufKW7ailST27XmBsRzEjUu5gldQC2+JQubS/xpnsTo=; b=WkDWGlBZ99d/hhLNY1rjG2z6FNbTV45m3LjQr/84+6R0IF0PNu3G1EoHN1UogAx9Jq +FFaUHsPQhr+K0OpFWJ/fZ9/6my04np7yft7Uf1nbFuinlJe/RY6wGXDp7AOHA7WKNOd piI4kbCwPoUB63/+oF9UIrYSjFtSpyIf4ris8I33rpzcbfAA3HctAXnCv5S024OKUCBT oFAB2PTc9xfW6pZj2qq3k4D4hAYeALmT2xATQ4z47B7RKaxJCgbH10vAghfwhrreHjmU mO3PZyYFb/NJeLidxbBUne7+cC649DPFv/RAtTxpaN9wwKXhFvbgYUfKrt51Cs/eRxYw d3Gg== X-Gm-Message-State: APjAAAXBPALMuKH2DWwdzpXv7skRQ4XJYA7OoKiFt6hIpj373AmKP+Mv AG2vgjxbA+jlfrfG27r5HW2XLQ== X-Received: by 2002:a17:90a:9204:: with SMTP id m4mr1064291pjo.104.1572462581965; Wed, 30 Oct 2019 12:09:41 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id m123sm699881pfb.133.2019.10.30.12.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2019 12:09:41 -0700 (PDT) Date: Wed, 30 Oct 2019 12:09:40 -0700 From: Kees Cook To: Luis Chamberlain Cc: Brendan Higgins , Alan Maguire , Matthias Maennich , shuah , John Johansen , jmorris@namei.org, serge@hallyn.com, Iurii Zaikin , David Gow , Theodore Ts'o , Linux Kernel Mailing List , linux-security-module@vger.kernel.org, KUnit Development , "open list:KERNEL SELFTEST FRAMEWORK" , Mike Salvatore Subject: Re: [PATCH linux-kselftest/test v1] apparmor: add AppArmor KUnit tests for policy unpack Message-ID: <201910301205.74EC2A226D@keescook> References: <20191018001816.94460-1-brendanhiggins@google.com> <20191018122949.GD11244@42.do-not-panic.com> <20191024101529.GK11244@42.do-not-panic.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191024101529.GK11244@42.do-not-panic.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 24, 2019 at 10:15:29AM +0000, Luis Chamberlain wrote: > On Wed, Oct 23, 2019 at 05:42:18PM -0700, Brendan Higgins wrote: > > With that, I think the best solution in this case will be the > > "__visible_for_testing" route. It has no overhead when testing is > > turned off (in fact it is no different in anyway when testing is > > turned off). The downsides I see are: > > > > 1) You may not be able to test non-module code not compiled for > > testing later with the test modules that Alan is working on (But the > > only way I think that will work is by preventing the symbol from being > > inlined, right?). > > > > 2) I think "__visible_for_testing" will be prone to abuse. Here, I > > think there are reasons why we might want to expose these symbols for > > testing, but not otherwise. Nevertheless, I think most symbols that > > should be tested should probably be made visible by default. Since you > > usually only want to test your public interfaces. I could very well > > see this getting used as a kludge that gets used far too frequently. > > There are two parts to your statement on 2): > > a) possible abuse of say __visible_for_testing I really don't like the idea of littering the kernel with these. It'll also require chunks in header files wrapped in #ifdefs. This is really ugly. > b) you typically only want to test your public interfaces True, but being able to test the little helper functions is a nice starting point and a good building block. Why can't unit tests live with the code they're testing? They're already logically tied together; what's the harm there? This needn't be the case for ALL tests, etc. The test driver could still live externally. The test in the other .c would just have exported functions... ? -- Kees Cook