[ofa-general] [PATCH] opensm/osm_ucast_lash: fix buffer overflow

Hal Rosenstock hal.rosenstock at gmail.com
Wed Oct 8 04:04:58 PDT 2008


Sasha,

On Tue, Oct 7, 2008 at 9:21 PM, Sasha Khapyorsky <sashak at voltaire.com> wrote:
>
> Lash first overflows its buffer and then check for the size (based on
> number VLs used). Fix the check order.
>
> Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
> ---
>  opensm/opensm/osm_ucast_lash.c |   13 ++++++-------
>  1 files changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/opensm/opensm/osm_ucast_lash.c b/opensm/opensm/osm_ucast_lash.c
> index ce3982f..03cfc1f 100644
> --- a/opensm/opensm/osm_ucast_lash.c
> +++ b/opensm/opensm/osm_ucast_lash.c
> @@ -979,6 +979,12 @@ static int lash_core(lash_t * p_lash)
>                                switches[dest_switch]->routing_table[i].lane = v_lane;
>
>                                if (cycle_found == 1 || cycle_found2 == 1) {
> +                                       if (lanes_needed + 1 > p_lash->vl_min) {
> +                                               lanes_needed++;
> +                                               goto Error_Not_Enough_Lanes;
> +                                       } else
> +                                               lanes_needed++;
> +
>                                        generate_cdg_for_sp(p_lash, i, dest_switch, v_lane);
>                                        generate_cdg_for_sp(p_lash, dest_switch, i, v_lane);
>
> @@ -987,13 +993,6 @@ static int lash_core(lash_t * p_lash)
>                                        set_temp_depend_to_permanent_for_sp(p_lash, dest_switch, i,
>                                                                            v_lane);
>
> -                                       if (lanes_needed + 1 > p_lash->vl_min) {
> -                                               lanes_needed++;
> -                                               goto Error_Not_Enough_Lanes;
> -                                       } else
> -                                               lanes_needed++;

Minor simplification as it seems like this could just be:

if (++lanes_needed > p_lash->vl_min)
  goto Error_Not_Enough_Lanes;

-- Hal

> -
> -                                       // goto error exit with message
>                                        p_lash->num_mst_in_lane[v_lane]++;
>                                        p_lash->num_mst_in_lane[v_lane]++;
>                                }
> --
> 1.6.0.1.196.g01914
>
> _______________________________________________
> general mailing list
> general at lists.openfabrics.org
> http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general
>
> To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general
>



More information about the general mailing list