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 X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6430C47253 for ; Fri, 1 May 2020 13:26:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B53782166E for ; Fri, 1 May 2020 13:26:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588339608; bh=DTGMImZJ7jUD9f8TAsQZWCyL6EtzNSwatzM2gU3fHMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=cIThLc/E3dXx4gRxZ5lW5J7F/Hr2uYcL3IiEHbRKxIxtbE9Pvnr/3GNpX8+V5PRBY 9dAL0kT8R8rQBFulb8qIfjg4WomkG3h9V97h99o8BaC7wDD13Ob0wF9Eh+Jvnvp6a3 V+GTAxmO0Xa/NjWayDhvEmnfmDXCV3j4fnLnlDTU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729346AbgEAN0s (ORCPT ); Fri, 1 May 2020 09:26:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:48636 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729330AbgEAN0q (ORCPT ); Fri, 1 May 2020 09:26:46 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3FEFF20757; Fri, 1 May 2020 13:26:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588339605; bh=DTGMImZJ7jUD9f8TAsQZWCyL6EtzNSwatzM2gU3fHMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KltfDJypKk7QlNWzlO8JaOmDIde4Lz0DaUUDzkIEpiQVSiH94sBRBANiUg2fWX3Kf LoOchQ5y9WKbB8pRYnie4pXiPLeT6UE0cBb8eqgJWr9I0Y78dZk4C81KZP2L6+Ce4p e1dGwV22zCPqE3RH7h2DcsZ9NOxiSZou98rRyVPw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+49e69b4d71a420ceda3e@syzkaller.appspotmail.com, Paul Moore Subject: [PATCH 4.4 44/70] audit: check the length of userspace generated audit records Date: Fri, 1 May 2020 15:21:32 +0200 Message-Id: <20200501131527.057140108@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200501131513.302599262@linuxfoundation.org> References: <20200501131513.302599262@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paul Moore commit 763dafc520add02a1f4639b500c509acc0ea8e5b upstream. Commit 756125289285 ("audit: always check the netlink payload length in audit_receive_msg()") fixed a number of missing message length checks, but forgot to check the length of userspace generated audit records. The good news is that you need CAP_AUDIT_WRITE to submit userspace audit records, which is generally only given to trusted processes, so the impact should be limited. Cc: stable@vger.kernel.org Fixes: 756125289285 ("audit: always check the netlink payload length in audit_receive_msg()") Reported-by: syzbot+49e69b4d71a420ceda3e@syzkaller.appspotmail.com Signed-off-by: Paul Moore Signed-off-by: Greg Kroah-Hartman --- kernel/audit.c | 3 +++ 1 file changed, 3 insertions(+) --- a/kernel/audit.c +++ b/kernel/audit.c @@ -919,6 +919,9 @@ static int audit_receive_msg(struct sk_b case AUDIT_FIRST_USER_MSG2 ... AUDIT_LAST_USER_MSG2: if (!audit_enabled && msg_type != AUDIT_USER_AVC) return 0; + /* exit early if there isn't at least one character to print */ + if (data_len < 2) + return -EINVAL; err = audit_filter_user(msg_type); if (err == 1) { /* match or error */