Merge tag 'docs-for-linus' of git://git.lwn.net/linux
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 20 May 2016 01:07:25 +0000 (18:07 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 20 May 2016 01:07:25 +0000 (18:07 -0700)
Pull Documentation updates from Jon Corbet:
 "A bit busier this time around.

  The most interesting thing (IMO) this time around is some beginning
  infrastructural work to allow documents to be written using
  restructured text.  Maybe someday, in a galaxy far far away, we'll be
  able to eliminate the DocBook dependency and have a much better
  integrated set of kernel docs.  Someday.

  Beyond that, there's a new document on security hardening from Kees,
  the movement of some sample code over to samples/, a number of
  improvements to the serial docs from Geert, and the usual collection
  of corrections, typo fixes, etc"

* tag 'docs-for-linus' of git://git.lwn.net/linux: (55 commits)
  doc: self-protection: provide initial details
  serial: doc: Use port->state instead of info
  serial: doc: Always refer to tty_port->mutex
  Documentation: vm: Spelling s/paltform/platform/g
  Documentation/memcg: update kmem limit doc as codes behavior
  docproc: print a comment about autogeneration for rst output
  docproc: add support for reStructuredText format via --rst option
  docproc: abstract terminating lines at first space
  docproc: abstract docproc directive detection
  docproc: reduce unnecessary indentation
  docproc: add variables for subcommand and filename
  kernel-doc: use rst C domain directives and references for types
  kernel-doc: produce RestructuredText output
  kernel-doc: rewrite usage description, remove duplicated comments
  Doc: correct the location of sysrq.c
  Documentation: fix common spelling mistakes
  samples: v4l: from Documentation to samples directory
  samples: connector: from Documentation to samples directory
  Documentation: xillybus: fix spelling mistake
  Documentation: x86: fix spelling mistakes
  ...

1  2 
Documentation/DocBook/media/v4l/controls.xml
Documentation/DocBook/media/v4l/vidioc-g-selection.xml
Documentation/driver-model/devres.txt
Documentation/networking/filter.txt

@@@ -2841,7 -2841,7 +2841,7 @@@ for a GOP and keep it below or equal th
  overall average bitrate for the stream and keeps it below or equal to the set bitrate. In the first case
  the average bitrate for the whole stream will be smaller then the set bitrate. This is caused because the
  average is calculated for smaller number of frames, on the other hand enabling this setting will ensure that
- the stream will meet tight bandwidth contraints. Applicable to encoders.
+ the stream will meet tight bandwidth constraints. Applicable to encoders.
  </entry>
              </row>
              <row><entry></entry></row>
@@@ -4272,6 -4272,13 +4272,6 @@@ manually or automatically if set to zer
      <section id="flash-controls">
        <title>Flash Control Reference</title>
  
 -      <note>
 -      <title>Experimental</title>
 -
 -      <para>This is an <link linkend="experimental">experimental</link>
 -interface and may change in the future.</para>
 -      </note>
 -
        <para>
        The V4L2 flash controls are intended to provide generic access
        to flash controller devices. Flash controller devices are
      <section id="image-source-controls">
        <title>Image Source Control Reference</title>
  
 -      <note>
 -      <title>Experimental</title>
 -
 -      <para>This is an <link
 -      linkend="experimental">experimental</link> interface and may
 -      change in the future.</para>
 -      </note>
 -
        <para>
        The Image Source control class is intended for low-level
        control of image source devices such as image sensors. The
      <section id="image-process-controls">
        <title>Image Process Control Reference</title>
  
 -      <note>
 -      <title>Experimental</title>
 -
 -      <para>This is an <link
 -      linkend="experimental">experimental</link> interface and may
 -      change in the future.</para>
 -      </note>
 -
        <para>
        The Image Process control class is intended for low-level control of
        image processing functions. Unlike
      <section id="dv-controls">
        <title>Digital Video Control Reference</title>
  
 -      <note>
 -      <title>Experimental</title>
 -
 -      <para>This is an <link
 -      linkend="experimental">experimental</link> interface and may
 -      change in the future.</para>
 -      </note>
 -
        <para>
        The Digital Video control class is intended to control receivers
        and transmitters for <ulink url="http://en.wikipedia.org/wiki/Vga">VGA</ulink>,
    <refsect1>
      <title>Description</title>
  
 -    <note>
 -      <title>Experimental</title>
 -      <para>This is an <link linkend="experimental"> experimental </link>
 -      interface and may change in the future.</para>
 -    </note>
 -
      <para>The ioctls are used to query and configure selection rectangles.</para>
  
  <para>To query the cropping (composing) rectangle set &v4l2-selection;
@@@ -216,7 -222,7 +216,7 @@@ or the <structfield>flags</structfield
        <term><errorcode>ERANGE</errorcode></term>
        <listitem>
          <para>It is not possible to adjust &v4l2-rect; <structfield>
- r</structfield> rectangle to satisfy all contraints given in the
+ r</structfield> rectangle to satisfy all constraints given in the
  <structfield>flags</structfield> argument.</para>
        </listitem>
        </varlistentry>
@@@ -268,6 -268,9 +268,9 @@@ II
    devm_iio_trigger_alloc()
    devm_iio_trigger_free()
  
+ INPUT
+   devm_input_allocate_device()
  IO region
    devm_release_mem_region()
    devm_release_region()
@@@ -328,8 -331,6 +331,8 @@@ PH
  PINCTRL
    devm_pinctrl_get()
    devm_pinctrl_put()
 +  devm_pinctrl_register()
 +  devm_pinctrl_unregister()
  
  PWM
    devm_pwm_get()
@@@ -216,21 -216,21 +216,21 @@@ opcodes as defined in linux/filter.h st
  
    jmp              6                    Jump to label
    ja               6                    Jump to label
 -  jeq              7, 8                 Jump on k == A
 -  jneq             8                    Jump on k != A
 -  jne              8                    Jump on k != A
 -  jlt              8                    Jump on k < A
 -  jle              8                    Jump on k <= A
 -  jgt              7, 8                 Jump on k > A
 -  jge              7, 8                 Jump on k >= A
 -  jset             7, 8                 Jump on k & A
 +  jeq              7, 8                 Jump on A == k
 +  jneq             8                    Jump on A != k
 +  jne              8                    Jump on A != k
 +  jlt              8                    Jump on A <  k
 +  jle              8                    Jump on A <= k
 +  jgt              7, 8                 Jump on A >  k
 +  jge              7, 8                 Jump on A >= k
 +  jset             7, 8                 Jump on A &  k
  
    add              0, 4                 A + <x>
    sub              0, 4                 A - <x>
    mul              0, 4                 A * <x>
    div              0, 4                 A / <x>
    mod              0, 4                 A % <x>
-   neg              0, 4                 !A
+   neg                                   !A
    and              0, 4                 A & <x>
    or               0, 4                 A | <x>
    xor              0, 4                 A ^ <x>
@@@ -1095,87 -1095,6 +1095,87 @@@ all use cases
  
  See details of eBPF verifier in kernel/bpf/verifier.c
  
 +Direct packet access
 +--------------------
 +In cls_bpf and act_bpf programs the verifier allows direct access to the packet
 +data via skb->data and skb->data_end pointers.
 +Ex:
 +1:  r4 = *(u32 *)(r1 +80)  /* load skb->data_end */
 +2:  r3 = *(u32 *)(r1 +76)  /* load skb->data */
 +3:  r5 = r3
 +4:  r5 += 14
 +5:  if r5 > r4 goto pc+16
 +R1=ctx R3=pkt(id=0,off=0,r=14) R4=pkt_end R5=pkt(id=0,off=14,r=14) R10=fp
 +6:  r0 = *(u16 *)(r3 +12) /* access 12 and 13 bytes of the packet */
 +
 +this 2byte load from the packet is safe to do, since the program author
 +did check 'if (skb->data + 14 > skb->data_end) goto err' at insn #5 which
 +means that in the fall-through case the register R3 (which points to skb->data)
 +has at least 14 directly accessible bytes. The verifier marks it
 +as R3=pkt(id=0,off=0,r=14).
 +id=0 means that no additional variables were added to the register.
 +off=0 means that no additional constants were added.
 +r=14 is the range of safe access which means that bytes [R3, R3 + 14) are ok.
 +Note that R5 is marked as R5=pkt(id=0,off=14,r=14). It also points
 +to the packet data, but constant 14 was added to the register, so
 +it now points to 'skb->data + 14' and accessible range is [R5, R5 + 14 - 14)
 +which is zero bytes.
 +
 +More complex packet access may look like:
 + R0=imm1 R1=ctx R3=pkt(id=0,off=0,r=14) R4=pkt_end R5=pkt(id=0,off=14,r=14) R10=fp
 + 6:  r0 = *(u8 *)(r3 +7) /* load 7th byte from the packet */
 + 7:  r4 = *(u8 *)(r3 +12)
 + 8:  r4 *= 14
 + 9:  r3 = *(u32 *)(r1 +76) /* load skb->data */
 +10:  r3 += r4
 +11:  r2 = r1
 +12:  r2 <<= 48
 +13:  r2 >>= 48
 +14:  r3 += r2
 +15:  r2 = r3
 +16:  r2 += 8
 +17:  r1 = *(u32 *)(r1 +80) /* load skb->data_end */
 +18:  if r2 > r1 goto pc+2
 + R0=inv56 R1=pkt_end R2=pkt(id=2,off=8,r=8) R3=pkt(id=2,off=0,r=8) R4=inv52 R5=pkt(id=0,off=14,r=14) R10=fp
 +19:  r1 = *(u8 *)(r3 +4)
 +The state of the register R3 is R3=pkt(id=2,off=0,r=8)
 +id=2 means that two 'r3 += rX' instructions were seen, so r3 points to some
 +offset within a packet and since the program author did
 +'if (r3 + 8 > r1) goto err' at insn #18, the safe range is [R3, R3 + 8).
 +The verifier only allows 'add' operation on packet registers. Any other
 +operation will set the register state to 'unknown_value' and it won't be
 +available for direct packet access.
 +Operation 'r3 += rX' may overflow and become less than original skb->data,
 +therefore the verifier has to prevent that. So it tracks the number of
 +upper zero bits in all 'uknown_value' registers, so when it sees
 +'r3 += rX' instruction and rX is more than 16-bit value, it will error as:
 +"cannot add integer value with N upper zero bits to ptr_to_packet"
 +Ex. after insn 'r4 = *(u8 *)(r3 +12)' (insn #7 above) the state of r4 is
 +R4=inv56 which means that upper 56 bits on the register are guaranteed
 +to be zero. After insn 'r4 *= 14' the state becomes R4=inv52, since
 +multiplying 8-bit value by constant 14 will keep upper 52 bits as zero.
 +Similarly 'r2 >>= 48' will make R2=inv48, since the shift is not sign
 +extending. This logic is implemented in evaluate_reg_alu() function.
 +
 +The end result is that bpf program author can access packet directly
 +using normal C code as:
 +  void *data = (void *)(long)skb->data;
 +  void *data_end = (void *)(long)skb->data_end;
 +  struct eth_hdr *eth = data;
 +  struct iphdr *iph = data + sizeof(*eth);
 +  struct udphdr *udp = data + sizeof(*eth) + sizeof(*iph);
 +
 +  if (data + sizeof(*eth) + sizeof(*iph) + sizeof(*udp) > data_end)
 +          return 0;
 +  if (eth->h_proto != htons(ETH_P_IP))
 +          return 0;
 +  if (iph->protocol != IPPROTO_UDP || iph->ihl != 5)
 +          return 0;
 +  if (udp->dest == 53 || udp->source == 9)
 +          ...;
 +which makes such programs easier to write comparing to LD_ABS insn
 +and significantly faster.
 +
  eBPF maps
  ---------
  'maps' is a generic storage of different types for sharing data between kernel
@@@ -1374,5 -1293,5 +1374,5 @@@ to give potential BPF hackers or securi
  the underlying architecture.
  
  Jay Schulist <jschlst@samba.org>
 -Daniel Borkmann <dborkman@redhat.com>
 -Alexei Starovoitov <ast@plumgrid.com>
 +Daniel Borkmann <daniel@iogearbox.net>
 +Alexei Starovoitov <ast@kernel.org>