From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD6F1C433F5 for ; Wed, 13 Oct 2021 21:16:55 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 565C961152 for ; Wed, 13 Oct 2021 21:16:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 565C961152 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=paul-moore.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-164-M__UpeWPO8ivIz7GnzIDNQ-1; Wed, 13 Oct 2021 17:16:50 -0400 X-MC-Unique: M__UpeWPO8ivIz7GnzIDNQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9918A1966320; Wed, 13 Oct 2021 21:16:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A1B5A694B4; Wed, 13 Oct 2021 21:16:46 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8D31B1800FE4; Wed, 13 Oct 2021 21:16:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19DLCq4u029390 for ; Wed, 13 Oct 2021 17:12:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 784F6400E410; Wed, 13 Oct 2021 21:12:52 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74447400F3FA for ; Wed, 13 Oct 2021 21:12:52 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5BED218A01AF for ; Wed, 13 Oct 2021 21:12:52 +0000 (UTC) Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-503-yR5BI3adP8iAP8g2hhQazA-1; Wed, 13 Oct 2021 17:12:50 -0400 X-MC-Unique: yR5BI3adP8iAP8g2hhQazA-1 Received: by mail-ed1-f52.google.com with SMTP id w19so15840677edd.2 for ; Wed, 13 Oct 2021 14:12:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=i1LgKY9ubJwkEIHDGsg63hyGpmKH47suPVaXuM2S3ec=; b=Ba3Dpk0k4RgbrGxlLAkLG7ABqcVdue9wZ6+IbG9s4BWJyZU3KxZ7HQrIDpJBfWMGHH lWtgnwWUWUgwPJkqUyiJ07vR/AhykzcX0VDu91RRc26ZoU2qN4IlgHjzt+z+yByFI8+m kogvQHf1Ezf4j1eSTeau+2xs1SwkWYDjYIQWSFyv06j8i1ePabb7rKuz16oLgXGa+ny8 eNEv2jJQZ5VX0mMBpQYzB8ZQ+1U1CKWU33L6vHI/m1Cr0VlJewsm7keHNtDVw5dip/3F UXgNI3DjGBlhORkiykK7czex80H3L/RyY5ZVdAvdMQ9YAkiqjpLByaiBM8GEDWcYFaqf U8uw== X-Gm-Message-State: AOAM532nD4ffH7vjaRswDAhddXLG2hYLmH2PCY1wHYhLsnE40OMve/Zp V5tTms7NL4nemmFmjyeKl19B6jiWdKkUqMt0xyyi X-Google-Smtp-Source: ABdhPJyAiWQXGQhIqSy4BRdxxSMzu4wtimoLcUmCiwhwOPD13Peavb3ClTRn5qpYIdmr7XV6U9ZqUK9coskHkfzuO+o= X-Received: by 2002:a17:906:d975:: with SMTP id rp21mr1923350ejb.104.1634159569393; Wed, 13 Oct 2021 14:12:49 -0700 (PDT) MIME-Version: 1.0 References: <20211013091208.36209-1-cuigaosheng1@huawei.com> <20211013091208.36209-2-cuigaosheng1@huawei.com> In-Reply-To: <20211013091208.36209-2-cuigaosheng1@huawei.com> From: Paul Moore Date: Wed, 13 Oct 2021 17:12:38 -0400 Message-ID: Subject: Re: [PATCH -next, v2 1/2] audit: fix possible null-pointer dereference in audit_filter_rules To: Gaosheng Cui X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-loop: linux-audit@redhat.com Cc: xiujianfeng@huawei.com, wangweiyang2@huawei.com, linux-audit@redhat.com, linux-kernel@vger.kernel.org, Eric Paris X-BeenThere: linux-audit@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Linux Audit Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=linux-audit-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Wed, Oct 13, 2021 at 5:10 AM Gaosheng Cui wrote: > > Fix this possible null-pointer dereference in audit_filter_rules. Thanks for fixing this, just a couple of small comments: I think you can drop the description text below here, the code snippet is just a duplicate of the code and the error message is pretty obvious. > 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 I would also add a Fixes tag, for example: Fixes: bf361231c295 ("audit: add saddr_fam filter field") > --- > 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 -- paul moore www.paul-moore.com -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit