Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5629357ybi; Sun, 7 Jul 2019 09:04:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjObHzRAn9uBcJJKRGGr0v/XH35yPLcN49Z2AoZogRRpFGX6T96eSiIseQ4HYneucC+78V X-Received: by 2002:a63:eb56:: with SMTP id b22mr17834418pgk.355.1562515495159; Sun, 07 Jul 2019 09:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562515495; cv=none; d=google.com; s=arc-20160816; b=AJoYzaQeq9A6brFpL56XUBRDCje+ZbmcqXjy3H163O1SxND5ellSmAVPAgg2rnBvi2 LP0zaugWRANen/10QJqJ70FJsZgUycMjNBAAPdlNJK/JEwIkZQm7eXY+j5jMPqaKYvth iOIfzNFR6S0N5dlaEDAPVvDFMt/OnZqAaAH+Y2Uby58NfQUmBBrmV6f35jfoqYugN/CY dm2s9zu+EHMflCFLtbsmGAENXWLHGx0/ucBcVBH21Ji8pYHDXI2QqzV55DVDbF2STG7A w4grjeNMZaja2bTQlzKx5oLY0+QsDuA01cx9q8foA70H0fLFcEqOsKck8RbfKULFwONF VS2g== 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=kpL69YTVdvgy2bgbCOoUAnMPb0H84df6WGk7mkMI8Qw=; b=wRoCRmRx/w7yjIXYRGiZZROz2rksAHaKLD9AxgNc29DUEag6MEJyxjDUfZc0nbfvpY ufZsFrltf1f/5wLnGwIOmym9YzfOU1bHJIYOlsqlD6iTyF6rM39yQ2qCo//OhAr8JXL6 2PaMiyrLdLZiImgVN8xJgeu5LAVy59iwdEfyNXiCBIzTCJaXpbfEUbZpw6iGLKGcoiuJ YKmY+3fSI7JaObu+T+3SfQbsvUlY57OBTII8v16zLbEDQimF3jmXY3+A+9HjqKklBA1l SHUsYPovwQ11XWVvCMBKPabheBy48qtWOLah8YfoCkSC06IJx+QQJ+7n/eNz9UJ4upZh /+WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nCwfu1OY; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a65si16250166pge.558.2019.07.07.09.04.40; Sun, 07 Jul 2019 09:04:55 -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=@gmail.com header.s=20161025 header.b=nCwfu1OY; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727142AbfGGQBn (ORCPT + 99 others); Sun, 7 Jul 2019 12:01:43 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:43041 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725901AbfGGQBn (ORCPT ); Sun, 7 Jul 2019 12:01:43 -0400 Received: by mail-io1-f66.google.com with SMTP id k20so29363972ios.10; Sun, 07 Jul 2019 09:01:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kpL69YTVdvgy2bgbCOoUAnMPb0H84df6WGk7mkMI8Qw=; b=nCwfu1OYXtJXAuz5Lw4SgN1PmgDQUVSLIFq+2jh1XLmUp3piIngxYlk0KmfkFI1FdU ROOz1oYuYpPTsIRC19fMn50wHKiL/1gzimzolIXiaiQbaMHI7/jEq3bXle+03+OUSiDc vb8XG3QFPTFXCgHoRzC3t4VI3dM5wY+VV08O9+8PRER8D6corxQOdB2qjaeH6UCQ+QcP FBAc9oCbnVJZQHcsSuN32Wru3Ez2SyPRyHYLFtpT1SvyMWXfGXVY0oh+ribE8rBorJx1 csI7+IjL0WhDtEaVwk2kiNc+fitKtaiRXFvzVURUwwFo3mTjAhcUNR/9yv01OnRYj5l9 zVaA== 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=kpL69YTVdvgy2bgbCOoUAnMPb0H84df6WGk7mkMI8Qw=; b=m2HlpE3bM6ieEtXoM8gqvCqlGuRQeGPMMvOBMYkCx16RsxOnCnNYZbqINQCHBGV26J 5HDaFhXV7WU4u03/V4x8TPWRvfd1TIVASPrPu2y1sQNgv7J06kAcCqTlaY1jTmuuV8GB oKoJz8VS/8ZW7tCaebwlcQSvPOKd9HJCoMdsK4/AB4ZiX5h+2Syhh2EDPDdAVseBCGb0 1myCYcDcJx+STF9KcTQmFg7Z0BEJ1jpo5t/8BKy1nrqtxrKlaZP9tyl6JqlAI5oIRmg1 /mMkpiw+n0TGTRqoV7/YD/Dr6PsbBwNofVskdvHcMh/32SdX2VMMqvF6thlwj3bmzJNa vvKg== X-Gm-Message-State: APjAAAVxl/MeFMZiSd/EGGE6ReKwD8NHvc+9cxx+pgGtMqlQuf+mhbVW pnYd1HMYjjtWo4YmIno7ifQx4lKjtnB0rZKKoV8= X-Received: by 2002:a5d:940b:: with SMTP id v11mr1384909ion.69.1562515302185; Sun, 07 Jul 2019 09:01:42 -0700 (PDT) MIME-Version: 1.0 References: <1562410493-8661-1-git-send-email-s.mesoraca16@gmail.com> <1562410493-8661-5-git-send-email-s.mesoraca16@gmail.com> In-Reply-To: From: Salvatore Mesoraca Date: Sun, 7 Jul 2019 18:01:31 +0200 Message-ID: Subject: Re: [PATCH v5 04/12] S.A.R.A.: generic DFA for string matching To: Jann Horn Cc: kernel list , Kernel Hardening , Linux-MM , linux-security-module , Alexander Viro , Brad Spengler , Casey Schaufler , Christoph Hellwig , Kees Cook , PaX Team , "Serge E. Hallyn" , Thomas Gleixner , James Morris , John Johansen 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 Jann Horn wrote: > > On Sat, Jul 6, 2019 at 12:55 PM Salvatore Mesoraca > wrote: > > Creation of a generic Discrete Finite Automata implementation > > for string matching. The transition tables have to be produced > > in user-space. > > This allows us to possibly support advanced string matching > > patterns like regular expressions, but they need to be supported > > by user-space tools. > > AppArmor already has a DFA implementation that takes a DFA machine > from userspace and runs it against file paths; see e.g. > aa_dfa_match(). Did you look into whether you could move their DFA to > some place like lib/ and reuse it instead of adding yet another > generic rule interface to the kernel? Yes, using AppArmor DFA cloud be a possibility. Though, I didn't know how AppArmor's maintainers feel about this. I thought that was easier to just implement my own. Anyway I understand that re-using that code would be the optimal solution. I'm adding in CC AppArmor's maintainers, let's see what they think about this. > > +++ b/security/sara/dfa.c > > @@ -0,0 +1,335 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > + > > +/* > > + * S.A.R.A. Linux Security Module > > + * > > + * Copyright (C) 2017 Salvatore Mesoraca > > + * > > + * This program is free software; you can redistribute it and/or modify > > + * it under the terms of the GNU General Public License version 2, as > > + * published by the Free Software Foundation. > > Throughout the series, you are adding files that both add an SPDX > identifier and have a description of the license in the comment block > at the top. The SPDX identifier already identifies the license. I added the license description because I thought it was required anyway. IANAL, if you tell me that SPDX it's enough I'll remove the description. Thank you for your comments.