Skip to content

Commit 9031626

Browse files
quic-lxu5gregkh
authored andcommitted
misc: fastrpc: Fix fastrpc_map_lookup operation
Fastrpc driver creates maps for user allocated fd buffers. Before creating a new map, the map list is checked for any already existing maps using map fd. Checking with just map fd is not sufficient as the user can pass offsetted buffer with less size when the map is created and then a larger size the next time which could result in memory issues. Check for dma_buf object also when looking up for the map. Fixes: c68cfb7 ("misc: fastrpc: Add support for context Invoke method") Cc: stable@kernel.org Co-developed-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com> Signed-off-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com> Signed-off-by: Ling Xu <quic_lxu5@quicinc.com> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Signed-off-by: Srinivas Kandagatla <srini@kernel.org> Link: https://lore.kernel.org/r/20250912131236.303102-3-srini@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8b5b456 commit 9031626

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/misc/fastrpc.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,16 @@ static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd,
367367
{
368368
struct fastrpc_session_ctx *sess = fl->sctx;
369369
struct fastrpc_map *map = NULL;
370+
struct dma_buf *buf;
370371
int ret = -ENOENT;
371372

373+
buf = dma_buf_get(fd);
374+
if (IS_ERR(buf))
375+
return PTR_ERR(buf);
376+
372377
spin_lock(&fl->lock);
373378
list_for_each_entry(map, &fl->maps, node) {
374-
if (map->fd != fd)
379+
if (map->fd != fd || map->buf != buf)
375380
continue;
376381

377382
if (take_ref) {

0 commit comments

Comments
 (0)