Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6:
firewire: cdev: change license of exported header files to MIT license
firewire: cdev: comment fixlet
firewire: cdev: iso packet documentation
firewire: cdev: fix information leak
firewire: cdev: require quadlet-aligned headers for transmit packets
firewire: cdev: disallow receive packets without header

+91 -31
+13 -10
drivers/firewire/core-cdev.c
··· 960 960 u.packet.header_length = GET_HEADER_LENGTH(control); 961 961 962 962 if (ctx->type == FW_ISO_CONTEXT_TRANSMIT) { 963 + if (u.packet.header_length % 4 != 0) 964 + return -EINVAL; 963 965 header_length = u.packet.header_length; 964 966 } else { 965 967 /* ··· 971 969 if (ctx->header_size == 0) { 972 970 if (u.packet.header_length > 0) 973 971 return -EINVAL; 974 - } else if (u.packet.header_length % ctx->header_size != 0) { 972 + } else if (u.packet.header_length == 0 || 973 + u.packet.header_length % ctx->header_size != 0) { 975 974 return -EINVAL; 976 975 } 977 976 header_length = 0; ··· 1357 1354 return -ENODEV; 1358 1355 1359 1356 if (_IOC_TYPE(cmd) != '#' || 1360 - _IOC_NR(cmd) >= ARRAY_SIZE(ioctl_handlers)) 1357 + _IOC_NR(cmd) >= ARRAY_SIZE(ioctl_handlers) || 1358 + _IOC_SIZE(cmd) > sizeof(buffer)) 1361 1359 return -EINVAL; 1362 1360 1363 - if (_IOC_DIR(cmd) & _IOC_WRITE) { 1364 - if (_IOC_SIZE(cmd) > sizeof(buffer) || 1365 - copy_from_user(&buffer, arg, _IOC_SIZE(cmd))) 1361 + if (_IOC_DIR(cmd) == _IOC_READ) 1362 + memset(&buffer, 0, _IOC_SIZE(cmd)); 1363 + 1364 + if (_IOC_DIR(cmd) & _IOC_WRITE) 1365 + if (copy_from_user(&buffer, arg, _IOC_SIZE(cmd))) 1366 1366 return -EFAULT; 1367 - } 1368 1367 1369 1368 ret = ioctl_handlers[_IOC_NR(cmd)](client, &buffer); 1370 1369 if (ret < 0) 1371 1370 return ret; 1372 1371 1373 - if (_IOC_DIR(cmd) & _IOC_READ) { 1374 - if (_IOC_SIZE(cmd) > sizeof(buffer) || 1375 - copy_to_user(arg, &buffer, _IOC_SIZE(cmd))) 1372 + if (_IOC_DIR(cmd) & _IOC_READ) 1373 + if (copy_to_user(arg, &buffer, _IOC_SIZE(cmd))) 1376 1374 return -EFAULT; 1377 - } 1378 1375 1379 1376 return ret; 1380 1377 }
+51 -19
include/linux/firewire-cdev.h
··· 1 1 /* 2 2 * Char device interface. 3 3 * 4 - * Copyright (C) 2005-2006 Kristian Hoegsberg <krh@bitplanet.net> 4 + * Copyright (C) 2005-2007 Kristian Hoegsberg <krh@bitplanet.net> 5 5 * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License as published by 8 - * the Free Software Foundation; either version 2 of the License, or 9 - * (at your option) any later version. 6 + * Permission is hereby granted, free of charge, to any person obtaining a 7 + * copy of this software and associated documentation files (the "Software"), 8 + * to deal in the Software without restriction, including without limitation 9 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 + * and/or sell copies of the Software, and to permit persons to whom the 11 + * Software is furnished to do so, subject to the following conditions: 10 12 * 11 - * This program is distributed in the hope that it will be useful, 12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 - * GNU General Public License for more details. 13 + * The above copyright notice and this permission notice (including the next 14 + * paragraph) shall be included in all copies or substantial portions of the 15 + * Software. 15 16 * 16 - * You should have received a copy of the GNU General Public License 17 - * along with this program; if not, write to the Free Software Foundation, 18 - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 + * DEALINGS IN THE SOFTWARE. 19 24 */ 20 25 21 26 #ifndef _LINUX_FIREWIRE_CDEV_H ··· 443 438 * @type: %FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE 444 439 * @header_size: Header size to strip for receive contexts 445 440 * @channel: Channel to bind to 446 - * @speed: Speed to transmit at 441 + * @speed: Speed for transmit contexts 447 442 * @closure: To be returned in &fw_cdev_event_iso_interrupt 448 443 * @handle: Handle to context, written back by kernel 449 444 * ··· 455 450 * 456 451 * If a context was successfully created, the kernel writes back a handle to the 457 452 * context, which must be passed in for subsequent operations on that context. 453 + * 454 + * For receive contexts, @header_size must be at least 4 and must be a multiple 455 + * of 4. 458 456 * 459 457 * Note that the effect of a @header_size > 4 depends on 460 458 * &fw_cdev_get_info.version, as documented at &fw_cdev_event_iso_interrupt. ··· 489 481 * 490 482 * &struct fw_cdev_iso_packet is used to describe isochronous packet queues. 491 483 * 492 - * Use the FW_CDEV_ISO_ macros to fill in @control. The sy and tag fields are 493 - * specified by IEEE 1394a and IEC 61883. 484 + * Use the FW_CDEV_ISO_ macros to fill in @control. 494 485 * 495 - * FIXME - finish this documentation 486 + * For transmit packets, the header length must be a multiple of 4 and specifies 487 + * the numbers of bytes in @header that will be prepended to the packet's 488 + * payload; these bytes are copied into the kernel and will not be accessed 489 + * after the ioctl has returned. The sy and tag fields are copied to the iso 490 + * packet header (these fields are specified by IEEE 1394a and IEC 61883-1). 491 + * The skip flag specifies that no packet is to be sent in a frame; when using 492 + * this, all other fields except the interrupt flag must be zero. 493 + * 494 + * For receive packets, the header length must be a multiple of the context's 495 + * header size; if the header length is larger than the context's header size, 496 + * multiple packets are queued for this entry. The sy and tag fields are 497 + * ignored. If the sync flag is set, the context drops all packets until 498 + * a packet with a matching sy field is received (the sync value to wait for is 499 + * specified in the &fw_cdev_start_iso structure). The payload length defines 500 + * how many payload bytes can be received for one packet (in addition to payload 501 + * quadlets that have been defined as headers and are stripped and returned in 502 + * the &fw_cdev_event_iso_interrupt structure). If more bytes are received, the 503 + * additional bytes are dropped. If less bytes are received, the remaining 504 + * bytes in this part of the payload buffer will not be written to, not even by 505 + * the next packet, i.e., packets received in consecutive frames will not 506 + * necessarily be consecutive in memory. If an entry has queued multiple 507 + * packets, the payload length is divided equally among them. 508 + * 509 + * When a packet with the interrupt flag set has been completed, the 510 + * &fw_cdev_event_iso_interrupt event will be sent. An entry that has queued 511 + * multiple receive packets is completed when its last packet is completed. 496 512 */ 497 513 struct fw_cdev_iso_packet { 498 514 __u32 control; ··· 533 501 * Queue a number of isochronous packets for reception or transmission. 534 502 * This ioctl takes a pointer to an array of &fw_cdev_iso_packet structs, 535 503 * which describe how to transmit from or receive into a contiguous region 536 - * of a mmap()'ed payload buffer. As part of the packet descriptors, 504 + * of a mmap()'ed payload buffer. As part of transmit packet descriptors, 537 505 * a series of headers can be supplied, which will be prepended to the 538 506 * payload during DMA. 539 507 * ··· 652 620 * instead of allocated. 653 621 * An %FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED event concludes this operation. 654 622 * 655 - * To summarize, %FW_CDEV_IOC_DEALLOCATE_ISO_RESOURCE allocates iso resources 656 - * for the lifetime of the fd or handle. 623 + * To summarize, %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE allocates iso resources 624 + * for the lifetime of the fd or @handle. 657 625 * In contrast, %FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE_ONCE allocates iso resources 658 626 * for the duration of a bus generation. 659 627 *
+27 -2
include/linux/firewire-constants.h
··· 1 + /* 2 + * IEEE 1394 constants. 3 + * 4 + * Copyright (C) 2005-2007 Kristian Hoegsberg <krh@bitplanet.net> 5 + * 6 + * Permission is hereby granted, free of charge, to any person obtaining a 7 + * copy of this software and associated documentation files (the "Software"), 8 + * to deal in the Software without restriction, including without limitation 9 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 + * and/or sell copies of the Software, and to permit persons to whom the 11 + * Software is furnished to do so, subject to the following conditions: 12 + * 13 + * The above copyright notice and this permission notice (including the next 14 + * paragraph) shall be included in all copies or substantial portions of the 15 + * Software. 16 + * 17 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 + * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 + * DEALINGS IN THE SOFTWARE. 24 + */ 25 + 1 26 #ifndef _LINUX_FIREWIRE_CONSTANTS_H 2 27 #define _LINUX_FIREWIRE_CONSTANTS_H 3 28 ··· 46 21 #define EXTCODE_WRAP_ADD 0x6 47 22 #define EXTCODE_VENDOR_DEPENDENT 0x7 48 23 49 - /* Juju specific tcodes */ 24 + /* Linux firewire-core (Juju) specific tcodes */ 50 25 #define TCODE_LOCK_MASK_SWAP (0x10 | EXTCODE_MASK_SWAP) 51 26 #define TCODE_LOCK_COMPARE_SWAP (0x10 | EXTCODE_COMPARE_SWAP) 52 27 #define TCODE_LOCK_FETCH_ADD (0x10 | EXTCODE_FETCH_ADD) ··· 61 36 #define RCODE_TYPE_ERROR 0x6 62 37 #define RCODE_ADDRESS_ERROR 0x7 63 38 64 - /* Juju specific rcodes */ 39 + /* Linux firewire-core (Juju) specific rcodes */ 65 40 #define RCODE_SEND_ERROR 0x10 66 41 #define RCODE_CANCELLED 0x11 67 42 #define RCODE_BUSY 0x12