13 Jun, 2018

3 commits

  • The vzalloc() function has no 2-factor argument form, so multiplication
    factors need to be wrapped in array_size(). This patch replaces cases of:

    vzalloc(a * b)

    with:
    vzalloc(array_size(a, b))

    as well as handling cases of:

    vzalloc(a * b * c)

    with:

    vzalloc(array3_size(a, b, c))

    This does, however, attempt to ignore constant size factors like:

    vzalloc(4 * 1024)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    vzalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    vzalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    vzalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    vzalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    vzalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    vzalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    vzalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    vzalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    vzalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    vzalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    vzalloc(
    - sizeof(TYPE) * (COUNT_ID)
    + array_size(COUNT_ID, sizeof(TYPE))
    , ...)
    |
    vzalloc(
    - sizeof(TYPE) * COUNT_ID
    + array_size(COUNT_ID, sizeof(TYPE))
    , ...)
    |
    vzalloc(
    - sizeof(TYPE) * (COUNT_CONST)
    + array_size(COUNT_CONST, sizeof(TYPE))
    , ...)
    |
    vzalloc(
    - sizeof(TYPE) * COUNT_CONST
    + array_size(COUNT_CONST, sizeof(TYPE))
    , ...)
    |
    vzalloc(
    - sizeof(THING) * (COUNT_ID)
    + array_size(COUNT_ID, sizeof(THING))
    , ...)
    |
    vzalloc(
    - sizeof(THING) * COUNT_ID
    + array_size(COUNT_ID, sizeof(THING))
    , ...)
    |
    vzalloc(
    - sizeof(THING) * (COUNT_CONST)
    + array_size(COUNT_CONST, sizeof(THING))
    , ...)
    |
    vzalloc(
    - sizeof(THING) * COUNT_CONST
    + array_size(COUNT_CONST, sizeof(THING))
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    vzalloc(
    - SIZE * COUNT
    + array_size(COUNT, SIZE)
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    vzalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vzalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vzalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vzalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vzalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vzalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vzalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vzalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    vzalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    vzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    vzalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    vzalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    vzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    vzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    vzalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vzalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vzalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vzalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vzalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vzalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vzalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vzalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    vzalloc(C1 * C2 * C3, ...)
    |
    vzalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants.
    @@
    expression E1, E2;
    constant C1, C2;
    @@

    (
    vzalloc(C1 * C2, ...)
    |
    vzalloc(
    - E1 * E2
    + array_size(E1, E2)
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     
  • The kzalloc() function has a 2-factor argument form, kcalloc(). This
    patch replaces cases of:

    kzalloc(a * b, gfp)

    with:
    kcalloc(a * b, gfp)

    as well as handling cases of:

    kzalloc(a * b * c, gfp)

    with:

    kzalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kzalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kzalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kzalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kzalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kzalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kzalloc
    + kcalloc
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kzalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kzalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kzalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kzalloc(sizeof(THING) * C2, ...)
    |
    kzalloc(sizeof(TYPE) * C2, ...)
    |
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(C1 * C2, ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     
  • The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
    patch replaces cases of:

    kmalloc(a * b, gfp)

    with:
    kmalloc_array(a * b, gfp)

    as well as handling cases of:

    kmalloc(a * b * c, gfp)

    with:

    kmalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kmalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kmalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The tools/ directory was manually excluded, since it has its own
    implementation of kmalloc().

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kmalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kmalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kmalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kmalloc
    + kmalloc_array
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kmalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kmalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kmalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kmalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kmalloc(C1 * C2 * C3, ...)
    |
    kmalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kmalloc(sizeof(THING) * C2, ...)
    |
    kmalloc(sizeof(TYPE) * C2, ...)
    |
    kmalloc(C1 * C2 * C3, ...)
    |
    kmalloc(C1 * C2, ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

04 May, 2018

1 commit


02 May, 2018

1 commit

  • In ethtool_get_rxnfc(), the object "info" is firstly copied from
    user-space. If the FLOW_RSS flag is set in the member field flow_type of
    "info" (and cmd is ETHTOOL_GRXFH), info needs to be copied again from
    user-space because FLOW_RSS is newer and has new definition, as mentioned
    in the comment. However, given that the user data resides in user-space, a
    malicious user can race to change the data after the first copy. By doing
    so, the user can inject inconsistent data. For example, in the second
    copy, the FLOW_RSS flag could be cleared in the field flow_type of "info".
    In the following execution, "info" will be used in the function
    ops->get_rxnfc(). Such inconsistent data can potentially lead to unexpected
    information leakage since ops->get_rxnfc() will prepare various types of
    data according to flow_type, and the prepared data will be eventually
    copied to user-space. This inconsistent data may also cause undefined
    behaviors based on how ops->get_rxnfc() is implemented.

    This patch simply re-verifies the flow_type field of "info" after the
    second copy. If the value is not as expected, an error code will be
    returned.

    Signed-off-by: Wenwen Wang
    Signed-off-by: David S. Miller

    Wenwen Wang
     

01 May, 2018

1 commit


27 Apr, 2018

3 commits

  • Add a new callback: get_ethtool_phy_stats() which allows network device
    drivers not making use of the PHY library to return PHY statistics.
    Update ethtool_get_phy_stats(), __ethtool_get_sset_count() and
    __ethtool_get_strings() accordingly to interogate the network device
    about ETH_SS_PHY_STATS.

    Signed-off-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Florian Fainelli
     
  • In order to make it possible for network device drivers that do not
    necessarily have a phy_device attached, but still report PHY statistics,
    have a preliminary refactoring consisting in creating helper functions
    that encapsulate the PHY device driver knowledge within PHYLIB.

    Signed-off-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Florian Fainelli
     
  • Virtual devices such as tunnels and bonding can handle large packets.
    Only segment packets when reaching a physical or loopback device.

    Signed-off-by: Willem de Bruijn
    Signed-off-by: David S. Miller

    Willem de Bruijn
     

01 Apr, 2018

1 commit

  • Ethtool option enables TLS record offload on HW, user
    configures the feature for netdev capable of Inline TLS.
    This allows user to define custom sk_prot for Inline TLS sock

    Signed-off-by: Atul Gupta
    Signed-off-by: David S. Miller

    Atul Gupta
     

30 Mar, 2018

1 commit

  • Provide a pointer to the SFP bus in struct net_device, so that the
    ethtool module EEPROM methods can access the SFP directly, rather
    than needing every user to provide a hook for it.

    Reviewed-by: Andrew Lunn
    Signed-off-by: Russell King
    Signed-off-by: Florian Fainelli
    Reviewed-by: Andrew Lunn
    Signed-off-by: Russell King
    Signed-off-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Russell King
     

27 Mar, 2018

1 commit

  • In the event where the device unexpectedly becomes unresponsive
    for a long period of time, flow control mechanism may propagate
    pause frames which will cause congestion spreading to the entire
    network.
    To prevent this scenario, when the device is stalled for a period
    longer than a pre-configured timeout, flow control mechanisms are
    automatically disabled.

    This patch adds support for the ETHTOOL_PFC_STALL_PREVENTION
    as a tunable.
    This API provides support for configuring flow control storm prevention
    timeout (msec).

    Signed-off-by: Inbar Karmy
    Cc: Michal Kubecek
    Cc: Andrew Lunn
    Signed-off-by: Saeed Mahameed

    Inbar Karmy
     

09 Mar, 2018

1 commit

  • We use a two-step process to configure a filter with RSS spreading. First,
    the RSS context is allocated and configured using ETHTOOL_SRSSH; this
    returns an identifier (rss_context) which can then be passed to subsequent
    invocations of ETHTOOL_SRXCLSRLINS to specify that the offset from the RSS
    indirection table lookup should be added to the queue number (ring_cookie)
    when delivering the packet. Drivers for devices which can only use the
    indirection table entry directly (not add it to a base queue number)
    should reject rule insertions combining RSS with a nonzero ring_cookie.

    Signed-off-by: Edward Cree
    Signed-off-by: David S. Miller

    Edward Cree
     

02 Mar, 2018

1 commit


07 Feb, 2018

1 commit

  • with bitmap_{from,to}_arr32 over the kernel. Additionally to it:
    * __check_eq_bitmap() now takes single nbits argument.
    * __check_eq_u32_array is not used in new test but may be used in
    future. So I don't remove it here, but annotate as __used.

    Tested on arm64 and 32-bit BE mips.

    [arnd@arndb.de: perf: arm_dsu_pmu: convert to bitmap_from_arr32]
    Link: http://lkml.kernel.org/r/20180201172508.5739-2-ynorov@caviumnetworks.com
    [ynorov@caviumnetworks.com: fix net/core/ethtool.c]
    Link: http://lkml.kernel.org/r/20180205071747.4ekxtsbgxkj5b2fz@yury-thinkpad
    Link: http://lkml.kernel.org/r/20171228150019.27953-2-ynorov@caviumnetworks.com
    Signed-off-by: Yury Norov
    Signed-off-by: Arnd Bergmann
    Cc: Ben Hutchings
    Cc: David Decotigny ,
    Cc: David S. Miller ,
    Cc: Geert Uytterhoeven
    Cc: Matthew Wilcox
    Cc: Rasmus Villemoes
    Cc: Heiner Kallweit
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yury Norov
     

10 Jan, 2018

1 commit


09 Jan, 2018

1 commit


03 Jan, 2018

1 commit

  • In kernel log ths message appears on every boot:
    "warning: `NetworkChangeNo' uses legacy ethtool link settings API,
    link modes are only partially reported"

    When ethtool link settings API changed, it started complaining about
    usages of old API. Ironically, the original patch was from google but
    the application using the legacy API is chrome.

    Linux ABI is fixed as much as possible. The kernel must not break it
    and should not complain about applications using legacy API's.
    This patch just removes the warning since using legacy API's
    in Linux is perfectly acceptable.

    Fixes: 3f1ac7a700d0 ("net: ethtool: add new ETHTOOL_xLINKSETTINGS API")
    Signed-off-by: Stephen Hemminger
    Signed-off-by: David Decotigny
    Signed-off-by: David S. Miller

    Stephen Hemminger
     

19 Dec, 2017

1 commit

  • Introduce NETIF_F_GRO_HW feature flag for NICs that support hardware
    GRO. With this flag, we can now independently turn on or off hardware
    GRO when GRO is on. Previously, drivers were using NETIF_F_GRO to
    control hardware GRO and so it cannot be independently turned on or
    off without affecting GRO.

    Hardware GRO (just like GRO) guarantees that packets can be re-segmented
    by TSO/GSO to reconstruct the original packet stream. Logically,
    GRO_HW should depend on GRO since it a subset, but we will let
    individual drivers enforce this dependency as they see fit.

    Since NETIF_F_GRO is not propagated between upper and lower devices,
    NETIF_F_GRO_HW should follow suit since it is a subset of GRO. In other
    words, a lower device can independent have GRO/GRO_HW enabled or disabled
    and no feature propagation is required. This will preserve the current
    GRO behavior. This can be changed later if we decide to propagate GRO/
    GRO_HW/RXCSUM from upper to lower devices.

    Cc: Ariel Elior
    Cc: everest-linux-l2@cavium.com
    Signed-off-by: Michael Chan
    Acked-by: Alexander Duyck
    Signed-off-by: David S. Miller

    Michael Chan
     

22 Oct, 2017

2 commits

  • There were quite a few overlapping sets of changes here.

    Daniel's bug fix for off-by-ones in the new BPF branch instructions,
    along with the added allowances for "data_end > ptr + x" forms
    collided with the metadata additions.

    Along with those three changes came veritifer test cases, which in
    their final form I tried to group together properly. If I had just
    trimmed GIT's conflict tags as-is, this would have split up the
    meta tests unnecessarily.

    In the socketmap code, a set of preemption disabling changes
    overlapped with the rename of bpf_compute_data_end() to
    bpf_compute_data_pointers().

    Changes were made to the mv88e6060.c driver set addr method
    which got removed in net-next.

    The hyperv transport socket layer had a locking change in 'net'
    which overlapped with a change of socket state macro usage
    in 'net-next'.

    Signed-off-by: David S. Miller

    David S. Miller
     
  • Commit 9cab88726929605 ("net: ethtool: Add back transceiver type")
    restores the transceiver type to struct ethtool_link_settings and
    convert_link_ksettings_to_legacy_settings() but forgets to remove the
    error check for the same in convert_legacy_settings_to_link_ksettings().
    This prevents older versions of ethtool to change link settings.

    # ethtool --version
    ethtool version 3.16

    # ethtool -s eth0 autoneg on speed 100 duplex full
    Cannot set new settings: Invalid argument
    not setting speed
    not setting duplex
    not setting autoneg

    While newer versions of ethtool works.

    # ethtool --version
    ethtool version 4.10

    # ethtool -s eth0 autoneg on speed 100 duplex full
    [ 57.703268] sh-eth ee700000.ethernet eth0: Link is Down
    [ 59.618227] sh-eth ee700000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx

    Fixes: 19cab88726929605 ("net: ethtool: Add back transceiver type")
    Signed-off-by: Niklas Söderlund
    Reported-by: Renjith R V
    Tested-by: Geert Uytterhoeven
    Signed-off-by: David S. Miller

    Niklas Söderlund
     

18 Oct, 2017

1 commit

  • This function provides a way to intersect two link masks together to
    find the common ground between them. For example in i40e, the driver
    first generates link masks for what is supported by the PHY type. The
    driver then gets the link masks for what the NVM supports. The
    resulting intersection between them yields what can truly be supported.

    Signed-off-by: Alan Brady
    Tested-by: Andrew Bowers
    Signed-off-by: Jeff Kirsher

    Alan Brady
     

22 Sep, 2017

1 commit

  • Commit 3f1ac7a700d0 ("net: ethtool: add new ETHTOOL_xLINKSETTINGS API")
    deprecated the ethtool_cmd::transceiver field, which was fine in
    premise, except that the PHY library was actually using it to report the
    type of transceiver: internal or external.

    Use the first word of the reserved field to put this __u8 transceiver
    field back in. It is made read-only, and we don't expect the
    ETHTOOL_xLINKSETTINGS API to be doing anything with this anyway, so this
    is mostly for the legacy path where we do:

    ethtool_get_settings()
    -> dev->ethtool_ops->get_link_ksettings()
    -> convert_link_ksettings_to_legacy_settings()

    to have no information loss compared to the legacy get_settings API.

    Fixes: 3f1ac7a700d0 ("net: ethtool: add new ETHTOOL_xLINKSETTINGS API")
    Signed-off-by: Florian Fainelli
    Signed-off-by: David S. Miller

    Florian Fainelli
     

30 Jul, 2017

1 commit

  • Forward Error Correction (FEC) modes i.e Base-R
    and Reed-Solomon modes are introduced in 25G/40G/100G standards
    for providing good BER at high speeds. Various networking devices
    which support 25G/40G/100G provides ability to manage supported FEC
    modes and the lack of FEC encoding control and reporting today is a
    source for interoperability issues for many vendors.
    FEC capability as well as specific FEC mode i.e. Base-R
    or RS modes can be requested or advertised through bits D44:47 of
    base link codeword.

    This patch set intends to provide option under ethtool to manage
    and report FEC encoding settings for networking devices as per
    IEEE 802.3 bj, bm and by specs.

    set-fec/show-fec option(s) are designed to provide control and
    report the FEC encoding on the link.

    SET FEC option:
    root@tor: ethtool --set-fec swp1 encoding [off | RS | BaseR | auto]

    Encoding: Types of encoding
    Off : Turning off any encoding
    RS : enforcing RS-FEC encoding on supported speeds
    BaseR : enforcing Base R encoding on supported speeds
    Auto : IEEE defaults for the speed/medium combination

    Here are a few examples of what we would expect if encoding=auto:
    - if autoneg is on, we are expecting FEC to be negotiated as on or off
    as long as protocol supports it
    - if the hardware is capable of detecting the FEC encoding on it's
    receiver it will reconfigure its encoder to match
    - in absence of the above, the configuration would be set to IEEE
    defaults.

    >From our understanding , this is essentially what most hardware/driver
    combinations are doing today in the absence of a way for users to
    control the behavior.

    SHOW FEC option:
    root@tor: ethtool --show-fec swp1
    FEC parameters for swp1:
    Active FEC encodings: RS
    Configured FEC encodings: RS | BaseR

    ETHTOOL DEVNAME output modification:

    ethtool devname output:
    root@tor:~# ethtool swp1
    Settings for swp1:
    root@hpe-7712-03:~# ethtool swp18
    Settings for swp18:
    Supported ports: [ FIBRE ]
    Supported link modes: 40000baseCR4/Full
    40000baseSR4/Full
    40000baseLR4/Full
    100000baseSR4/Full
    100000baseCR4/Full
    100000baseLR4_ER4/Full
    Supported pause frame use: No
    Supports auto-negotiation: Yes
    Supported FEC modes: [RS | BaseR | None | Not reported]
    Advertised link modes: Not reported
    Advertised pause frame use: No
    Advertised auto-negotiation: No
    Advertised FEC modes: [RS | BaseR | None | Not reported]
    <<<< One or more FEC modes
    Speed: 100000Mb/s
    Duplex: Full
    Port: FIBRE
    PHYAD: 106
    Transceiver: internal
    Auto-negotiation: off
    Link detected: yes

    This patch includes following changes
    a) New ETHTOOL_SFECPARAM/SFECPARAM API, handled by
    the new get_fecparam/set_fecparam callbacks, provides support
    for configuration of forward error correction modes.
    b) Link mode bits for FEC modes i.e. None (No FEC mode), RS, BaseR/FC
    are defined so that users can configure these fec modes for supported
    and advertising fields as part of link autonegotiation.

    Signed-off-by: Vidya Sagar Ravipati
    Signed-off-by: Dustin Byford
    Signed-off-by: Roopa Prabhu
    Signed-off-by: David S. Miller

    Vidya Sagar Ravipati
     

25 Jul, 2017

1 commit


18 Jul, 2017

1 commit


30 Jun, 2017

1 commit


14 Apr, 2017

1 commit


10 Mar, 2017

1 commit


02 Mar, 2017

1 commit


08 Feb, 2017

1 commit


04 Feb, 2017

2 commits

  • We added generic support for busy polling in NAPI layer in linux-4.5

    No network driver uses ndo_busy_poll() anymore, we can get rid
    of the pointer in struct net_device_ops, and its use in sk_busy_loop()

    Saves NETIF_F_BUSY_POLL features bit.

    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     
  • If ->get_regs_len() callback return 0, we allocate 0 bytes of memory,
    what print ugly warning in dmesg, which can be found further below.

    This happen on mac80211 devices where ieee80211_get_regs_len() just
    return 0 and driver only fills ethtool_regs structure and actually
    do not provide any dump. However I assume this can happen on other
    drivers i.e. when for some devices driver provide regs dump and for
    others do not. Hence preventing to to print warning in ethtool code
    seems to be reasonable.

    ethtool: vmalloc: allocation failure: 0 bytes, mode:0x24080c2(GFP_KERNEL|__GFP_HIGHMEM|__GFP_ZERO)

    Call Trace:
    [] dump_stack+0x63/0x8c
    [] warn_alloc+0x13f/0x170
    [] __vmalloc_node_range+0x1e6/0x2c0
    [] vzalloc+0x54/0x60
    [] dev_ethtool+0xb4c/0x1b30
    [] dev_ioctl+0x181/0x520
    [] sock_do_ioctl+0x42/0x50

    Mem-Info:
    active_anon:435809 inactive_anon:173951 isolated_anon:0
    active_file:835822 inactive_file:196932 isolated_file:0
    unevictable:0 dirty:8 writeback:0 unstable:0
    slab_reclaimable:157732 slab_unreclaimable:10022
    mapped:83042 shmem:306356 pagetables:9507 bounce:0
    free:130041 free_pcp:1080 free_cma:0
    Node 0 active_anon:1743236kB inactive_anon:695804kB active_file:3343288kB inactive_file:787728kB unevictable:0kB isolated(anon):0kB isolated(file):0kB mapped:332168kB dirty:32kB writeback:0kB shmem:0kB shmem_thp: 0kB shmem_pmdmapped: 0kB anon_thp: 1225424kB writeback_tmp:0kB unstable:0kB pages_scanned:0 all_unreclaimable? no
    Node 0 DMA free:15900kB min:136kB low:168kB high:200kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB present:15984kB managed:15900kB mlocked:0kB slab_reclaimable:0kB slab_unreclaimable:0kB kernel_stack:0kB pagetables:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
    lowmem_reserve[]: 0 3187 7643 7643
    Node 0 DMA32 free:419732kB min:28124kB low:35152kB high:42180kB active_anon:541180kB inactive_anon:248988kB active_file:1466388kB inactive_file:389632kB unevictable:0kB writepending:0kB present:3370280kB managed:3290932kB mlocked:0kB slab_reclaimable:217184kB slab_unreclaimable:4180kB kernel_stack:160kB pagetables:984kB bounce:0kB free_pcp:2236kB local_pcp:660kB free_cma:0kB
    lowmem_reserve[]: 0 0 4456 4456

    Signed-off-by: Stanislaw Gruszka
    Signed-off-by: David S. Miller

    Stanislaw Gruszka
     

01 Feb, 2017

1 commit

  • under memory pressure 'ethtool -S' command may warn:
    [ 2374.385195] ethtool: page allocation failure: order:4, mode:0x242c0c0
    [ 2374.405573] CPU: 12 PID: 40211 Comm: ethtool Not tainted
    [ 2374.423071] Call Trace:
    [ 2374.423076] [] dump_stack+0x4d/0x64
    [ 2374.423080] [] warn_alloc_failed+0xeb/0x150
    [ 2374.423082] [] ? __alloc_pages_direct_compact+0x43/0xf0
    [ 2374.423084] [] __alloc_pages_nodemask+0x4dc/0xbf0
    [ 2374.423091] [] ? cmd_exec+0x722/0xcd0 [mlx5_core]
    [ 2374.423095] [] alloc_pages_current+0x8c/0x110
    [ 2374.423097] [] alloc_kmem_pages+0x19/0x90
    [ 2374.423099] [] kmalloc_order_trace+0x2e/0xe0
    [ 2374.423101] [] __kmalloc+0x204/0x220
    [ 2374.423105] [] dev_ethtool+0xe4e/0x1f80
    [ 2374.423106] [] ? dev_get_by_name_rcu+0x5e/0x80
    [ 2374.423108] [] dev_ioctl+0x156/0x560
    [ 2374.423111] [] ? mem_cgroup_commit_charge+0x78/0x3c0
    [ 2374.423117] [] sock_do_ioctl+0x42/0x50
    [ 2374.423119] [] sock_ioctl+0x1b3/0x250
    [ 2374.423121] [] do_vfs_ioctl+0x92/0x580
    [ 2374.423123] [] ? do_audit_syscall_entry+0x4b/0x70
    [ 2374.423124] [] ? syscall_trace_enter_phase1+0xfc/0x120
    [ 2374.423126] [] SyS_ioctl+0x79/0x90
    [ 2374.423127] [] do_syscall_64+0x50/0xa0
    [ 2374.423129] [] entry_SYSCALL64_slow_path+0x25/0x25

    ~1160 mlx5 counters ~= order 4 allocation which is unlikely to succeed
    under memory pressure. Convert them to vzalloc() as ethtool_get_regs() does.
    Also take care of drivers without counters similar to
    commit 67ae7cf1eeda ("ethtool: Allow zero-length register dumps again")
    and reduce warn_on to warn_on_once.

    Signed-off-by: Alexei Starovoitov
    Signed-off-by: David S. Miller

    Alexei Starovoitov
     

19 Jan, 2017

1 commit

  • Ethtool channels respond struct was uninitialized when querying device
    channel boundaries settings. As a result, unreported fields by the driver
    hold garbage. This may cause sending unsupported params to driver.

    Fixes: 8bf368620486 ('ethtool: ensure channel counts are within bounds ...')
    Signed-off-by: Eran Ben Elisha
    Signed-off-by: Tariq Toukan
    CC: John W. Linville
    Signed-off-by: David S. Miller

    Eran Ben Elisha
     

27 Nov, 2016

1 commit


26 Nov, 2016

1 commit


25 Nov, 2016

1 commit

  • PHY drivers should be able to rely on the caller of {get,set}_tunable to
    have acquired the PHY device mutex, in order to both serialize against
    concurrent calls of these functions, but also against PHY state machine
    changes. All ethtool PHY-level functions do this, except
    {get,set}_tunable, so we make them consistent here as well.

    We need to update the Microsemi PHY driver in the same commit to avoid
    introducing either deadlocks, or lack of proper locking.

    Fixes: 968ad9da7e0e ("ethtool: Implements ETHTOOL_PHY_GTUNABLE/ETHTOOL_PHY_STUNABLE")
    Fixes: 310d9ad57ae0 ("net: phy: Add downshift get/set support in Microsemi PHYs driver")
    Signed-off-by: Florian Fainelli
    Reviewed-by: Andrew Lunn
    Reviewed-by: Allan W. Nielsen
    Signed-off-by: David S. Miller

    Florian Fainelli
     

19 Nov, 2016

2 commits