Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2613194pxb; Sun, 17 Oct 2021 20:31:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEya8Eblf0mx1ZlvD0j80ruFJU2uyveqg4TJIoqjQ8CrXhB5A6F4C4mfk7Tmlyp3Er8hQd X-Received: by 2002:a62:1450:0:b0:44c:7681:90b9 with SMTP id 77-20020a621450000000b0044c768190b9mr26278535pfu.42.1634527865357; Sun, 17 Oct 2021 20:31:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634527865; cv=none; d=google.com; s=arc-20160816; b=SWlWE29VR4CAgPPRDuor4I3/D+yVja+VGtnnBL7eK+zaaC8/lZWFW3Q0Jg/qMq+QRK wghmrP2UxylQm/u/+DXKah2sFf8cE7SK4Re/T/cnoX2Bs2rhYpPD7Mkj1uIn8mi4niy1 Tba+BhNzp9URL4l+ulYCVUSDeZA8h8Ai6iRNERM24vW53FvUItE3L5gQ7KWdI0cWBSVh +O+RxeOKhNIxSiTobsWUKQkCMbNawDzi+VW69d7pupazE6yoeaCbs9Dgr5uOfgXAailu 6IKEz6Dl1ZSiFP82NH6YhcZi0V3Jn+J+8ZrjoKl+rat9T6lsp7RhmrUhQijXSE7MwvvQ rgHA== 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=VD/C8WPIMqUr153i2tcb5sHzlrTVMOYcPDwgqDS+jN0=; b=I6KS4gOmlHrRDFhs0717eFQDtzkhyrqwK8r/Q+/uk7Zkk1mjcg2Togi5YnwQzYjEas EnQTCe9tGNOPgUuw4vrElScs4Wa4A4kdjExhI+RnX9w3jqQe++8jVXmcxIO2TjK/fP/3 TaUrtC1WwJUn5D8suQB03Oa46fn6SGCu0l3Bo2QIV4pUdK7w8SR94dZGdeG1v6L1BOSK 8p4MCa659+sNtfVtiUBVV3dHJ+JlAFSt0cJSNaVuXibC6mvDw4K9AR++EM8ohSOuoF7w H25YXrRa3sV1hDI23U5kmQE6Yb4vk/uJiLwvMrKhjUHLZTzAquIH19BmS1nUUZ+2IPhS 5LXg== 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 y32si20108558pgk.72.2021.10.17.20.30.53; Sun, 17 Oct 2021 20:31:05 -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 S240103AbhJPHYH (ORCPT + 98 others); Sat, 16 Oct 2021 03:24:07 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:28950 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233934AbhJPHYG (ORCPT ); Sat, 16 Oct 2021 03:24:06 -0400 Received: from dggeme762-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HWZGG6GBrzbn7S; Sat, 16 Oct 2021 15:17:26 +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; Sat, 16 Oct 2021 15:21:53 +0800 From: Gaosheng Cui To: , , CC: , , Subject: [PATCH -next,v3 1/2] audit: fix possible null-pointer dereference in audit_filter_rules Date: Sat, 16 Oct 2021 15:23:50 +0800 Message-ID: <20211016072351.237745-2-cuigaosheng1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20211016072351.237745-1-cuigaosheng1@huawei.com> References: <20211016072351.237745-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: dggems702-chm.china.huawei.com (10.3.19.179) 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 possible null-pointer dereference in audit_filter_rules. audit_filter_rules() error: we previously assumed 'ctx' could be null Fixes: bf361231c295 ("audit: add saddr_fam filter field") 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