Received: by 10.223.185.116 with SMTP id b49csp5457333wrg; Wed, 7 Mar 2018 12:05:38 -0800 (PST) X-Google-Smtp-Source: AG47ELuHZgJGzBDbqtC6A9X9AnvR2YJgj7Jb8uFANwYPWfFysUPGURcW+S+dNuCyhzbNze9VM3Y3 X-Received: by 2002:a17:902:70c5:: with SMTP id l5-v6mr1490240plt.13.1520453138567; Wed, 07 Mar 2018 12:05:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520453138; cv=none; d=google.com; s=arc-20160816; b=jS4TGk5nRN80jKBmpD60mVsHhNu5tGEArcT4ktNN5tK/UcGDXjNcsmjnIL1OZ/nqfA Mlx3U8NohumcDo+c2CCfVdcfk0A6JdKgZ5wtPlt4DIN4mZLUhV0Ut3wG/nY4Fm4xhqmT JhJh+DoK0T3DZNWtlcrUSwn1Twzy3672JYxZ5dcF7P/OP4VKMZgcNNOOljnPMro8V4wZ gS6Y8pNqtzqMpErEev1VSG1PLsmEeg8mcNOjFcLZaVYNxWsfe7gon7nrF6CxpKU+Mivm /U2VTxSUdfjuR8KI9YJxoBG9LGzjZ7pioBoPcJH9fP/wP8eKz4OeuIvxu9LQNetuX8xj u6SA== 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=l3yor8ElAUnYnsC+LzEseIhyMT5DRsKnRORZm6nAChc=; b=fmEzKL5HmXARG4xKzIt0ex/I9SyZ9AOPX5k9h/0g111mh2U2cuW+B2skpEppyd2pYw 9/BCxJbI1NmfsUAPqMh8+epIxCg+fZ4x1HgoFSR9CYcFL8kC/QPk3EAHIHctIGBcQLct ANQuG094HBXL6FkfITVedOF3dWY/M5vUr4j9cqPTuMzCUAtEQMpCu3Yg5ovwHHaFJ00L fcIzJzLrX5JkJVQFxI28LK3oUCvQ9GqiLxMHz+yg4nxzI4A1nU1wJWsq3iqfjv8M6i+N osYfJbigon8w9+R55uO/PBiP0WUo/52jgjHtABSOrhB8lT2wAIqH2iVe9Lt/nDrmiJ4D Hv5g== 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 l18si11767423pgn.103.2018.03.07.12.05.23; Wed, 07 Mar 2018 12:05:38 -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 S965516AbeCGTqT (ORCPT + 99 others); Wed, 7 Mar 2018 14:46:19 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:44528 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965465AbeCGTqR (ORCPT ); Wed, 7 Mar 2018 14:46:17 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 60B5A1032; Wed, 7 Mar 2018 19:46:16 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Richard Fitzgerald , Takashi Iwai Subject: [PATCH 4.14 011/110] ALSA: control: Fix memory corruption risk in snd_ctl_elem_read Date: Wed, 7 Mar 2018 11:37:54 -0800 Message-Id: <20180307191041.187154835@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180307191039.748351103@linuxfoundation.org> References: <20180307191039.748351103@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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: Richard Fitzgerald commit 5a23699a39abc5328921a81b89383d088f6ba9cc upstream. The patch "ALSA: control: code refactoring for ELEM_READ/ELEM_WRITE operations" introduced a potential for kernel memory corruption due to an incorrect if statement allowing non-readable controls to fall through and call the get function. For TLV controls a driver can omit SNDRV_CTL_ELEM_ACCESS_READ to ensure that only the TLV get function can be called. Instead the normal get() can be invoked unexpectedly and as the driver expects that this will only be called for controls <= 512 bytes, potentially try to copy >512 bytes into the 512 byte return array, so corrupting kernel memory. The problem is an attempt to refactor the snd_ctl_elem_read function to invert the logic so that it conditionally aborted if the control is unreadable instead of conditionally executing. But the if statement wasn't inverted correctly. The correct inversion of if (a && !b) is if (!a || b) Fixes: becf9e5d553c2 ("ALSA: control: code refactoring for ELEM_READ/ELEM_WRITE operations") Signed-off-by: Richard Fitzgerald Cc: Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/core/control.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/sound/core/control.c +++ b/sound/core/control.c @@ -888,7 +888,7 @@ static int snd_ctl_elem_read(struct snd_ index_offset = snd_ctl_get_ioff(kctl, &control->id); vd = &kctl->vd[index_offset]; - if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_READ) && kctl->get == NULL) + if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_READ) || kctl->get == NULL) return -EPERM; snd_ctl_build_ioff(&control->id, kctl, index_offset);