From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.81 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796390972; b=g9fKIDDQvt9/n9M2B9ZFEp00eGmbKBJ+03zlMB5wZcB9tYHjal45vP7dY/9C1IqQVoJS qNh9xJHAk2WiBLyYCc0c/YKtzZWgtXYIYRj7Cd5w5GVm7bn+g9pMF8bI+Hwtkjm2uLTYO D4pPursq8lDYMxmB4l4GFic+b8k5dkKYTOOEFYi8L29ZBgKfER5pFB3hCRMspFjRUWRhV 86TAyvy80zUTmLv0XDL8VjmQ56wlaTs3VXoUApY1VkSbR4sg1X9OOoGpgDe9bcucX4NIJ 4Tejvh9cwxqIvadC7CR0N9WJiuic8CAPPJI2dF5gxwO/riB87T0DeDkElsNERA5D+bQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796390972; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=QLUHuZeqgf7Nr//7WpI9gRTQAENX2pPrpvR+XmPwfko=; b=olm3bFLuN/ovDJo2IqJLOf8v/g+JocWG4N/lGNIPlYl3A/LCvRAKxg9aX3fQuEgZPJjX 0U8jh8Oc4WbkyeMhE5Ejfw97fBDKOolKDVop7iCux4PVCIGh1lv7MiVVaqnO7gDuxuTRA Nlvn/WtFcoA5CvVDIiJgFz7poUCLlcDPkrChRqewjCtIIzBusbIIFug8tZ03i0vutFDZZ qyMttc0ZWMW9H6IPXjTK/YtgeofFQisc1YOBtnj0DpY8M+/ndSagPBqVMRUDdBliQr8ik QT8q63+S0WeNqw8A4RbLslJw0eIvk+96d7Wf6H3id/al+IRwYC68qzqT8cOsJecgK3Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=c+8PZjbu; arc=none smtp.remote-ip=95.215.58.81 Received: from mta1.migadu.com (out-81.mta1.migadu.com [95.215.58.81]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BDA9606A336 for ; Fri, 4 Dec 2026 13:29:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5BDA9606A336 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=c+8PZjbu X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=Fdn/4cH22BRLaDJ0d6JgpiTeackbleZ/MTJ1a/uR1UU=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796390969; v=1; x=1796995769; b=c+8PZjbuNcP4GBbcJijufTzrTTjndh8x/jnhe79rz+snV3ADjdZz7Ri5DhrmmSdN3riPmQxu MXzHPQ4HGmrlfbRlb35kc8aLu/PvJE4zHVQYf1PwJcsc08z+SQTdRCdPuLOqb1vWKrzq7pduFYK kIQI0CMi1JTGIow28nx+3Ai8= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id b8054e06b6fe9deb; Fri, 04 Dec 2026 13:29:29 +0000 X-Mizu-Trace-ID: b8054e06b6fe9deb X-Migadu-Flow: FLOW_OUT Message-ID: <5931a486-88be-4102-8f79-fffc4f74c890@linux.dev> Date: Fri, 4 Dec 2026 14:29:28 +0100 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH rdma-next] RDMA/siw: Fix overflow in inline SGE length check To: Andrew Stellman Cc: Jason Gunthorpe , Leon Romanovsky , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org References: <63fd6336-4370-4f2b-bcec-1e18c6b5ce84@linux.dev> <20261202194829.5633-1-bugs@stellman-greene.com> From: Bernard Metzler In-Reply-To: <20261202194829.5633-1-bugs@stellman-greene.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 02.12.2026 20:48, Andrew Stellman wrote: > On Wed, Dec 02, 2026 at 07:18:50PM +0100, Bernard Metzler wrote: >> The bug is that 'bytes' is declared signed while 'core_sge->length' >> is unsigned. Just make it unsigned as well. > > Thanks, Bernard. I tried that. With 'bytes' as unsigned int, the same > test (inline SGE lengths 16 and 0xfffffff8) still posted and KASAN still > reported the out-of-bounds write, because the sum wraps to 8. With > 'bytes' as u64 it returned -EINVAL and KASAN was quiet, the same as v1. > Would you rather have the u64 version, or keep v1's check before the > addition? > > Andrew You are right. The overflow may occure when a huge second SGE comes in. This is all very theoretical for trusted kernel clients. It cannot happen at all for user land clients, since inline WR representation is restricted to just one SGE at the send queue. I'd prefer to make bytes an unsigned 64. It just looks more clean to me than substracting and testing before addition. Thanks, Bernard.