Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp3752651imd; Mon, 29 Oct 2018 11:48:41 -0700 (PDT) X-Google-Smtp-Source: AJdET5fhD7pAXczxY3ELmDgRMpKcLGg6BnseAA7xnhrl2BvCf9le9YsP33GyyZxI7I2pi0UKddxb X-Received: by 2002:a17:902:6a83:: with SMTP id n3-v6mr15623498plk.288.1540838921855; Mon, 29 Oct 2018 11:48:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540838921; cv=none; d=google.com; s=arc-20160816; b=R9CFsuL9h3Sb4hfV+QJmUKpg7tRyB4Sfiy2V1ObJweWbsSSL/z1e+uVwjG8y0jAWUx EoyJhs/1VafaV30QDUI4662ihDYpjVnboj+Vj/INCAs/jo7OLwXw7a7uvKPzk5NXMbDF qpfz1vdsDk0nNL8n6qnQsbqs2uPfI+3j0Tgs8kN0UuPF2T6yOR0Q3wHxmFbCNZ54XwT1 BSxvOWnMQDJ9fbQQ/9kMe/atNTXHxFCdIe3BXXcCzKK6JfwY7AnrR4g3iZ6BscQxqQCy 03XLbx3SWBJebZRxKCeCXDgvyJqeRtM9QJyyxynXRLv/AM5GM9Ukfb7EIJCIwu67lKjc jdVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=3X+HqPUFjx0dwJT65B43YyoJ642UMI7QVxI+JZVhm3Y=; b=TkVmS0zt8AaPVLFtrS/41sYgA3Xap7fj2cARYQOTpABstTunZ3Ye9Er2L8krFMTAoQ ErVoWaREhZoXHJvLs4ElTJdsEGYJWeHgEUsLITTLWHGW97f32pXJJG7XSNo5RTSbnAMg kQqGBXQ+MpGLkUstoi3gQ/Lc/ukJzct1zSpWT8/N1EvR7Qk8VnCt7VZZyWYyfnieH8MC A9PnlcDfmJHAiajipsoZJszoZl98kNdKBJmJq9sauo7jZvSAXioLOKHGZBKB97Mz8wjE TuaxNwHNajJ3XZ1fDRl6DRsjBE/yIfok9Dk9qa5nyxJiEzHBeJuuCuBzqxvHOduQnTo0 pCow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umn.edu header.s=20160920 header.b=uKRCrLkb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umn.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z7-v6si21012344pgc.343.2018.10.29.11.48.25; Mon, 29 Oct 2018 11:48:41 -0700 (PDT) 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; dkim=pass header.i=@umn.edu header.s=20160920 header.b=uKRCrLkb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umn.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729425AbeJ3Dgi (ORCPT + 99 others); Mon, 29 Oct 2018 23:36:38 -0400 Received: from mta-p4.oit.umn.edu ([134.84.196.204]:57382 "EHLO mta-p4.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726036AbeJ3Dgi (ORCPT ); Mon, 29 Oct 2018 23:36:38 -0400 Received: from localhost (localhost [127.0.0.1]) by mta-p4.oit.umn.edu (Postfix) with ESMTP id 6B15E6F2; Mon, 29 Oct 2018 18:46:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=umn.edu; h= content-type:content-type:subject:subject:message-id:date:date :from:from:in-reply-to:references:mime-version:received:received :received; s=20160920; t=1540838802; x=1542653203; bh=DnRnVqmnS/ 3YdV0iCc5SQhIbdjGxM82O3DdnjbdOpqI=; b=uKRCrLkb3YFu3xJwuL0K79HuSx 2oz6DhovsrEN9zUsMKv3WfLQOYmiPcjOX/4zEE/omI/0Sj/p1Q4KcjiW9Ua8I7xd KfzyB/97NcSH54UWWp97ejwJbQcFEH+TnDLXi9DDRJpy2AOa6b8HryX7uu8HUSWj rHnpMie8C3uBHzEhkOOYsKRtWkYvHKxHH0krfIOrxUwOz0JAQFTxTAWM0Tyl5/bp EBcFAocB1iA/g3TvX4zkg3HlB1dXb1axVeXxYOmuET2vs3pr5mdyP4tCzo2X4fAJ MmGhD3xHseLnLwrCPJ4DLIDdfNXwbsgWEygeHhxF+1ygxCPYkQc+obgtG04Q== X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p4.oit.umn.edu ([127.0.0.1]) by localhost (mta-p4.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NeJYn5-5cKO2; Mon, 29 Oct 2018 13:46:42 -0500 (CDT) Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.41]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: wang6495) by mta-p4.oit.umn.edu (Postfix) with ESMTPSA id 4BD6E6E8; Mon, 29 Oct 2018 13:46:42 -0500 (CDT) Received: by mail-io1-f41.google.com with SMTP id y22-v6so5634720ioj.13; Mon, 29 Oct 2018 11:46:42 -0700 (PDT) X-Gm-Message-State: AGRZ1gKNZ6qAMkMSOoNgkb+EFtuI9b13BSML51QnlVG5TI89AzIGYFIs CRkUb3iXlJEz4/aGjvn34nFv2p0s5KCO/mx2YVk= X-Received: by 2002:a5e:dd4d:: with SMTP id u13-v6mr9408706iop.62.1540838802038; Mon, 29 Oct 2018 11:46:42 -0700 (PDT) MIME-Version: 1.0 References: <1539958334-11531-1-git-send-email-wang6495@umn.edu> In-Reply-To: <1539958334-11531-1-git-send-email-wang6495@umn.edu> From: Wenwen Wang Date: Mon, 29 Oct 2018 13:46:04 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] media: dvb: fix a missing-check bug To: Wenwen Wang Cc: Kangjie Lu , Mauro Carvalho Chehab , viro@zeniv.linux.org.uk, "open list:STAGING - ATOMISP DRIVER" , open list 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 Hello, Can anyone confirm this bug? Thanks! Wenwen On Fri, Oct 19, 2018 at 9:12 AM Wenwen Wang wrote: > > In dvb_audio_write(), the first byte of the user-space buffer 'buf' is > firstly copied and checked to see whether this is a TS packet, which always > starts with 0x47 for synchronization purposes. If yes, ts_play() will be > called. Otherwise, dvb_aplay() will be called. In ts_play(), the content of > 'buf', including the first byte, is copied again from the user space. > However, after the copy, no check is re-enforced on the first byte of the > copied data. Given that 'buf' is in the user space, a malicious user can > race to change the first byte after the check in dvb_audio_write() but > before the copy in ts_play(). Through this way, the user can supply > inconsistent code, which can cause undefined behavior of the kernel and > introduce potential security risk. > > This patch adds a necessary check in ts_play() to make sure the first byte > acquired in the second copy contains the expected value. Otherwise, an > error code EINVAL will be returned. > > Signed-off-by: Wenwen Wang > --- > drivers/media/pci/ttpci/av7110_av.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/media/pci/ttpci/av7110_av.c b/drivers/media/pci/ttpci/av7110_av.c > index ef1bc17..1ff6062 100644 > --- a/drivers/media/pci/ttpci/av7110_av.c > +++ b/drivers/media/pci/ttpci/av7110_av.c > @@ -468,6 +468,8 @@ static ssize_t ts_play(struct av7110 *av7110, const char __user *buf, > } > if (copy_from_user(kb, buf, TS_SIZE)) > return -EFAULT; > + if (kb[0] != 0x47) > + return -EINVAL; > write_ts_to_decoder(av7110, type, kb, TS_SIZE); > todo -= TS_SIZE; > buf += TS_SIZE; > -- > 2.7.4 >