lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdWovmqqgrOvtA=cyineJigwOtv-tGwz_PBVRFrgtryumw@mail.gmail.com>
Date:   Thu, 5 Apr 2018 15:13:13 +0200
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     Tal Gilboa <talgi@...lanox.com>
Cc:     netdev <netdev@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: net_dim() may use uninitialized data

Hi Tal,

With gcc-4.1.2:

    drivers/net/ethernet/broadcom/bcmsysport.c: In function ‘bcm_sysport_poll’:
    include/linux/net_dim.h:354: warning: ‘curr_stats.ppms’ may be
used uninitialized in this function
    include/linux/net_dim.h:354: warning: ‘curr_stats.bpms’ may be
used uninitialized in this function
    include/linux/net_dim.h:354: warning: ‘curr_stats.epms’ may be
used uninitialized in this function

Indeed, ...

| static inline void net_dim_calc_stats(struct net_dim_sample *start,
|                                       struct net_dim_sample *end,
|                                       struct net_dim_stats *curr_stats)
| {
|         /* u32 holds up to 71 minutes, should be enough */
|         u32 delta_us = ktime_us_delta(end->time, start->time);
|         u32 npkts = BIT_GAP(BITS_PER_TYPE(u32), end->pkt_ctr, start->pkt_ctr);
|         u32 nbytes = BIT_GAP(BITS_PER_TYPE(u32), end->byte_ctr,
|                              start->byte_ctr);
|
|         if (!delta_us)
|                 return;

... if delta_us is zero, none of the below will be initialized ...

|         curr_stats->ppms = DIV_ROUND_UP(npkts * USEC_PER_MSEC, delta_us);
|         curr_stats->bpms = DIV_ROUND_UP(nbytes * USEC_PER_MSEC, delta_us);
|         curr_stats->epms = DIV_ROUND_UP(NET_DIM_NEVENTS * USEC_PER_MSEC,
|                                         delta_us);
| }
|
| static inline void net_dim(struct net_dim *dim,
|                            struct net_dim_sample end_sample)
| {
|         struct net_dim_stats curr_stats;
|         u16 nevents;
|
|         switch (dim->state) {
|         case NET_DIM_MEASURE_IN_PROGRESS:
|                 nevents = BIT_GAP(BITS_PER_TYPE(u16),
|                                   end_sample.event_ctr,
|                                   dim->start_sample.event_ctr);
|                 if (nevents < NET_DIM_NEVENTS)
|                         break;
|                 net_dim_calc_stats(&dim->start_sample, &end_sample,
|                                    &curr_stats);

... in the output parameter curr_stats ...

|                 if (net_dim_decision(&curr_stats, dim)) {

... and net_dim_decision will make some funky decisions based on
uninitialized data.

What are the proper values to initialize curr_stats with?
Alternatively, perhaps the call to net_dim_decision() should be made
dependent on delta_us being non-zero?

|                         dim->state = NET_DIM_APPLY_NEW_PROFILE;
|                         schedule_work(&dim->work);
|                         break;
|                 }
|                 /* fall through */
|         case NET_DIM_START_MEASURE:
|                 dim->state = NET_DIM_MEASURE_IN_PROGRESS;
|                 break;
|         case NET_DIM_APPLY_NEW_PROFILE:
|                 break;
|         }
| }

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ