Received: by 10.223.176.5 with SMTP id f5csp985662wra; Fri, 2 Feb 2018 09:16:03 -0800 (PST) X-Google-Smtp-Source: AH8x225Gp5OOoCz7wPYBM9BmLP/VC8ag4htB9aBjhjd4KRW96s6HKg2v7yZ8LKY/H3xvITGJDyjF X-Received: by 10.101.96.44 with SMTP id p12mr31232533pgu.390.1517591762939; Fri, 02 Feb 2018 09:16:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517591762; cv=none; d=google.com; s=arc-20160816; b=JovUIb2uYqzwO1yELQLOiM6A9/sfEWwOLSOh8UAtZkaWJ4/TqOGyzb109e+8924BPa nPmA+QWOM1/ZVfMXHWdfwZZmiX3lQNnTOC2akvvmp1VQbJdevI09x/dwrK2BT5EzsuqN Tidy2MyxAeAwUVrHoJdHKOrAfG9JDInaim93Q/u59f0tMeDBLscYodI9dayOxCL/k95o Q5zwcsECZQw4o2KI6znl4fZd1JVTy6WQgRGUK4OdigDCrMOU6UgfTW+KC1pOIcUi9IfP MVJHsd3uF0lrUoVGvVvXHQbfj8xdPFAoTBDFiofvB9Ir0Jgq8+HJB0309hq8uqq5Hy0j pLJA== 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=fwKa0CmToxr4Y2cOWIu4fIzqZPh/6ZvNh3FTsm4ki+c=; b=ztQeUda7C5l1A7geDeXCiSInVbN1jmpGh87eJetjqVr7HHxrA3SIDhnaWWrSjgCmIC u4A+p5dPJMhVRjS3XynhD18uajnScu+VKT/2vYyhTbzkZtD1aSReguwUcVrbAI36KqFh jqI/X6UcorSX2577ySGgFrnKKoEdwiCYpcZP0oArZre1roajF4UeysM+ApH81T1uPT0x CzNSCgud+u4ZEqlhkUvy8CcNl9AgUpkARRcOOfkMoaUa8NNBhOUQKI/1cawS3VE0LGFn +ECndTlr8BkC7TN6BOaek5E2BnOy+ra563RpLB0GWXSjwr/FwNBxf97XXb6PbZFhXg4r tO2A== 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 a8-v6si48949ple.375.2018.02.02.09.15.48; Fri, 02 Feb 2018 09:16:02 -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 S1753584AbeBBRON (ORCPT + 99 others); Fri, 2 Feb 2018 12:14:13 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:37096 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753163AbeBBRHk (ORCPT ); Fri, 2 Feb 2018 12:07:40 -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 24FE8EEC; Fri, 2 Feb 2018 17:07:38 +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.14 019/156] crypto: af_alg - whitelist mask and type Date: Fri, 2 Feb 2018 17:56:40 +0100 Message-Id: <20180202140841.185966767@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@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.14-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);