From patchwork Tue Dec 19 21:19:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 181264 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2234722dyi; Tue, 19 Dec 2023 13:21:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEBM7vK7uzoBpsYWxmBGjs26chpcXf4RGpK8V3aopcJLdXCLpRaBvHqcrw9LFPy0qX/jB2Q X-Received: by 2002:a05:6358:2919:b0:170:b0fe:13a2 with SMTP id y25-20020a056358291900b00170b0fe13a2mr22675126rwb.17.1703020884334; Tue, 19 Dec 2023 13:21:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703020884; cv=none; d=google.com; s=arc-20160816; b=CV43LqhlKOP1YOkiPUkzj8aoajSQQ42SR9aa/E4vgrkIpSiA9D9O4qGNdbIctuhwV1 dsouByu1LMOtjRHAgAdhEnp8c00O09S7aWZkm5h6vqXBVA1ob4jgGpFl9ODkpB52Jzfj G+h4Xbs+BMlT4enpMRdRlUAKiHp8tL5Siro4vn+y6f/MjshvjjuT37aiwetD0nKe/0up fXP4eL2kN8xOCR1xOBoW2gOcvLkPXNPZV/gE8hfHNU1G4aeVUTP9yn11+fzupZ6cVgse qdkTnxcS1SdVQvp6YezQg3kO6ggZl+1fQiMcyTDxwbSU3kn7kn0bDTSMivaeKsD4ryuX mRaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fOHzqh8IZvvUQEcAVUngjlYsg+ArhHiPZJoDS72WUGY=; fh=R37Itr4vM4DSdM7nCVEJRaUzpyR01xRhpmD5Puf7xME=; b=R/Vwf07e52bXd/1A3I4Brk8RIml0VD5p0WrLmu5BOZvaT/TEBAqEUUjyHWRIfxhIj0 Su8fJRozcMdVvEtzHnEIkNLUjf4xE1/lPzjoHFeAvwBcUXifOfRoigDifrGy+ceuC/FP JDHemMLFFR4PP5XS+ng30pPII19tgFh1enk63VC9QsGVTGmmEWE6Y+CvJlOI9cbIJQq8 Fwg1n37F12N+gmdaV/p7IjK/whViU/VdsUEHUGGQBdX8dUDi+mBCzanDd4AJXCKXtQof GlmwSNQp2JUg8Q6CrnU5sBKfu/cMzgV92izOKJNCgkX/Ps+TGlocYOwHrPRoABMHz905 598Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=qSi6bCK8; spf=pass (google.com: domain of linux-kernel+bounces-5961-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5961-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 23-20020a630c57000000b005cd7c92f504si6533375pgm.481.2023.12.19.13.21.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 13:21:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5961-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=qSi6bCK8; spf=pass (google.com: domain of linux-kernel+bounces-5961-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5961-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 134CAB23FD4 for ; Tue, 19 Dec 2023 21:21:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E545B40C0F; Tue, 19 Dec 2023 21:20:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="qSi6bCK8" X-Original-To: linux-kernel@vger.kernel.org Received: from out-175.mta1.migadu.com (out-175.mta1.migadu.com [95.215.58.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 770AD3D0CE for ; Tue, 19 Dec 2023 21:20:00 +0000 (UTC) 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 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1703020798; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fOHzqh8IZvvUQEcAVUngjlYsg+ArhHiPZJoDS72WUGY=; b=qSi6bCK82bZzb5eDpiDbrLAgv900bdtXCroZwQk+HMxNuCcAH6RDEUBSEuZXglh3sQ52dp y4hliOr/Z2u8q2lAKSTk3GSjbIMKCqYtE46R+/r0JsXgn8CkNa8Ohm/TliCh9Gv/qOmJ9H dqjaS5WqDKLwR54ujuGm3mhTRxi7Yx0= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , Tetsuo Handa , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH v3 mm 3/4] kasan: memset free track in qlink_free Date: Tue, 19 Dec 2023 22:19:52 +0100 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785746826721293694 X-GMAIL-MSGID: 1785746826721293694 From: Andrey Konovalov Instead of only zeroing out the stack depot handle when evicting the free stack trace in qlink_free, zero out the whole track. Do this just to produce a similar effect for alloc and free meta. The other fields of the free track besides the stack trace handle are considered invalid at this point anyway, so no harm in zeroing them out. Fixes: 773688a6cb24 ("kasan: use stack_depot_put for Generic mode") Reviewed-by: Marco Elver Signed-off-by: Andrey Konovalov --- mm/kasan/quarantine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/kasan/quarantine.c b/mm/kasan/quarantine.c index 265ca2bbe2dd..782e045da911 100644 --- a/mm/kasan/quarantine.c +++ b/mm/kasan/quarantine.c @@ -157,7 +157,7 @@ static void qlink_free(struct qlist_node *qlink, struct kmem_cache *cache) if (free_meta && *(u8 *)kasan_mem_to_shadow(object) == KASAN_SLAB_FREETRACK) { stack_depot_put(free_meta->free_track.stack); - free_meta->free_track.stack = 0; + __memset(&free_meta->free_track, 0, sizeof(free_meta->free_track)); } /*