]> git.baikalelectronics.ru Git - kernel.git/commitdiff
audit: fix possible null-pointer dereference in audit_filter_rules
authorGaosheng Cui <cuigaosheng1@huawei.com>
Sat, 16 Oct 2021 07:23:50 +0000 (15:23 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Oct 2021 07:54:27 +0000 (09:54 +0200)
commit 6e3ee990c90494561921c756481d0e2125d8b895 upstream.

Fix  possible null-pointer dereference in audit_filter_rules.

audit_filter_rules() error: we previously assumed 'ctx' could be null

Cc: stable@vger.kernel.org
Fixes: b884a08ea1c7 ("audit: add saddr_fam filter field")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/auditsc.c

index 4effe01ebbe2b3ad1e0d5cf566909db533dcb610..d33c5dccde1c710c37d14aff0a78fc252329495e 100644 (file)
@@ -624,7 +624,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;