Received: by 10.223.176.5 with SMTP id f5csp997060wra; Fri, 2 Feb 2018 09:26:53 -0800 (PST) X-Google-Smtp-Source: AH8x226Eg9ZNFqQCyZvUv1D87Xs0ftQOYowXyoLu5+sggLYa3rc1PxXJMujQa2na24D75fECQ15S X-Received: by 10.99.125.13 with SMTP id y13mr31622707pgc.282.1517592412998; Fri, 02 Feb 2018 09:26:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517592412; cv=none; d=google.com; s=arc-20160816; b=MyhDZCSy7P3prs5phRjvUUc1EQmYWgpkdrtn+35yaxwz0P7bhYI5HBCeZlXcJhETBp yy30HnQsAYaBzcYdtP386YRppSUbOpyG3ZEC3aCUGP8gB5PbV7wMV5Fq5ZyPv3GolgG3 qMnBU5ZYfDLPaMPep4b9uCZgEy0k0P6iB+bLLRekZUygg3Y5Tksx7ugFc2WJ/DefoKCC wTNvPyJ5QlnejmM+lJUSckBeBpOLQ5dmc6khmVKk2TJ3vWOrU5qUOIyO+gpmSa8YYatL LC4eG9udbpBvLeGuMzWa9xJRoOojDowMuoZWS5O2GZldPYSs1f1mASznEdSWlTn/fZaW 2yJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=FjVij3vwgHk86QgU8Fto7I0W7WHm4jJB7RdMG68BZ/A=; b=XuZdv/HL3LFHTlUNaq03yIL/Bwp3Xc0KRVlc+0bAHYO/a8Yr+BIqTbm+O5FcxKGKPI wF+3pL/ANBTmqpmx2+NjFs0WFHTfnsG90z7VzssKz3ULG6LVwu7RV8DTVbTQavnIeprd k907NVyoeGdM2ByY2w1FPrsLpWdK6J3mk4QcLBuTYAwwugvts9bC8rpVTMEgf1wZfUa9 hWY/65IDxPcE4vNsGjOQJnHWrm1uB3qKPzWqZ7NCNRR13B86Dqlk7rDsWbcI/o4a7ESc 6JruNRhOM3wHVS63gko2PKE8MIVfJtbLafbVk4ODEJqpkQWRhKXU8v2++niYHDa1Izbq M7Mw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6-v6si91836plr.802.2018.02.02.09.26.38; Fri, 02 Feb 2018 09:26:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754115AbeBBRZ3 (ORCPT + 99 others); Fri, 2 Feb 2018 12:25:29 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40646 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753698AbeBBRPB (ORCPT ); Fri, 2 Feb 2018 12:15:01 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 200B3D81; Fri, 2 Feb 2018 17:14:59 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Stephan Mueller , Herbert Xu Subject: [PATCH 4.15 15/55] crypto: af_alg - whitelist mask and type Date: Fri, 2 Feb 2018 17:58:33 +0100 Message-Id: <20180202140827.628846872@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140826.117602411@linuxfoundation.org> References: <20180202140826.117602411@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stephan Mueller commit bb30b8848c85e18ca7e371d0a869e94b3e383bdf upstream. The user space interface allows specifying the type and mask field used to allocate the cipher. Only a subset of the possible flags are intended for user space. Therefore, white-list the allowed flags. In case the user space caller uses at least one non-allowed flag, EINVAL is returned. Reported-by: syzbot Signed-off-by: Stephan Mueller Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- crypto/af_alg.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -150,7 +150,7 @@ EXPORT_SYMBOL_GPL(af_alg_release_parent) static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) { - const u32 forbidden = CRYPTO_ALG_INTERNAL; + const u32 allowed = CRYPTO_ALG_KERN_DRIVER_ONLY; struct sock *sk = sock->sk; struct alg_sock *ask = alg_sk(sk); struct sockaddr_alg *sa = (void *)uaddr; @@ -158,6 +158,10 @@ static int alg_bind(struct socket *sock, void *private; int err; + /* If caller uses non-allowed flag, return error. */ + if ((sa->salg_feat & ~allowed) || (sa->salg_mask & ~allowed)) + return -EINVAL; + if (sock->state == SS_CONNECTED) return -EINVAL; @@ -176,9 +180,7 @@ static int alg_bind(struct socket *sock, if (IS_ERR(type)) return PTR_ERR(type); - private = type->bind(sa->salg_name, - sa->salg_feat & ~forbidden, - sa->salg_mask & ~forbidden); + private = type->bind(sa->salg_name, sa->salg_feat, sa->salg_mask); if (IS_ERR(private)) { module_put(type->owner); return PTR_ERR(private);