Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2915499pxb; Sat, 26 Mar 2022 07:05:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGMmlkqwDY5lbDIO7fJ0OrgY0+X0l7JdxTyBTlRKxCfNp8b3UV0SwuaigifzbZCAQc6fvT X-Received: by 2002:a17:907:62a1:b0:6da:7952:d4d2 with SMTP id nd33-20020a17090762a100b006da7952d4d2mr17366075ejc.260.1648303542468; Sat, 26 Mar 2022 07:05:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303542; cv=none; d=google.com; s=arc-20160816; b=wv9Xasu5vdQHsjtJUYzGNHf2ZbH8OC/rpG+zA4fmV0kzDzUScHsuIgJ5eGlSnBbh8V xD/OU/tzjafCcrtvq3wJlGgOLzbhVPPgLWqCG8I5IHihwajwl2Qx/YDTDW+G1dG0n4kx +p/zhnrbPPc+ufM3FBbqsDJD//4JRYu8x7+rAklxkNwOmd/2Yd8Mv1VYELWPzHzixRsc v48JDdsYZJKth0rKrvelica2OFgcO/LWl44EXkePytCSXhXNA7pSullMQC0W+8unRhcF nN/J2yxKfKbn2ajzzv16t7rVU6NxeSduEOIzISMfVbJFQBfJTMnEZxp+grQHXB4KgM+l OHuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=+B7SpbgCMQv+5yCcAkjFJyzQjT6pt2NifXC9lsW5qSg=; b=JO3IhWiyfnVY4pY7xq/bgs1Gf8+t1mB7gfF0FALRZe9tcmf3IhOFiXXucGGysqJwp+ 22/aSN8TRSHohqIn8RKroB/f17xxRtFA3VDO9XWTqURSTf0HNhHCqEztfLVcwK2MYj/j T6f+zGabR3+W3euTHMJbpvOsm9EvPmXEr5ZLRApZOZNSjgd1CBbKXOaszUd8TKhHnY9U /KJ2fq8ktJGSq7deUFk656sYZ/I9PioimWOHie3aZgd2B9KZ0worgulB5YER5DYK8Qhr fIavRrJhjt+yiXsx8vxj/WV/rEK0nGkkdIDUxgYONC4seIqQjkt63syMEpHCfKOlB3pN cD7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="NpmAWev/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u16-20020a170906069000b006df76385c52si5975147ejb.242.2022.03.26.07.04.55; Sat, 26 Mar 2022 07:05:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="NpmAWev/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232225AbiCZJtI (ORCPT + 99 others); Sat, 26 Mar 2022 05:49:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231936AbiCZJtG (ORCPT ); Sat, 26 Mar 2022 05:49:06 -0400 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 807FD24B0B0 for ; Sat, 26 Mar 2022 02:47:29 -0700 (PDT) Received: by mail-qv1-xf31.google.com with SMTP id f3so8067406qvz.10 for ; Sat, 26 Mar 2022 02:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+B7SpbgCMQv+5yCcAkjFJyzQjT6pt2NifXC9lsW5qSg=; b=NpmAWev/N16WKN4wld338PxVITBO9RaPVr/AiJWR/Tpk9ZkmS65sp3fXy0PbruDj8p 691+5dReWc86SJbwzkI+aj7N3j3vLHifW8nm4a2Mwr5yuRZd+lEvEntSTk2snA/V/weH wdPKT7DqRgJ9qtW0JSmbG4iPJvDUyNnWeEIwJd3ufYL9Mb6taDLp+l8m9bD4JK3dcGws eNwbVWO+HJOSqTzgED/jzC7gKX7ioVzzEqFSliuvsueHkLlg8XXcK+pRDdxKJZZU+jHc 3yjmU3t5xnZUyTgplbkiMcFu93/ufnnA8FQIx4DFKjCq+LTxz2FvaouRvipzm8F5VPpr wtXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+B7SpbgCMQv+5yCcAkjFJyzQjT6pt2NifXC9lsW5qSg=; b=ASaqLTpo58BJIEBFIPxsvy30pH73l2q7zERcxa8hTQGUxV1EJDyR/1XXgRU0gWRl1A sqdH/0wi0PKH7iTUG3Wn1lbR7tVznGgAsuU4LQCou3ZQqMAFKAVor4Gxp1NigweBe+Zl u4nV2TJqqG8GvFeK7HWIycaavErvWjVgZdIiRl9omE7tpFkydBuOu+ohy0ckn9RVBL1n IgXlYdkjlZt5Dwjoyuq2I4Dt82PN80GVK4r8aPOS7iWY0TXMEPSQ79lqpm/YsOg2DoWL XeDbEuuGhf6CiaGUsAdBCSjSDWJx0fDIWmNhL8Ee25o86rKtNvWLo7dqBdjyihQZVH2Q CTMQ== X-Gm-Message-State: AOAM530eI1gCM+bmiSpNANnnHSPAsqNaZ+Qi1VjiQVkei8p2nwWl0MLR qlhFrLj8QElx9i1NEwvEYx3Pn4yM8Tg= X-Received: by 2002:a05:6214:2428:b0:441:5f62:b8c4 with SMTP id gy8-20020a056214242800b004415f62b8c4mr12716057qvb.21.1648288048361; Sat, 26 Mar 2022 02:47:28 -0700 (PDT) Received: from localhost.localdomain ([193.203.214.57]) by smtp.gmail.com with ESMTPSA id y17-20020a05622a121100b002e0702457b2sm7106246qtx.20.2022.03.26.02.47.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 02:47:27 -0700 (PDT) From: cgel.zte@gmail.com X-Google-Original-From: yang.yang29@zte.com.cn To: paul@paul-moore.com, eparis@redhat.com, linux-audit@redhat.com Cc: linux-kernel@vger.kernel.org, Yang Yang , Zeal Robot Subject: [PATCH] audit: do a quick exit when syscall number is invalid Date: Sat, 26 Mar 2022 09:46:55 +0000 Message-Id: <20220326094654.2361956-1-yang.yang29@zte.com.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Yang Yang Userspace may use syscall with invalid syscall number by calling syscall(syscall_num,..). For example we found openSSH may use syscall with syscall number is -1 in some case. When that happens we better do a quick handle no need to gohead. Signed-off-by: Yang Yang Reported-by: Zeal Robot --- kernel/auditsc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index ea2ee1181921..806cd57d7f20 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -2077,7 +2077,8 @@ void __audit_syscall_exit(int success, long return_code) struct audit_context *context = audit_context(); if (!context || context->dummy || - context->context != AUDIT_CTX_SYSCALL) + context->context != AUDIT_CTX_SYSCALL || + unlikely(context->major < 0 || context->major > NR_syscalls)) goto out; /* this may generate CONFIG_CHANGE records */ -- 2.25.1