]> 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)
committerPaul Moore <paul@paul-moore.com>
Mon, 18 Oct 2021 22:27:47 +0000 (18:27 -0400)
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: bf361231c295 ("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>
kernel/auditsc.c

index 8dd73a64f9216a294822540436d72193e66bfedf..b1cb1dbf7417f0a02849aea33ed3f1c3444a5a08 100644 (file)
@@ -657,7 +657,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;