-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
There is a missing validation for the input keyword strides passed to usm_ndarray constructor which can cause walking outside of the memory:
import dpctl, dpctl.tensor as dpt
dpctl.__version__
# Out: '0.22.0dev0+114.g0797836be2'
# create a buffer with ones
buf = dpt.ones(24, dtype=np.float64)
# new array points outside the buffer memory:
a = dpt.usm_ndarray((2, 3, 4), strides=(1, 16, 128), dtype=buf.dtype)
a
# Out:
# usm_ndarray([[[0., 0., 0., 0.],
# [0., 0., 0., 0.],
# [0., 0., 0., 0.]],
#
# [[0., 0., 0., 0.],
# [0., 0., 0., 0.],
# [0., 0., 0., 0.]]])
# new array points outside the buffer memory:
a = dpt.usm_ndarray((2, 3, 4), strides=(-1, 1, 1), dtype=buf.dtype)
a
# Out:
# usm_ndarray([[[0., 0., 0., 0.],
# [0., 0., 0., 0.],
# [0., 0., 0., 0.]],
#
# [[0., 0., 0., 0.],
# [0., 0., 0., 0.],
# [0., 0., 0., 0.]]])Metadata
Metadata
Assignees
Labels
No labels