From patchwork Fri Oct 6 15:18:44 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: 149300 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp405036vqo; Fri, 6 Oct 2023 08:19:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEiZu+7lcn9XvanpQwSqGfrKAyiu7y9DPLl65h+kXKub9afqyT17Os7nOSGQCdpOmmQraSL X-Received: by 2002:a05:6a21:197:b0:149:122b:6330 with SMTP id le23-20020a056a21019700b00149122b6330mr10662614pzb.10.1696605562417; Fri, 06 Oct 2023 08:19:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696605562; cv=none; d=google.com; s=arc-20160816; b=rKknQ5CzwjLpA21T3kYRa4X+q2bWBzvHVVWrCmtSAnEyDeHFrZMfXA2YOZSQLxF1hY wWbnnPloUpGox8USMQRKZnUAiKqETq2M5Q9Q6o7HPV8pRbmTdVAwTxWxn0/gYwHO35v2 1y+/HCY93yN6iRPeRtBHmHmntPDo2Zot6r6zm2wPYq7NFO5G0Fp+dnHe4o0ibbquDSUG HwjrLjWIkTOV2nkO3lTlUkJGZHMQTnG8NuzRYpxP6ok2ExsJYMSUHIo1l9+S5uCFK43t tXg/mWNXteYWLMralxL52cyMv+NtbG9G0i1VzNO3HcrV4S717eTD5qXDNzEygr76A5Hd APmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=d2bfkEo5JYZuK7Cv8VAKlPll7M52jynkOgAjxxr9P8w=; fh=MvduW7TtfFJGfZiC/W6aaLQjI7EqApwiKAwimfBfFME=; b=Bygr/LaZDuNq3aKnHkuuj+m+imdS8DpshKWMURhsk88VmR7RgF3ittZ/iKwgBTPyNx eUu/zCBqSvMbsiRdLC7NMaRehaaprVeKYNGeTSje027jFxpkpbz8jvBsTZs0c8IzVSRs ZVnB/g3D5EWcnHJZg0vDMvOyuzxncAx4HwBndUtiTkF5zANfJv8bM5rvI9q1ze8AxLa0 JkzDGdDD0evYW6MTU1gwS4p07zKiQ9zibIlDZQbIPDPg5oxCwFz6JsgzNoHhowondJuJ fMwsA+h7AWP0mtru7NJBw+0/X3GoJimL9iLnV+wrWQJ8urXUWCyOqBFBfCNOn4FAU0YB LWfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vlDt89zq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id j13-20020a63cf0d000000b005704979833csi3708902pgg.855.2023.10.06.08.19.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 08:19:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vlDt89zq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id AF085802A547; Fri, 6 Oct 2023 08:19:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232746AbjJFPTC (ORCPT + 18 others); Fri, 6 Oct 2023 11:19:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232833AbjJFPS5 (ORCPT ); Fri, 6 Oct 2023 11:18:57 -0400 Received: from out-204.mta0.migadu.com (out-204.mta0.migadu.com [91.218.175.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E51E5EB for ; Fri, 6 Oct 2023 08:18:55 -0700 (PDT) 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=1696605531; 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=d2bfkEo5JYZuK7Cv8VAKlPll7M52jynkOgAjxxr9P8w=; b=vlDt89zqqnculRELuSeD9jLjZvKkTm/HiU3ElzO3T+fxatuKvM2A4E2SdhRUNGBH2xbgro 3wvtsb368B03sIGwZKqVO5PGL8PxfVJNm+p51ld6CPnb10yOlBCdGxfsf4fknSSnhps7S3 EcII2j00X56lu2ZTTlQlFbk3V+F7v2Y= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH 3/5] kasan: use unchecked __memset internally Date: Fri, 6 Oct 2023 17:18:44 +0200 Message-Id: <6f621966c6f52241b5aaa7220c348be90c075371.1696605143.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 06 Oct 2023 08:19:13 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779019874324456789 X-GMAIL-MSGID: 1779019874324456789 From: Andrey Konovalov KASAN code is supposed to use the unchecked __memset implementation when accessing its metadata. Change uses of memset to __memset in mm/kasan/. Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver --- mm/kasan/report.c | 4 ++-- mm/kasan/shadow.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/kasan/report.c b/mm/kasan/report.c index ca4b6ff080a6..12557ffee90b 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -538,7 +538,7 @@ void kasan_report_invalid_free(void *ptr, unsigned long ip, enum kasan_report_ty start_report(&flags, true); - memset(&info, 0, sizeof(info)); + __memset(&info, 0, sizeof(info)); info.type = type; info.access_addr = ptr; info.access_size = 0; @@ -576,7 +576,7 @@ bool kasan_report(const void *addr, size_t size, bool is_write, start_report(&irq_flags, true); - memset(&info, 0, sizeof(info)); + __memset(&info, 0, sizeof(info)); info.type = KASAN_REPORT_ACCESS; info.access_addr = addr; info.access_size = size; diff --git a/mm/kasan/shadow.c b/mm/kasan/shadow.c index dd772f9d0f08..d687f09a7ae3 100644 --- a/mm/kasan/shadow.c +++ b/mm/kasan/shadow.c @@ -324,7 +324,7 @@ static int kasan_populate_vmalloc_pte(pte_t *ptep, unsigned long addr, if (!page) return -ENOMEM; - memset((void *)page, KASAN_VMALLOC_INVALID, PAGE_SIZE); + __memset((void *)page, KASAN_VMALLOC_INVALID, PAGE_SIZE); pte = pfn_pte(PFN_DOWN(__pa(page)), PAGE_KERNEL); spin_lock(&init_mm.page_table_lock);