1. 31 3月, 2011 1 次提交
  2. 17 3月, 2011 1 次提交
  3. 01 3月, 2011 1 次提交
  4. 18 2月, 2011 3 次提交
  5. 16 2月, 2011 1 次提交
  6. 15 2月, 2011 1 次提交
  7. 14 2月, 2011 1 次提交
  8. 10 2月, 2011 1 次提交
  9. 02 2月, 2011 1 次提交
    • S
      isdn: icn: Fix potentially wrong string handling · a29ae23f
      Stefan Weil 提交于
      This warning was reported by cppcheck:
      drivers/isdn/icn/icn.c:1641: error: Dangerous usage of 'rev' (strncpy doesn't always 0-terminate it)
      
      If strncpy copied 20 bytes, the destination string rev was not terminated.
      The patch adds one more byte to rev and makes sure that this byte is
      always 0.
      
      Cc: Karsten Keil <isdn@linux-pingi.de>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: netdev@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NStefan Weil <weil@mail.berlios.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a29ae23f
  10. 03 1月, 2011 1 次提交
  11. 01 1月, 2011 1 次提交
    • J
      ISDN, Gigaset: Fix memory leak in do_disconnect_req() · 2393c944
      Jesper Juhl 提交于
      Hi,
      
      In drivers/isdn/gigaset/capi.c::do_disconnect_req() we will leak the
      memory allocated (with kmalloc) to 'b3cmsg' if the call to alloc_skb()
      fails.
      
      ...
      		b3cmsg = kmalloc(sizeof(*b3cmsg), GFP_KERNEL);
      	allocation here ------^
      		if (!b3cmsg) {
      			dev_err(cs->dev, "%s: out of memory\n", __func__);
      			send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR);
      			return;
      		}
      		capi_cmsg_header(b3cmsg, ap->id, CAPI_DISCONNECT_B3, CAPI_IND,
      				 ap->nextMessageNumber++,
      				 cmsg->adr.adrPLCI | (1 << 16));
      		b3cmsg->Reason_B3 = CapiProtocolErrorLayer1;
      		b3skb = alloc_skb(CAPI_DISCONNECT_B3_IND_BASELEN, GFP_KERNEL);
      		if (b3skb == NULL) {
      			dev_err(cs->dev, "%s: out of memory\n", __func__);
      			send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR);
      			return;
      	leak here ------^
      ...
      
      This leak is easily fixed by just kfree()'ing the memory allocated to
      'b3cmsg' right before we return. The following patch does that.
      Signed-off-by: NJesper Juhl <jj@chaosbits.net>
      Acked-by: NTilman Schmidt <tilman@imap.cc>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2393c944
  12. 24 12月, 2010 3 次提交
  13. 11 12月, 2010 2 次提交
  14. 09 12月, 2010 1 次提交
  15. 25 11月, 2010 1 次提交
    • S
      isdn: icn: Fix stack corruption bug. · 4448008e
      Steven Rostedt 提交于
      Running randconfig with ktest.pl I hit this bug:
      
      [   16.101158] ICN-ISDN-driver Rev 1.65.6.8 mem=0x000d0000
      [   16.106376] icn: (line0) ICN-2B, port 0x320 added
      [   16.111064] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: c1642880
      [   16.111066] 
      [   16.121214] Pid: 1, comm: swapper Not tainted 2.6.37-rc2-test-00124-g6656b3fc #8
      [   16.128499] Call Trace:
      [   16.130942]  [<c0f51662>] ? printk+0x1d/0x23
      [   16.135200]  [<c0f5153f>] panic+0x5c/0x162
      [   16.139286]  [<c0d62a9a>] ? icn_addcard+0x6d/0xbe
      [   16.143975]  [<c0445783>] print_tainted+0x0/0x8c
      [   16.148582]  [<c1642880>] ? icn_init+0xd8/0xdf
      [   16.153012]  [<c1642880>] icn_init+0xd8/0xdf
      [   16.157271]  [<c04012e5>] do_one_initcall+0x8c/0x143
      [   16.162222]  [<c16427a8>] ? icn_init+0x0/0xdf
      [   16.166566]  [<c15f1a05>] kernel_init+0x13f/0x1da
      [   16.171256]  [<c15f18c6>] ? kernel_init+0x0/0x1da
      [   16.175945]  [<c0403bfe>] kernel_thread_helper+0x6/0x10
      [   16.181181] panic occurred, switching back to text console
      
      Looking into it I found that the stack was corrupted by the assignment
      of the Rev #. The variable rev is given 10 bytes, and in this output the
      characters that were copied was: " 1.65.6.8 $". Which was 11 characters
      plus the null ending character for a total of 12 bytes, thus corrupting
      the stack.
      
      This patch ups the variable size to 20 bytes as well as changes the
      strcpy to strncpy. I also added a check to make sure '$' is found.
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4448008e
  16. 20 11月, 2010 1 次提交
    • E
      filter: optimize sk_run_filter · 93aaae2e
      Eric Dumazet 提交于
      Remove pc variable to avoid arithmetic to compute fentry at each filter
      instruction. Jumps directly manipulate fentry pointer.
      
      As the last instruction of filter[] is guaranteed to be a RETURN, and
      all jumps are before the last instruction, we dont need to check filter
      bounds (number of instructions in filter array) at each iteration, so we
      remove it from sk_run_filter() params.
      
      On x86_32 remove f_k var introduced in commit 57fe93b3
      (filter: make sure filters dont read uninitialized memory)
      
      Note : We could use a CONFIG_ARCH_HAS_{FEW|MANY}_REGISTERS in order to
      avoid too many ifdefs in this code.
      
      This helps compiler to use cpu registers to hold fentry and A
      accumulator.
      
      On x86_32, this saves 401 bytes, and more important, sk_run_filter()
      runs much faster because less register pressure (One less conditional
      branch per BPF instruction)
      
      # size net/core/filter.o net/core/filter_pre.o
         text    data     bss     dec     hex filename
         2948       0       0    2948     b84 net/core/filter.o
         3349       0       0    3349     d15 net/core/filter_pre.o
      
      on x86_64 :
      # size net/core/filter.o net/core/filter_pre.o
         text    data     bss     dec     hex filename
         5173       0       0    5173    1435 net/core/filter.o
         5224       0       0    5224    1468 net/core/filter_pre.o
      Signed-off-by: NEric Dumazet <eric.dumazet@gmail.com>
      Acked-by: NChangli Gao <xiaosuo@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      93aaae2e
  17. 18 11月, 2010 2 次提交
  18. 17 11月, 2010 1 次提交
  19. 16 11月, 2010 1 次提交
  20. 02 11月, 2010 1 次提交
  21. 01 11月, 2010 1 次提交
  22. 31 10月, 2010 1 次提交
  23. 29 10月, 2010 1 次提交
  24. 28 10月, 2010 1 次提交
    • J
      drivers/isdn: delete double assignment · 4101e976
      Julia Lawall 提交于
      Delete successive assignments to the same location.  In the first case, the
      hscx array has two elements, so change the assignment to initialize the
      second one.  In the second case, the two assignments are simply identical.
      Furthermore, neither is necessary, because the effect of the assignment is
      only visible in the next line, in the assignment in the if test.  The patch
      inlines the right hand side value in the latter assignment and pulls that
      assignment out of the if test.
      
      A simplified version of the semantic match that finds this problem is as
      follows: (http://coccinelle.lip6.fr/)
      
      // <smpl>
      @@
      expression i;
      @@
      
      *i = ...;
       i = ...;
      // </smpl>
      Signed-off-by: NJulia Lawall <julia@diku.dk>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4101e976
  25. 21 10月, 2010 1 次提交
  26. 18 10月, 2010 1 次提交
  27. 17 10月, 2010 1 次提交
  28. 15 10月, 2010 1 次提交
    • A
      llseek: automatically add .llseek fop · 6038f373
      Arnd Bergmann 提交于
      All file_operations should get a .llseek operation so we can make
      nonseekable_open the default for future file operations without a
      .llseek pointer.
      
      The three cases that we can automatically detect are no_llseek, seq_lseek
      and default_llseek. For cases where we can we can automatically prove that
      the file offset is always ignored, we use noop_llseek, which maintains
      the current behavior of not returning an error from a seek.
      
      New drivers should normally not use noop_llseek but instead use no_llseek
      and call nonseekable_open at open time.  Existing drivers can be converted
      to do the same when the maintainer knows for certain that no user code
      relies on calling seek on the device file.
      
      The generated code is often incorrectly indented and right now contains
      comments that clarify for each added line why a specific variant was
      chosen. In the version that gets submitted upstream, the comments will
      be gone and I will manually fix the indentation, because there does not
      seem to be a way to do that using coccinelle.
      
      Some amount of new code is currently sitting in linux-next that should get
      the same modifications, which I will do at the end of the merge window.
      
      Many thanks to Julia Lawall for helping me learn to write a semantic
      patch that does all this.
      
      ===== begin semantic patch =====
      // This adds an llseek= method to all file operations,
      // as a preparation for making no_llseek the default.
      //
      // The rules are
      // - use no_llseek explicitly if we do nonseekable_open
      // - use seq_lseek for sequential files
      // - use default_llseek if we know we access f_pos
      // - use noop_llseek if we know we don't access f_pos,
      //   but we still want to allow users to call lseek
      //
      @ open1 exists @
      identifier nested_open;
      @@
      nested_open(...)
      {
      <+...
      nonseekable_open(...)
      ...+>
      }
      
      @ open exists@
      identifier open_f;
      identifier i, f;
      identifier open1.nested_open;
      @@
      int open_f(struct inode *i, struct file *f)
      {
      <+...
      (
      nonseekable_open(...)
      |
      nested_open(...)
      )
      ...+>
      }
      
      @ read disable optional_qualifier exists @
      identifier read_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      expression E;
      identifier func;
      @@
      ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
      {
      <+...
      (
         *off = E
      |
         *off += E
      |
         func(..., off, ...)
      |
         E = *off
      )
      ...+>
      }
      
      @ read_no_fpos disable optional_qualifier exists @
      identifier read_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      @@
      ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
      {
      ... when != off
      }
      
      @ write @
      identifier write_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      expression E;
      identifier func;
      @@
      ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
      {
      <+...
      (
        *off = E
      |
        *off += E
      |
        func(..., off, ...)
      |
        E = *off
      )
      ...+>
      }
      
      @ write_no_fpos @
      identifier write_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      @@
      ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
      {
      ... when != off
      }
      
      @ fops0 @
      identifier fops;
      @@
      struct file_operations fops = {
       ...
      };
      
      @ has_llseek depends on fops0 @
      identifier fops0.fops;
      identifier llseek_f;
      @@
      struct file_operations fops = {
      ...
       .llseek = llseek_f,
      ...
      };
      
      @ has_read depends on fops0 @
      identifier fops0.fops;
      identifier read_f;
      @@
      struct file_operations fops = {
      ...
       .read = read_f,
      ...
      };
      
      @ has_write depends on fops0 @
      identifier fops0.fops;
      identifier write_f;
      @@
      struct file_operations fops = {
      ...
       .write = write_f,
      ...
      };
      
      @ has_open depends on fops0 @
      identifier fops0.fops;
      identifier open_f;
      @@
      struct file_operations fops = {
      ...
       .open = open_f,
      ...
      };
      
      // use no_llseek if we call nonseekable_open
      ////////////////////////////////////////////
      @ nonseekable1 depends on !has_llseek && has_open @
      identifier fops0.fops;
      identifier nso ~= "nonseekable_open";
      @@
      struct file_operations fops = {
      ...  .open = nso, ...
      +.llseek = no_llseek, /* nonseekable */
      };
      
      @ nonseekable2 depends on !has_llseek @
      identifier fops0.fops;
      identifier open.open_f;
      @@
      struct file_operations fops = {
      ...  .open = open_f, ...
      +.llseek = no_llseek, /* open uses nonseekable */
      };
      
      // use seq_lseek for sequential files
      /////////////////////////////////////
      @ seq depends on !has_llseek @
      identifier fops0.fops;
      identifier sr ~= "seq_read";
      @@
      struct file_operations fops = {
      ...  .read = sr, ...
      +.llseek = seq_lseek, /* we have seq_read */
      };
      
      // use default_llseek if there is a readdir
      ///////////////////////////////////////////
      @ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier readdir_e;
      @@
      // any other fop is used that changes pos
      struct file_operations fops = {
      ... .readdir = readdir_e, ...
      +.llseek = default_llseek, /* readdir is present */
      };
      
      // use default_llseek if at least one of read/write touches f_pos
      /////////////////////////////////////////////////////////////////
      @ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier read.read_f;
      @@
      // read fops use offset
      struct file_operations fops = {
      ... .read = read_f, ...
      +.llseek = default_llseek, /* read accesses f_pos */
      };
      
      @ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier write.write_f;
      @@
      // write fops use offset
      struct file_operations fops = {
      ... .write = write_f, ...
      +	.llseek = default_llseek, /* write accesses f_pos */
      };
      
      // Use noop_llseek if neither read nor write accesses f_pos
      ///////////////////////////////////////////////////////////
      
      @ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier read_no_fpos.read_f;
      identifier write_no_fpos.write_f;
      @@
      // write fops use offset
      struct file_operations fops = {
      ...
       .write = write_f,
       .read = read_f,
      ...
      +.llseek = noop_llseek, /* read and write both use no f_pos */
      };
      
      @ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier write_no_fpos.write_f;
      @@
      struct file_operations fops = {
      ... .write = write_f, ...
      +.llseek = noop_llseek, /* write uses no f_pos */
      };
      
      @ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier read_no_fpos.read_f;
      @@
      struct file_operations fops = {
      ... .read = read_f, ...
      +.llseek = noop_llseek, /* read uses no f_pos */
      };
      
      @ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      @@
      struct file_operations fops = {
      ...
      +.llseek = noop_llseek, /* no read or write fn */
      };
      ===== End semantic patch =====
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Julia Lawall <julia@diku.dk>
      Cc: Christoph Hellwig <hch@infradead.org>
      6038f373
  29. 12 10月, 2010 1 次提交
  30. 09 10月, 2010 1 次提交
    • D
      isdn: strcpy() => strlcpy() · b530fb69
      Dan Carpenter 提交于
      setup.phone and setup.eazmsn are 32 character buffers.
      rcvmsg.msg_data.byte_array is a 48 character buffer.
      sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].dn is 50 chars.
      
      The rcvmsg struct comes from the memcpy_fromio() in receivemessage().
      I guess that means it's data off the wire.  I'm not very familiar with
      this code but I don't see any reason to assume these strings are NULL
      terminated.
      
      Also it's weird that "dn" in a 50 character buffer but we only seem to
      use 32 characters.  In drivers/isdn/sc/scioc.h, "dn" is only a 49
      character buffer.  So potentially there is still an issue there.
      
      The important thing for now is to prevent the memory corruption.
      Signed-off-by: NDan Carpenter <error27@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b530fb69
  31. 07 10月, 2010 1 次提交
    • D
      eicon: make buffer larger · c2dddf94
      Dan Carpenter 提交于
      In diva_mnt_add_xdi_adapter() we do this:
        strcpy (clients[id].drvName,     tmp);
        strcpy (clients[id].Dbg.drvName, tmp);
      
      The "clients[id].drvName" is a 128 character buffer and
      "clients[id].Dbg.drvName" was originally a 16 character buffer but I've
      changed it to 128 as well.  We don't actually use 128 characters but we
      do use more than 16.
      
      I've also changed the size of "tmp" to 128 characters instead of 256.
      Signed-off-by: NDan Carpenter <error27@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c2dddf94
  32. 04 10月, 2010 1 次提交
  33. 01 10月, 2010 2 次提交