From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=220.197.31.5 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795961561; b=GByEKCSnugvixXkpJz3ZMuUuJPscsKG/vXTsx/TwlKrzoWNsYBpkaxAZFD//iquPx0dR PNDtPCoDb/Bh3uQt9YjrWr1KmMcsHTHUdLa2ZFIGQdkz8L5uoA2Gj+O1l6UIvCh6IU51D Y8wYEFIbJMcH7CwBVDMyHs7Ak7sExTixDpQZb4kgKtUSVT7pV3gtbU3f/cHyJ3DPOr3VG lcQKHVDPSc+0ACEu5KVKtprJrPHq5XtSTc1czv8FYlC+nMDCRlLJH0WLleUgXUAnwC9OU PQocI+y+dh10ZLJTLUQwpHBzzShhXExEBfmZrIwzWlE5TNJl02ss6pp6DvrKvwkGDow== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795961561; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-CM-TRANSID:X-Coremail-Antispam:X-CM-SenderInfo; bh=6nXPRHq8ZJBqZ5tjpgPZEoglfEkxY5+Ah080Yn8MgkU=; b=Qxr7DTLA8ErZNjoyXtmg5mmM6SeZOPCD9eXwoq3nJS24+E7Ayx/9NPjjXiI6VDxXx/E8 xaFJinCZm2q8JjRf9hGYbQN7oiOBULhq9qczCoe6/MU/5pV/mlH5qBKnkJXZ8647ya6Rm uby2yQoHbMtt35O8lt6p6uQTVIQmxB3/pmp0ul8SmLAUibNufYIuOCLDy90MxI7q/3nzF pGE1sKg2QCSupsJUPtj6/Lv1CjV505ATia8tG0KA0/PngvVbeD4k3Tz52+bT0B7K4GhmH yOYBzdrvh8N6Z+nO18IVSlBKEX3aFvxwOuFf7VbxEnNASwXGrA1R0o4IZ2PrNwQ8iHA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=VFx93gxH; arc=none smtp.remote-ip=220.197.31.5 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7355A606A31C; Sun, 29 Nov 2026 14:12:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7355A606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=VFx93gxH DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=6n XPRHq8ZJBqZ5tjpgPZEoglfEkxY5+Ah080Yn8MgkU=; b=VFx93gxHtueIVfxH9F uqd+XGMfJElUaq2UY1e0lej58F/7c+2vXE7UlbakVSXKZq+Vq5mf/jiaoRyyt+2q kkied/V7OsvzGEzLhLKsbovOXNlRPg1BIB9h1ryUqRiRsNAhnCw8f1/9q5SHC+tG lQCwpJ8z4wvF8csJ21dSZArNA= Received: from iZbp142fio164970eurit1Z.. (unknown []) by gzga-smtp-mtada-g1-0 (Coremail) with SMTP id _____wD3PxKLMgxrIbd7KQ--.48069S2; Sun, 29 Nov 2026 22:11:24 +0800 (CST) From: linfordWu To: Johan Hovold , Alex Elder , Greg Kroah-Hartman Cc: greybus-dev@lists.linaro.org, linux-kernel@vger.kernel.org, linfordWu , syzbot+61464b62b688791cc24c@syzkaller.appspotmail.com, syzbot+a2e50fb40695811c2dab@syzkaller.appspotmail.com, stable@vger.kernel.org Subject: [PATCH] greybus: operation: fix request timeout race Date: Sun, 29 Nov 2026 22:11:23 +0800 Message-ID: <20261129141123.2172008-1-linfordwu@163.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wD3PxKLMgxrIbd7KQ--.48069S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7try7urWrJw1fArWDWFWkCrg_yoW8tFyfpF WUKw1IkF1Fqr10vw48AayDZr90vw1xGa9rGrs7JwnYyFsFqF1UtF1vvrW29FW5Jr1UWr12 qFs8trnxC3W8uF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pEAhLnUUUUU= X-CM-SenderInfo: xolqw0pugz3qqrwthudrp/xtbCzw2NLWsMMo3qPgAA3u A request can complete after gb_message_send() returns but before its timeout timer is armed. The completion worker then finds no timer to delete, and the request path can leave an active timer in an operation that is about to be freed. Check the result and arm the timer while holding gb_operations_lock, which also protects result updates. If completion has already happened, leave the timer unarmed. Otherwise the completion worker will delete the armed timer as before. Reported-by: syzbot+61464b62b688791cc24c@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=61464b62b688791cc24c Reported-by: syzbot+a2e50fb40695811c2dab@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=a2e50fb40695811c2dab Fixes: dbec27298b0d ("staging: greybus: operation: add generic timeout support") Link: https://lore.kernel.org/all/20261022134817.1703927-1-hackerowskiy@gmail.com/ Link: https://lore.kernel.org/all/20261103-gb-uart-transport-v5-3-f8e326d6561f@beagleboard.org/ Cc: stable@vger.kernel.org Signed-off-by: linfordWu --- drivers/greybus/operation.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/greybus/operation.c b/drivers/greybus/operation.c index 7e12ffb2dd6..7d4006f4bbd 100644 --- a/drivers/greybus/operation.c +++ b/drivers/greybus/operation.c @@ -725,6 +725,7 @@ int gb_operation_request_send(struct gb_operation *operation, { struct gb_connection *connection = operation->connection; struct gb_operation_msg_hdr *header; + unsigned long flags; unsigned int cycle; int ret; @@ -771,8 +772,12 @@ int gb_operation_request_send(struct gb_operation *operation, goto err_put_active; if (timeout) { - operation->timer.expires = jiffies + msecs_to_jiffies(timeout); - add_timer(&operation->timer); + spin_lock_irqsave(&gb_operations_lock, flags); + if (operation->errno == -EINPROGRESS) { + operation->timer.expires = jiffies + msecs_to_jiffies(timeout); + add_timer(&operation->timer); + } + spin_unlock_irqrestore(&gb_operations_lock, flags); } return 0; -- 2.43.0