From patchwork Tue Jun 16 15:35:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 224452 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,URIBL_BLOCKED,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 74CE0C433DF for ; Tue, 16 Jun 2020 15:54:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D93321534 for ; Tue, 16 Jun 2020 15:54:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592322887; bh=L+ZIDbk7gGh2d8y06TrWjfNNB4BOtBVD11yTKaLw7C0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=M/mB/D9WJ8QOxfT6WEnFXxIYJnnQJUhOL6vyxPHuOP4Or7Mpc+ebXXEXtkfU5xk7G hSiYUoU/FnO4+/j6OuAV7vAWA1iZefR7eNc9tnO9tYuI/odxojJ26HSSy1BuLN4myJ kLPpKuOR/AIRaEsz59lUrfvIDoGnbp1eDWWwD2Vc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732803AbgFPPyp (ORCPT ); Tue, 16 Jun 2020 11:54:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:54260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733014AbgFPPyo (ORCPT ); Tue, 16 Jun 2020 11:54:44 -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 1E54721527; Tue, 16 Jun 2020 15:54:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592322884; bh=L+ZIDbk7gGh2d8y06TrWjfNNB4BOtBVD11yTKaLw7C0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nf0CsbjUrp8oikgkxoYvsi6MUaqkst1KCZym0OrMD3+XOmVhBPyd8L6Sscn8UVmyM kvj9HyIQHOMp1vsBjmN0gouW+FRObdHsVRrnyxaKBK/8PKgLUV5uqx2GfFKFGLvjJe Ro9gTM1DKGue4MH4uRSu8KFFLokVKFqf/OfHtNvo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hillf Danton , syzbot+bfdd4a2f07be52351350@syzkaller.appspotmail.com, Casey Schaufler Subject: [PATCH 5.6 142/161] Smack: slab-out-of-bounds in vsscanf Date: Tue, 16 Jun 2020 17:35:32 +0200 Message-Id: <20200616153113.123932358@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200616153106.402291280@linuxfoundation.org> References: <20200616153106.402291280@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Casey Schaufler commit 84e99e58e8d1e26f04c097f4266e431a33987f36 upstream. Add barrier to soob. Return -EOVERFLOW if the buffer is exceeded. Suggested-by: Hillf Danton Reported-by: syzbot+bfdd4a2f07be52351350@syzkaller.appspotmail.com Signed-off-by: Casey Schaufler Signed-off-by: Greg Kroah-Hartman --- security/smack/smackfs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/security/smack/smackfs.c +++ b/security/smack/smackfs.c @@ -878,11 +878,21 @@ static ssize_t smk_set_cipso(struct file else rule += strlen(skp->smk_known) + 1; + if (rule > data + count) { + rc = -EOVERFLOW; + goto out; + } + ret = sscanf(rule, "%d", &maplevel); if (ret != 1 || maplevel > SMACK_CIPSO_MAXLEVEL) goto out; rule += SMK_DIGITLEN; + if (rule > data + count) { + rc = -EOVERFLOW; + goto out; + } + ret = sscanf(rule, "%d", &catlen); if (ret != 1 || catlen > SMACK_CIPSO_MAXCATNUM) goto out;