From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BACF7C36010 for ; Fri, 4 Apr 2025 12:45:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3305F280004; Fri, 4 Apr 2025 08:45:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E046280001; Fri, 4 Apr 2025 08:45:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1817F280004; Fri, 4 Apr 2025 08:45:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id ED0E0280001 for ; Fri, 4 Apr 2025 08:45:17 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 575BB1CEA36 for ; Fri, 4 Apr 2025 12:45:19 +0000 (UTC) X-FDA: 83296331958.28.76D2DF9 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf29.hostedemail.com (Postfix) with ESMTP id EE72C12000E for ; Fri, 4 Apr 2025 12:45:16 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=J1tE6dZQ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=eJZCu3EU; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=J1tE6dZQ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=eJZCu3EU; spf=pass (imf29.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743770717; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qiLQsqtXEWkIF6Tu5ENuyz8lIzD9QOQAHlLDgCNQ1k4=; b=xhwkE6o2jZh18qWB70kQn/mZyvzIoKfPw0c4AvaCcrX2anqFiAqpPutJn5TkOoggxu5i3g EShrTSNgVC84R1k582Fqex0vf3IAs9RhXE82xOVJONlbChaWg7PkuiggtmcQ7lAD3AfBan d2cU6Gcz7IVwA+GjGXjjIvXO3VXcfUc= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=J1tE6dZQ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=eJZCu3EU; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=J1tE6dZQ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=eJZCu3EU; spf=pass (imf29.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743770717; a=rsa-sha256; cv=none; b=ccJAQpDvCGJh5iVqLz3NbN32BgWvXPNXjRoc+HFproxsY6IXV1ZLy/NPj/59zeJa1C+93c NjsykMr2kQ1CAugE/gCgBYjfG7YNAINV2M20yIDRRBzYx/73ers/N1AHh9aM1teYxp59qL gvfHQrjt9/ttm7qZepUpAyhmnMtXA9I= Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 42D76211C4; Fri, 4 Apr 2025 12:45:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1743770715; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qiLQsqtXEWkIF6Tu5ENuyz8lIzD9QOQAHlLDgCNQ1k4=; b=J1tE6dZQ2QbUKImOIPkl+LObyCwNygYVW3hUrl8HVsWEG43jWO0yoqxXZqly89NcY7nvLr Dt7FBNsytkWlzmKG0f+c8IIOEnBz3lLPuUnoVnabkyVaN6KwGC6uvQPc3zFUYbh56XRORb GeFCXTOQJEaQYqP49YIgpodYNROBl8M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1743770715; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qiLQsqtXEWkIF6Tu5ENuyz8lIzD9QOQAHlLDgCNQ1k4=; b=eJZCu3EUnhmgP3B0lcn8UOMLi3/bPYeCn+DCTKsh/WLcEiwBxe71/2Fe+dh90U+IJy3CF6 KKMdKksaIeuPVDDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1743770715; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qiLQsqtXEWkIF6Tu5ENuyz8lIzD9QOQAHlLDgCNQ1k4=; b=J1tE6dZQ2QbUKImOIPkl+LObyCwNygYVW3hUrl8HVsWEG43jWO0yoqxXZqly89NcY7nvLr Dt7FBNsytkWlzmKG0f+c8IIOEnBz3lLPuUnoVnabkyVaN6KwGC6uvQPc3zFUYbh56XRORb GeFCXTOQJEaQYqP49YIgpodYNROBl8M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1743770715; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qiLQsqtXEWkIF6Tu5ENuyz8lIzD9QOQAHlLDgCNQ1k4=; b=eJZCu3EUnhmgP3B0lcn8UOMLi3/bPYeCn+DCTKsh/WLcEiwBxe71/2Fe+dh90U+IJy3CF6 KKMdKksaIeuPVDDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2745613691; Fri, 4 Apr 2025 12:45:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id F20+CVvU72dMTgAAD6G6ig (envelope-from ); Fri, 04 Apr 2025 12:45:15 +0000 Message-ID: Date: Fri, 4 Apr 2025 14:45:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: slub - extended kmalloc redzone and dma alignment Content-Language: en-US To: Petr Tesarik , Harry Yoo Cc: Feng Tang , Peng Fan , Hyeonggon Yoo <42.hyeyoo@gmail.com>, David Rientjes , Christoph Lameter , "linux-mm@kvack.org" , Catalin Marinas References: <20250404131239.2a987e58@mordecai> From: Vlastimil Babka In-Reply-To: <20250404131239.2a987e58@mordecai> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: EE72C12000E X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: hynm3s8tsihcfjw3cs5u1wwgwpxabb9o X-HE-Tag: 1743770716-927007 X-HE-Meta: U2FsdGVkX1/d3s6X6XmTMUuc3LtKMlRp3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xJ7XN5cbWUYFNiDvsKcIKkfYSvSIdWtMXYFHc2WwXTGSElZoe5JLp6h40SvXGoWhxvV0e7HDNxvGmRMc7YYugqW0Q3KOkShauu1jVzudq+EB720EarDPLSp5VeQy2s7IigQ/Zzgt0KcsrbQEEZjNv+6uTgXoMtDh+x+6s2Q2H69L3lvjr5Mb2lob8cXuH2JlgR1Xq8pq0d9I4WQNdy0xqDU2gUPLEJC2DKWOs2hs2pgBSH+ZgI4dmpICOL4aurWhpI6d1VsZ343lcjrKsvgtWuJlFm3L/xI1WZAWmd1itMrlkxYXpTTwKM3Mvvwg1tLlFWsxAIat2v9W8vDtNli9TmdYUR9YoWffMnnMKMMsHsc1eFpwQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 4/4/25 13:12, Petr Tesarik wrote: > On Fri, 4 Apr 2025 19:30:09 +0900 > Harry Yoo wrote: > >> On Fri, Apr 04, 2025 at 11:30:49AM +0200, Vlastimil Babka wrote: >> > Hi, >> > >> > due to some off-list inquiry I have realized that since 946fa0dbf2d8 >> > ("mm/slub: extend redzone check to extra allocated kmalloc space than >> > requested") >> > we might be reporting false positives due to dma writing into the redzone. >> > >> > It wasn't confirmed (yet) during the conversation but AFAICS it can be >> > happening. We have this ARCH_DMA_MINALIGN and kmalloc() will guarantee it, >> > but the redzone check doesn't take it into account. >> >> Sounds valid to me. > > I'm not sure I understand your concerns. I'd be happy to be proven wrong and you're more familiar with DMA details than me :) > Are you afraid that another device on the bus caches a copy of the > redzone before it was poisoned, so it overwrites the redzone with stale > data on a memory write operation? IMO that's buggy, because if a > bus-mastering device implements such cache, it is the device driver's > responsibility to flush it before starting a DMA transfer. FTR I'm not > aware of any such devices, except GPUs, but there's a whole lot to do > about CPU<->GPU coherency management, including device-specific ioctl's > to expose some gory details all the way down to userspace. OK, guess not that. > Or are you concerned about bus data word size? I would again argue that > allocating a DMA buffer with a size that is not a multiple of the > transfer size is a bug. IOW the driver must make sure the buffer size > is a multiple of 4 if it is used for 32-bit DMA transfers, or a > multiple of 8 if it is used for 64-bit DMA transfers. Yeah I think it's that, and I thought drivers don't need to care themselves because ARCH_DMA_MINALIGN means kmalloc() layer provides that guarantee itself. I also remember this series (incidentally just recently the discussion was revived). https://lore.kernel.org/all/20230612153201.554742-1-catalin.marinas@arm.com/ > Confused. > > Petr T