RE: [PATCH] hyper-v: Check for ring buffer in hv_get_bytes_to_read/write

From: Michael Kelley
Date: Thu Mar 07 2019 - 12:33:25 EST


From: Mohammed Gamal <mgamal@xxxxxxxxxx> Sent: Thursday, March 7, 2019 8:36 AM
>
> This patch adds a check for the presence of the ring buffer in
> hv_get_bytes_to_read/write() to avoid possible NULL pointer dereferences.
> If the ring buffer is not yet allocated, return 0 bytes to be read/written.
>
> The root cause is that code that accesses the ring buffer including
> hv_get_bytes_to_read/write() could be vulnerable to the race condition
> discussed in https://lkml.org/lkml/2018/10/18/779>
>
> This race is being addressed by the patch series by Kimberly Brown in
> https://lkml.org/lkml/2019/2/21/1236 which is not final yet
>
> Signed-off-by: Mohammed Gamal <mgamal@xxxxxxxxxx>

Could you elaborate on the code paths where
hv_get_bytes_to_read/write() could be called when the ring buffer
isn't yet allocated? My sense is that Kim Brown's patch will address
all of the code paths that involved sysfs access from outside the
driver. And within a driver, the ring buffer should never be accessed
unless it is already allocated. Is there another code path we're not
aware of? I'm wondering if these changes are really needed once
Kim Brown's patch is finished.

Michael