Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1212939pxb; Wed, 6 Apr 2022 11:28:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFsMTIVTtOwZ6xAJ9IHYiBMpv0a4CX11ne9qCn1nhTr6mXEm+OOEyOHwnIp4uDdh+c+0Cm X-Received: by 2002:a63:6c4:0:b0:382:8506:c127 with SMTP id 187-20020a6306c4000000b003828506c127mr8310521pgg.279.1649269713079; Wed, 06 Apr 2022 11:28:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649269713; cv=none; d=google.com; s=arc-20160816; b=DJ4pPTXfYSW9vE+YoOu1Y5eBsl43ChxQKtnZwtBF5W4fWb9kV0CpU7Gp/8d+3WNLyy YQfw1RAm5/XDl4EUVyWIsLmvXqXgfJIHlkM37gpecYieRRVgel3J3yOxvZjU2DJ+15tc new+SJ7hmLmu3rjCYLJ5O0riu9ns09BXIObs/lplebxTW4Kcwjccicd9invGKCnFX57+ bJSGt9p0cZJL8dcr2RMgp/lMKSuvuP94WL9lUTw/vUy+VZ9ujkLxeTyt4IwMkPgAi8hW NjIwFxCgJfiNk1eOQ8a2QD6iOM79l3o0XDwA4ZBZ0PhzWqLQ1yUGRHNlK7iAqaU8n005 UlOw== 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=sQTT4EqOLRNQF0Ed2dIB0yr4+oIJIzcbTRQWujoh2kY=; b=vKc2e39sN0/H7InneQvatIXFe4QrKwy59zwaGTl2BdPrfxqyeTl9TfnrZS9gc3iXYV o/L71+DUSS2iUSnxSMR71K8QO4QPRqhxwZeHN9XMcVmaaEhCCtNbagpA4Ie6BNBsPhWO sVqgUEF6T5+XgOdw7qe5kcUUKbQux1ZmuZTvdR9c454p4CyCpT7RyxcfmeSCT6WltXhU EP7HxxdqBfMIiSS6MljoVDQ9ghdn2Vsq8xZV/OXsRhHnZyTpL8Tnyi605IIw0/PwT7dr jL/iGZ96deFmj6gpcKO+pnA4LIu8I+ZqEjazNWsODsIe8eTQgURMoxpsBJR3ylitx+Tf 9P9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Ek/VubAN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l15-20020a170903120f00b00153b2d16579si17287133plh.385.2022.04.06.11.28.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 11:28:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Ek/VubAN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BCB93185469; Wed, 6 Apr 2022 11:11:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240374AbiDFSNM (ORCPT + 99 others); Wed, 6 Apr 2022 14:13:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240547AbiDFSMx (ORCPT ); Wed, 6 Apr 2022 14:12:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DBC2C1F9A3E for ; Wed, 6 Apr 2022 09:50:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649263817; 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=sQTT4EqOLRNQF0Ed2dIB0yr4+oIJIzcbTRQWujoh2kY=; b=Ek/VubANinPC9h9ZGCSwBN5Dy2Bd73QKGhM2T4OwroZM/1bb9vVAESyDG+hH6qht4dZalw qk1SwZF3VLvGdpwVqGvzfQJ33ENEltBbOYmLNUpUEIeWsz1qvK8ijQPvm2vnlItAp+xIlN yOfgy2UhkPyLSrj1uiU4NwsGlQ/+no0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-446-f_Ly0toDM--tXyule_3RIw-1; Wed, 06 Apr 2022 12:50:14 -0400 X-MC-Unique: f_Ly0toDM--tXyule_3RIw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 30F0F803D7C; Wed, 6 Apr 2022 16:50:13 +0000 (UTC) Received: from madcap2.tricolour.ca (ovpn-0-8.rdu2.redhat.com [10.22.0.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CFF7B76C4; Wed, 6 Apr 2022 16:49:56 +0000 (UTC) Date: Wed, 6 Apr 2022 12:49:54 -0400 From: Richard Guy Briggs To: CGEL Cc: Paul Moore , kbuild-all@lists.01.org, Zeal Robot , linux-kernel@vger.kernel.org, eparis@redhat.com, dai.shixin@zte.com.cn, Yang Yang , linux-audit@redhat.com, ink@jurassic.park.msu.ru, huang.junhua@zte.com.cn, guo.xiaofeng@zte.com.cn, mattst88@gmail.com Subject: Re: [PATCH] audit: do a quick exit when syscall number is invalid Message-ID: References: <20220326094654.2361956-1-yang.yang29@zte.com.cn> <62465bf3.1c69fb81.d5424.365e@mx.google.com> <2777189.mvXUDI8C0e@x2> <624803f7.1c69fb81.972da.2dd0@mx.google.com> <624cea8e.1c69fb81.422be.e03b@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <624cea8e.1c69fb81.422be.e03b@mx.google.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-04-06 01:19, CGEL wrote: > On Mon, Apr 04, 2022 at 11:58:50AM -0400, Richard Guy Briggs wrote: > > On 2022-04-02 08:06, CGEL wrote: > > > On Fri, Apr 01, 2022 at 10:16:45AM -0400, Paul Moore wrote: > > > > On Fri, Apr 1, 2022 at 9:39 AM Steve Grubb wrote: > > > > > On Thursday, March 31, 2022 9:57:05 PM EDT CGEL wrote: > > > > > > On Thu, Mar 31, 2022 at 10:16:23AM -0400, Paul Moore wrote: > > > > > > > On Wed, Mar 30, 2022 at 10:29 PM CGEL wrote: > > > > > > > > On Wed, Mar 30, 2022 at 10:48:12AM -0400, Paul Moore wrote: > > > > > > > > > If audit is not generating SYSCALL records, even for invalid/ENOSYS > > > > > > > > > syscalls, I would consider that a bug which should be fixed. > > > > > > > > > > > > > > > > If we fix this bug, do you think audit invalid/ENOSYS syscalls better > > > > > > > > be forcible or be a rule that can be configure? I think configure is > > > > > > > > better. > > > > > > > > > > > > > > It isn't clear to me exactly what you are asking, but I would expect > > > > > > > the existing audit syscall filtering mechanism to work regardless if > > > > > > > the syscall is valid or not. > > > > > > > > > > > > Thanks, I try to make it more clear. We found that auditctl would only > > > > > > set rule with syscall number (>=0 && <2047) ... > > > > > > > > That is exactly why I wrote the warning below in my response ... > > > > > > > I think the question is more clear now. > > > > > > 1) libaudit.c wants to forbid setting invalid syscall, but inconsistent > > > Currently way(>=0 && <2047) is inconsistent, syscall with number 2000 and > > > syscall with number 3000 are both invalid syscall. But 2000 can be set by > > > auditctl, and 3000 cannot be set by auditctl. > > > A better way to do this forbidden is to use __NR_syscalls(asm-generic/unistd.h). > > > > > > 2) if libaudit.c do the right forbidden, kernel better ignore invalid syscall > > > See this patch. > > > > > > If we want audit invalid syscall as you said before. libaudit.c should not > > > do the forbidden, auditctl should allow setting syscall rule with 'any' number. > > > So do you think we should fix libaudit.c? > > > > I'm having a bit of trouble understanding what you've said above. > > > > The kernel ultimately must protect itself from malice and mistakes, so > > it must verify all data sent to it. > > > > Userspace can help by knowing what that kernel policy is so it can avoid > > violating that policy or provide useful feedback if it can't. Userspace > > can be used to make things more efficient, but the kernel is the last > > step for security. > > > > If userspace and the kernel are mismatched or out of sync, then the > > kernel enforces policy to protect itself. > > Much appreciate for your interpretation. Have you get any idea of how > to solve the mismatched? From your viewpoint, I think it's better for > kernel to not handle syscall of syscall number<0, because it's invaild > of all arch, and has no value for attacker to probing for specific > syscall numbers. Going back to the very first quoted line above, if you can generate a test case that shows that audit is missing an auditable event, that is a bug that should be fixed. > > > > > > > to the audit syscall filter, which are unfortunately baked into the > > > > > > > current design/implementation, which may affect this to some extent. > > > > > > > > -- > > > > paul-moore.com > > > > - RGB - RGB -- Richard Guy Briggs Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada IRC: rgb, SunRaycer Voice: +1.647.777.2635, Internal: (81) 32635