Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3255851pxb; Wed, 13 Oct 2021 02:11:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygg2nSDtWlnJMy8WMxIEzBKbs+ZC4KBCS63dfUQvFiG6vgVmzMHSOerTJBEIVixhXZDQu4 X-Received: by 2002:a62:31c5:0:b0:447:cd37:61f8 with SMTP id x188-20020a6231c5000000b00447cd3761f8mr36822445pfx.29.1634116314634; Wed, 13 Oct 2021 02:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634116314; cv=none; d=google.com; s=arc-20160816; b=bASqjig7E65RpfkSaIr1c19qkob2wEF+KbwEZh1KputOhHkmWb2DJSAB+wuX5q9B/c /xh1bl22D2QtKr7M5A3dvD0SZkxONX7I7vKqvKHarOH9VFO64A6Tc+CnudefHf+F/TTc AqeeEkNxGN2BTInJ42ydfOMM5xQ7sKq6ULuWtmdsMt4yQFw/gm0k7RCd25mHT2bpyMPG 4InqITWYF1AD7AH09KEACdXMP2ObOBzZU5bNknz5QjQuO4ww3WTqEcmKHkkg/awKJxXA DOs+nnSpgT+a1ktFrTwAZvYXiU5sWeGSAt7ZKeS2yGRMamQ3xwqA8i/jUpSfhmkjBtCn 2KzQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=FzCi8RWZvfyMCFW+yI/R8BrbnrLuGwyTLAiGQezq5NI=; b=ItQSwfLySOb2Zn2HTKymx5ufwWwDcS2Jy02O4UtjcZvuDytqzhVdzbiOs9D4o+PwI7 zFOgKEXdW5Ev41e6tjwWp+vS9X2vj6cnWTfJA1kS3q6FcM9ZiWKqv3rE9eYPH1x574Q0 epau4eeIEFlQ3lU03tFAwqlUYfaKM68MNbAhOHMm03WiEMEAigWh7AO2IwAmz3TahC+F vpGhIv+54S/3t517DQ/USVo9UJ5wbLQ2U9daMczmadd0Q+0INje2jo8HdLI+MPwAReku tqIvESUwybEUSPM9tydlToSLD6QPXBlUOD2sbbE3r0frprb3yisBGNm18hIgNc29Wo6U Vtqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t19si18741372pgu.235.2021.10.13.02.11.41; Wed, 13 Oct 2021 02:11:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238942AbhJMJMQ (ORCPT + 99 others); Wed, 13 Oct 2021 05:12:16 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:25180 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238960AbhJMJMM (ORCPT ); Wed, 13 Oct 2021 05:12:12 -0400 Received: from dggeme762-chm.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4HTmtP3Gs3z8tZj; Wed, 13 Oct 2021 17:09:01 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.44) by dggeme762-chm.china.huawei.com (10.3.19.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Wed, 13 Oct 2021 17:10:08 +0800 From: Gaosheng Cui To: , CC: , , , Subject: [PATCH -next,v2 1/2] audit: fix possible null-pointer dereference in audit_filter_rules Date: Wed, 13 Oct 2021 17:12:07 +0800 Message-ID: <20211013091208.36209-2-cuigaosheng1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20211013091208.36209-1-cuigaosheng1@huawei.com> References: <20211013091208.36209-1-cuigaosheng1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.174.44] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggeme762-chm.china.huawei.com (10.3.19.108) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix this possible null-pointer dereference in audit_filter_rules. If ctx is null, a null-pointer dereference will occur: case AUDIT_SADDR_FAM: if (ctx->sockaddr) ... break; audit_filter_rules() error: we previously assumed 'ctx' could be null Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Gaosheng Cui --- kernel/auditsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 4ba3b8573ff4..42d4a4320526 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -647,7 +647,7 @@ static int audit_filter_rules(struct task_struct *tsk, result = audit_comparator(audit_loginuid_set(tsk), f->op, f->val); break; case AUDIT_SADDR_FAM: - if (ctx->sockaddr) + if (ctx && ctx->sockaddr) result = audit_comparator(ctx->sockaddr->ss_family, f->op, f->val); break; -- 2.30.0