Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4466593ybz; Tue, 28 Apr 2020 11:46:40 -0700 (PDT) X-Google-Smtp-Source: APiQypI066atX4Gpwh0MC+9P6v5MAuFJZ3qq8hkT9x5fAHfqVynvBcpxHWGoy8km82/1UMrbSauk X-Received: by 2002:a17:906:4f03:: with SMTP id t3mr25116779eju.254.1588099600121; Tue, 28 Apr 2020 11:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588099600; cv=none; d=google.com; s=arc-20160816; b=pFwLd3Eugp97eDwYZOu9xYTIDRpE+oZbuN6DNqW0tCMac5dTR3N3xjKOH2bp7MsDbA VNTChUsKbvxQ6h0sg5+lTWlE5JiQenbNm45/2nzuuMwou3FFnjA3tajPsrU0A1hZ05Dw N7FMn4L9edbkrjwRLFKxzZ2EZsqbSHA7JY+K2FModBzJOfPBPnSKzGomMTZ0cUM8hi3V FeS814n5H2qkgnuG5y4qvbBkAAMDoWg7r3GSGuqtN41LUQQULoJHhKLrM8UvjET5GQoj 3j0xaNT6f18JboN/9Q6VfK8kowly9exSJfnCy2G62TIJlmMnArCEARITmjIksxIr6YF9 D78Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EXlnIFgrL1QhDOIenXRKZsV0r1Hk/zWM6GMtZfN09RI=; b=CdSUjTMfs5XDAPgHimElZNdC+ocGrI4l8lRyBp+2fC3VkkVk2iQNKRV8oKhT21f0Fh 1K0Pcdka/lqhccztaErzR6bsawYZxBWdixfrQpk7fGiFd0abPXLz/g82GC3cANxUZmuW SL1pEKhWxOthV4wgZ8YSNrHxwFkEanx7lTXb1/g5Ly2ZAOKOez57lLE2UeXJADyeyZaD 4E5cbqIb70asclw9KDtEiHuOF5d6FGeoV5T6exwDubmJnityM//cqZNb2WRXQPaAjWwI KSL1qHGt2cPupuZAtYAcvUnMlD37gRwlUdEWAuye9S7kX8WdkQs08Dw1zq+Ofxt+n2NE fP3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nQimQWyI; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n9si2045597edb.87.2020.04.28.11.46.16; Tue, 28 Apr 2020 11:46:40 -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; dkim=pass header.i=@kernel.org header.s=default header.b=nQimQWyI; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730617AbgD1SnA (ORCPT + 99 others); Tue, 28 Apr 2020 14:43:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:35186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731166AbgD1Sm4 (ORCPT ); Tue, 28 Apr 2020 14:42:56 -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 C67462085B; Tue, 28 Apr 2020 18:42:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588099376; bh=MfnMWtZZy4UlrU6mRR+o4ZqcxjwM4uZgbP+GXH38zyM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nQimQWyIjNO5WzZe6GUevzKFwFA4bpi0bPlh3GhKsQ6tBupqM7f8mlPelBMw1cEcw PiJQa2qjwJQ0J9pxD24DcRcaz/jz0CHoF+LHadKREB471Q3c5TmdRbJKd3A6LSzwCp RAS6Gb25B1TndSwOODBevSVOJbHMVXce2VgdlFZU= 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 5.4 124/168] audit: check the length of userspace generated audit records Date: Tue, 28 Apr 2020 20:24:58 +0200 Message-Id: <20200428182248.031809709@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200428182231.704304409@linuxfoundation.org> References: <20200428182231.704304409@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 @@ -1325,6 +1325,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(msg_type, AUDIT_FILTER_USER); if (err == 1) { /* match or error */