Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6635223rdb; Tue, 2 Jan 2024 08:11:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IFW+xyR4mtXVTDg1j1povQf23iROzjBJV5OrKHp10p8HsBYLgWZupA5si53ZexPv807vGnN X-Received: by 2002:a17:906:b0c7:b0:a27:97a5:2424 with SMTP id bk7-20020a170906b0c700b00a2797a52424mr6575355ejb.41.1704211866067; Tue, 02 Jan 2024 08:11:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704211866; cv=none; d=google.com; s=arc-20160816; b=ATyqGgImtQltkahblRzfeJNH2kksrdBu4sHFdeP62c2ghS/Oe2Y3m0kUTsRoFzy43M 2wkpOgv8UhFF0fFH+FBYKjqMc+XmZq3rQqSlcena4a+CalFiG5PT31JLhkHqfwPxmWIR Fp9AU4BhnfRVspyzEqo3qJg+PM2JGlDobVDaIAGWFJzyuzHXJ/ygGLknkNcqD8TsEnMh uBPMYtC5atNiZh5v1BC7f2pDJYVNEELYBA+NjIIZcn60YxtTJwijD3ZJLb2om+nUggpo IeuuEx4x0bBYypGeh/cQq5QvBGMVmwIeJ7e61f/eX5p3ICrK75e9bw2KiE0mAsrMLoz1 pTjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature :dkim-signature:dkim-signature:dkim-signature; bh=XVgL7DZ8mWAYcWGWuopXqY0ECrWRGDftGwQn5Ry+vCc=; fh=gtwm6qN9lskLrXqGcgQSmKN+lN7yfNQhDGa14RKei7M=; b=x1vyfDxCtasHNTXnh72nWL5Mn5RsdU0PRgQqAj0CFETNSAiNXA+JLZ2AkRjK0lGyfR 1w7yfDfnE3kOFgV1sy4NDIf5mxd7m+CEyQXAtpix9znAaZ0I8CaVsSn7pGxa0u5zUaZ4 IX1mbeZIyh3wtFBR3qMaKPWd9PAlDAiHZiDcbBb/AGFGBzQk0HIoTJe6eDwlrhwQznzN gKuGjAIddeVJHXiZ1YzPmwlIc3iu4FRRhKkKK5V++stIZx2Uj7rsFki2wVKd9jVppcC4 YgWzAr6as92nY6jKgXxvYGPqLicfxkxQ8qOFCrfG2hZmvg1s5gxxjEOmpf482STTH8Wd Uv6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=qjgwENPJ; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=qjgwENPJ; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel+bounces-14588-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14588-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gi31-20020a1709070c9f00b00a234b6bc08csi10288834ejc.262.2024.01.02.08.11.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 08:11:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14588-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=qjgwENPJ; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=qjgwENPJ; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel+bounces-14588-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14588-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 83B021F2303C for ; Tue, 2 Jan 2024 16:11:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 542A614F6A; Tue, 2 Jan 2024 16:10:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="qjgwENPJ"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="1QTZh1Yz"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="qjgwENPJ"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="1QTZh1Yz" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9476A14F63; Tue, 2 Jan 2024 16:10:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 7B815210E9; Tue, 2 Jan 2024 16:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1704211853; 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=XVgL7DZ8mWAYcWGWuopXqY0ECrWRGDftGwQn5Ry+vCc=; b=qjgwENPJL3wvMdNf1NQhTmCqxbErIBXz24k4rN4DaX8Q5CwLgaz4bwpltIn0tDfDqPzD0q oCNjnuCrbFOEt77QCSj1nLpB3YK9GmA4gkeNYKtJjDOh/ilZqZef4tiMDP3lngyaY1Jjuo eIub1M3AYlqebWMB+WJwQwa9FNTfGl4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1704211853; 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=XVgL7DZ8mWAYcWGWuopXqY0ECrWRGDftGwQn5Ry+vCc=; b=1QTZh1YzMctn1TSoUf76eKlcAMwAyYKRbp3bUfKTABE4vhTVaUFKh8kGh5RP0RXhdSUjuN YcXEArQXJRnMziAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1704211853; 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=XVgL7DZ8mWAYcWGWuopXqY0ECrWRGDftGwQn5Ry+vCc=; b=qjgwENPJL3wvMdNf1NQhTmCqxbErIBXz24k4rN4DaX8Q5CwLgaz4bwpltIn0tDfDqPzD0q oCNjnuCrbFOEt77QCSj1nLpB3YK9GmA4gkeNYKtJjDOh/ilZqZef4tiMDP3lngyaY1Jjuo eIub1M3AYlqebWMB+WJwQwa9FNTfGl4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1704211853; 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=XVgL7DZ8mWAYcWGWuopXqY0ECrWRGDftGwQn5Ry+vCc=; b=1QTZh1YzMctn1TSoUf76eKlcAMwAyYKRbp3bUfKTABE4vhTVaUFKh8kGh5RP0RXhdSUjuN YcXEArQXJRnMziAA== 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 454BD1340C; Tue, 2 Jan 2024 16:10:53 +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 f9+XEI01lGWlegAAD6G6ig (envelope-from ); Tue, 02 Jan 2024 16:10:53 +0000 Message-ID: Date: Tue, 2 Jan 2024 17:10:53 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 15/34] mm: slub: Unpoison the memchr_inv() return value Content-Language: en-US To: Ilya Leoshkevich , Alexander Gordeev , Alexander Potapenko , Andrew Morton , Christoph Lameter , David Rientjes , Heiko Carstens , Joonsoo Kim , Marco Elver , Masami Hiramatsu , Pekka Enberg , Steven Rostedt , Vasily Gorbik Cc: Christian Borntraeger , Dmitry Vyukov , Hyeonggon Yoo <42.hyeyoo@gmail.com>, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-s390@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Mark Rutland , Roman Gushchin , Sven Schnelle References: <20231213233605.661251-1-iii@linux.ibm.com> <20231213233605.661251-16-iii@linux.ibm.com> From: Vlastimil Babka In-Reply-To: <20231213233605.661251-16-iii@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: 1.37 X-Spamd-Result: default: False [1.37 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; MID_RHS_MATCH_FROM(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RL5nkphuxq5kxo98ppmuqoc8wo)]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; BAYES_HAM(-0.04)[58.94%]; RCPT_COUNT_TWELVE(0.00)[24]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[linux.ibm.com,google.com,gmail.com,googlegroups.com,vger.kernel.org,kvack.org,arm.com,linux.dev]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: * X-Spam-Flag: NO On 12/14/23 00:24, Ilya Leoshkevich wrote: > Even though the KMSAN warnings generated by memchr_inv() are suppressed > by metadata_access_enable(), its return value may still be poisoned. > > The reason is that the last iteration of memchr_inv() returns > `*start != value ? start : NULL`, where *start is poisoned. Because of > this, somewhat counterintuitively, the shadow value computed by > visitSelectInst() is equal to `(uintptr_t)start`. > > The intention behind guarding memchr_inv() behind > metadata_access_enable() is to touch poisoned metadata without > triggering KMSAN, so unpoison its return value. > > Signed-off-by: Ilya Leoshkevich Acked-by: Vlastimil Babka > --- > mm/slub.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/mm/slub.c b/mm/slub.c > index 2d29d368894c..802702748925 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -1076,6 +1076,7 @@ static int check_bytes_and_report(struct kmem_cache *s, struct slab *slab, > metadata_access_enable(); > fault = memchr_inv(kasan_reset_tag(start), value, bytes); > metadata_access_disable(); > + kmsan_unpoison_memory(&fault, sizeof(fault)); > if (!fault) > return 1; > > @@ -1182,6 +1183,7 @@ static void slab_pad_check(struct kmem_cache *s, struct slab *slab) > metadata_access_enable(); > fault = memchr_inv(kasan_reset_tag(pad), POISON_INUSE, remainder); > metadata_access_disable(); > + kmsan_unpoison_memory(&fault, sizeof(fault)); > if (!fault) > return; > while (end > fault && end[-1] == POISON_INUSE)