Public bug reported:

There asynchronous buffer for the COMEDI drivers is only 65k and is hard coded 
in the kernel. With slower computers and slow userspace programs there is 
virtually always a buffer overflow which makes it impossible to run these 
programs, especially with DAQ cards which have a high resolution or those with 
high sampling rate.
I'm attaching a patch which has been submitted and accepted upstream. Below the 
confirmation e-mail from Gregkh:

Return-Path: <gre...@linuxfoundation.org>
Delivered-To: berndp...@f2s.com
Envelope-To: berndp...@f2s.com
Received: (qmail 39856 invoked from network); 13 Apr 2012 18:20:21 -0000
Received: from as001.apm-internet.net (85.119.248.19)
  by mail003.apm-internet.net with SMTP; 13 Apr 2012 18:20:21 -0000
Received: (qmail 73709 invoked from network); 13 Apr 2012 18:20:20 -0000
X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on
        as001.apm-internet.net
X-Spam-Score: -0.1
X-Spam-Report: 
        * -0.1 SPF_PASS SPF database pass
X-Spam-Relay-Country: GB GB US US
Received: from av002.apm-internet.net (85.119.248.59)
  by as001.apm-internet.net with SMTP; 13 Apr 2012 18:20:20 -0000
Received: (qmail 98427 invoked from network); 13 Apr 2012 18:20:20 -0000
X-AV-Scan: clean
Received: from relay004.apm-internet.net (85.119.248.7)
  by av002.apm-internet.net with SMTP; 13 Apr 2012 18:20:20 -0000
Received: (qmail 73444 invoked from network); 13 Apr 2012 18:20:19 -0000
Received: from mail-pb0-f41.google.com (209.85.160.41)
  by relay004.apm-internet.net with ESMTPS (RC4-SHA encrypted); 13 Apr 2012 
18:20:20 -0000
X-APM-IP: 209.85.160.41
X-APM-Score: -2
Received-SPF: pass (relay004.apm-internet.net: SPF record at _spf.google.com 
designates 209.85.160.41 as permitted sender)
Received: by pbcup15 with SMTP id up15so3700835pbc.28
        for <berndp...@f2s.com>; Fri, 13 Apr 2012 11:20:17 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=subject:to:from:date:message-id:mime-version:content-type
         :content-transfer-encoding:x-gm-message-state;
        bh=F0mM6Wrc1iIO+RcwOJc25lkJE4nAd4Fgxj+5MCNNxDU=;
        b=SeejiQ22iVQnt8WizuUPzUg9VqmG1DLqH6nB5r3Xcc90PcIxRvsAjMs9/bykNbv1ol
         lM4/AfL+un7p/R5P1Yv5GcRg8YWaocDMcsFyrTWaMx3BPonEkXK4WT1Lhw+IBiydEIpo
         3DLcTivSmAep8yiqfMx4zB+jn4jRyKwNLL5hfYi//YOLAMjKpLFqmMP6G5Dlc/Kp9PTf
         s27/qyU/uX6wk6PHs4tjmvmX+pV5zcQa77U1CDSoCtj90qJsIwtrODVsqPvh9ZqBD6Mv
         OR/bRYcKKlMGYYmtnMVs3sp+znE0ZCkXnhlPIVZqy7+rV5K3IpQP14tRgdIZdS8u4FNK
         VqJw==
Received: by 10.68.132.36 with SMTP id or4mr6543286pbb.115.1334341217157;
        Fri, 13 Apr 2012 11:20:17 -0700 (PDT)
Return-Path: <gre...@linuxfoundation.org>
Received: from localhost (c-67-168-183-230.hsd1.wa.comcast.net. 
[67.168.183.230])
        by mx.google.com with ESMTPS id vh10sm9365834pbc.29.2012.04.13.11.20.15
        (version=TLSv1/SSLv3 cipher=OTHER);
        Fri, 13 Apr 2012 11:20:16 -0700 (PDT)
Subject: patch "staging: comedi: Add kernel config for default buffer sizes" 
added to staging tree
To: abbo...@mev.co.uk,berndp...@f2s.com,gre...@linuxfoundation.org
From: <gre...@linuxfoundation.org>
Date: Fri, 13 Apr 2012 11:20:08 -0700
Message-ID: <13343412082...@kroah.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=ASCII
Content-Transfer-Encoding: 8bit
X-Gm-Message-State: 
ALoCoQlEvqUZ2Xtd66ofDeuWg5qV6v8uW82oXq3rGRQDbKuADvj2uoIK3rhnUuQ/d7ByKS81LT8s


This is a note to let you know that I've just added the patch titled

    staging: comedi: Add kernel config for default buffer sizes

to my staging git tree which can be found at
    git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-next branch.

The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)

The patch will also will be merged in the next major kernel release
during the merge window.

If you have any questions about this process, please let me know.


>From 234bb3c60f1f1489630750aba4adf40154e0bd70 Mon Sep 17 00:00:00 2001
From: Ian Abbott <abbo...@mev.co.uk>
Date: Fri, 13 Apr 2012 14:12:54 +0100
Subject: staging: comedi: Add kernel config for default buffer sizes

Allow the default values for the module parameters for the default
initial buffer size and default maximum buffer size to be specified in
the kernel configuration.

I'm not sure what the defaults for the defaults for the defaults should
be, but 64 KiB seems to small, so I used values suggested by Bernd Porr,
which are 2048 KiB for the default initial buffer size and 20480 for the
default maximum buffer size.

Signed-off-by: Ian Abbott <abbo...@mev.co.uk>
Cc: Bernd Porr <berndp...@f2s.com>
Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>
---
 drivers/staging/comedi/Kconfig       |   20 ++++++++++++++++++++
 drivers/staging/comedi/comedi_fops.c |   12 +++++-------
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index 9037d02..a1cf0b0 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -14,6 +14,26 @@ config COMEDI_DEBUG
          This is an option for use by developers; most people should
          say N here. This enables comedi core and driver debugging.
 
+config COMEDI_DEFAULT_BUF_SIZE_KB
+       int "Comedi default initial asynchronous buffer size in KiB"
+       default "2048"
+       depends on COMEDI != n
+       ---help---
+         This is the default asynchronous buffer size which is used for
+         commands running in the background in kernel space.  This
+         defaults to 2048 KiB of memory so that a 16 channel card
+         running at 10 kHz has of 2-4 seconds of buffer.
+
+config COMEDI_DEFAULT_BUF_MAXSIZE_KB
+       int "Comedi default maximum asynchronous buffer size in KiB"
+       default "20480"
+       depends on COMEDI != n
+       ---help---
+         This is the default maximum asynchronous buffer size which can
+         be requested by a userspace program without root privileges.
+         This is set to 20480 KiB so that a fast I/O card with 16
+         channels running at 100 kHz has 2-4 seconds of buffer.
+
 menuconfig COMEDI_MISC_DRIVERS
        tristate "Comedi misc drivers"
        depends on COMEDI
diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index ef7bbe4..3222ac6 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -55,9 +55,6 @@ MODULE_AUTHOR("http://www.comedi.org";);
 MODULE_DESCRIPTION("Comedi core module");
 MODULE_LICENSE("GPL");
 
-#define DEFAULT_BUF_MAXSIZE_KB 64
-#define DEFAULT_BUF_SIZE_KB 64
-
 #ifdef CONFIG_COMEDI_DEBUG
 int comedi_debug;
 EXPORT_SYMBOL(comedi_debug);
@@ -78,17 +75,18 @@ MODULE_PARM_DESC(comedi_num_legacy_minors,
                 "number of comedi minor devices to reserve for 
non-auto-configured devices (default 0)"
                );
 
-unsigned int comedi_default_buf_size_kb = DEFAULT_BUF_SIZE_KB;
+unsigned int comedi_default_buf_size_kb = CONFIG_COMEDI_DEFAULT_BUF_SIZE_KB;
 module_param(comedi_default_buf_size_kb, uint, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(comedi_default_buf_size_kb,
                 "default asynchronous buffer size in KiB (default "
-                __MODULE_STRING(DEFAULT_BUF_SIZE_KB) ")");
+                __MODULE_STRING(CONFIG_COMEDI_DEFAULT_BUF_SIZE_KB) ")");
 
-unsigned int comedi_default_buf_maxsize_kb = DEFAULT_BUF_MAXSIZE_KB;
+unsigned int comedi_default_buf_maxsize_kb
+       = CONFIG_COMEDI_DEFAULT_BUF_MAXSIZE_KB;
 module_param(comedi_default_buf_maxsize_kb, uint, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(comedi_default_buf_maxsize_kb,
                 "default maximum size of asynchronous buffer in KiB (default "
-                __MODULE_STRING(DEFAULT_BUF_MAXSIZE_KB) ")");
+                __MODULE_STRING(CONFIG_COMEDI_DEFAULT_BUF_MAXSIZE_KB) ")");
 
 static DEFINE_SPINLOCK(comedi_file_info_table_lock);
 static struct comedi_device_file_info
-- 
1.7.10

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: linux-image-3.2.0-23-generic-pae 3.2.0-23.36
ProcVersionSignature: Ubuntu 3.2.0-23.36-generic-pae 3.2.14
Uname: Linux 3.2.0-23-generic-pae i686
AlsaVersion: Advanced Linux Sound Architecture Driver Version 1.0.24.
ApportVersion: 2.0.1-0ubuntu2
Architecture: i386
AudioDevicesInUse:
 USER        PID ACCESS COMMAND
 /dev/snd/controlC0:  bp1        1761 F.... pulseaudio
CRDA: Error: [Errno 2] No such file or directory
Card0.Amixer.info:
 Card hw:0 'Intel'/'HDA Intel at 0xfdff8000 irq 45'
   Mixer name   : 'Realtek ALC888'
   Components   : 'HDA:10ec0888,1019e619,00100001'
   Controls      : 44
   Simple ctrls  : 21
Date: Fri Apr 13 23:32:26 2012
HibernationDevice: RESUME=UUID=b6911a72-ca8c-451f-980b-5f16df4e94f3
InstallationMedia: Ubuntu 12.04 LTS "Precise Pangolin" - Alpha i386 (20120201.2)
IwConfig:
 lo        no wireless extensions.
 
 eth0      no wireless extensions.
MachineType: Acer AcerPower FH
ProcEnviron:
 LANGUAGE=en_GB:en
 TERM=xterm
 PATH=(custom, user)
 LANG=en_GB.UTF-8
 SHELL=/bin/bash
ProcFB: 0 radeondrmfb
ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-3.2.0-23-generic-pae 
root=UUID=2a22481e-fd0f-4a5b-adb8-18566a6f8d65 ro quiet splash vt.handoff=7
RelatedPackageVersions:
 linux-restricted-modules-3.2.0-23-generic-pae N/A
 linux-backports-modules-3.2.0-23-generic-pae  N/A
 linux-firmware                                1.79
RfKill:
 
SourcePackage: linux
UpgradeStatus: No upgrade log present (probably fresh install)
UserAsoundrc:
 pcm.fileout {
    type empty
    slave.pcm "tee:default,'/tmp/out.raw',raw"
    # 48000 S16_LE 2ch (aplay -t raw -f dat)
 }
dmi.bios.date: 03/03/2007
dmi.bios.vendor: Phoenix Technologies, LTD
dmi.bios.version: R01-B4
dmi.board.name: E946GZ
dmi.board.vendor: Acer
dmi.chassis.type: 3
dmi.chassis.vendor: Broadwater
dmi.chassis.version: 946GZT-AM
dmi.modalias: 
dmi:bvnPhoenixTechnologies,LTD:bvrR01-B4:bd03/03/2007:svnAcer:pnAcerPowerFH:pvrR01-B4:rvnAcer:rnE946GZ:rvr:cvnBroadwater:ct3:cvr946GZT-AM:
dmi.product.name: AcerPower FH
dmi.product.version: R01-B4
dmi.sys.vendor: Acer

** Affects: linux (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: apport-bug i386 precise

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/981234

Title:
  buffer overflows in comedi drivers

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/981234/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to