From patchwork Sun Oct 13 13:02:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sabyrzhan Tasbolatov X-Patchwork-Id: 13833404 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 93F29CF2579 for ; Sun, 13 Oct 2024 13:01:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1A7B66B0085; Sun, 13 Oct 2024 09:01:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 157EE6B0088; Sun, 13 Oct 2024 09:01:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3A656B0089; Sun, 13 Oct 2024 09:01:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D287F6B0085 for ; Sun, 13 Oct 2024 09:01:58 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0F5C2AB030 for ; Sun, 13 Oct 2024 13:01:45 +0000 (UTC) X-FDA: 82668591390.21.8C71C67 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) by imf26.hostedemail.com (Postfix) with ESMTP id BA3F314001D for ; Sun, 13 Oct 2024 13:01:52 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ApU1kxd3; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of snovitoll@gmail.com designates 209.85.218.52 as permitted sender) smtp.mailfrom=snovitoll@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728824401; a=rsa-sha256; cv=none; b=DekumQo2cREmMhHRHLp1RK5jaIBkMortTe9ievmncf7V1YU8qTBTuFUCpuvIFzABzKsBDz RMeh33nMxjSSiz1g++tRx/oxSPdMdto3+wXKIPprliTowJHaQbRrhFiByBL76x6n63HQds PGS5UsdNLltqzF3G2F/dna98Th90UNM= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ApU1kxd3; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of snovitoll@gmail.com designates 209.85.218.52 as permitted sender) smtp.mailfrom=snovitoll@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728824401; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YUH0O52iG9NocMBQX2ifD6HnZr5R8mVmxmATQ3anrSs=; b=1bRIHIeTJiY15YjdeTir8WiajGUPhb65415P+RlFpNCZ4FEWTe7+byWP2VvJC33rAMAErZ mIO5SnsyXiEr6s8ErPGyLRcbAOaNVFKgOdN3P+yads30L9P5XDxZaMscdbafHnSutwo+Gj OcH/2CkgS1yxZwNBUeSHXmbCW/GuMlc= Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a994cd82a3bso501508966b.2 for ; Sun, 13 Oct 2024 06:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728824515; x=1729429315; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YUH0O52iG9NocMBQX2ifD6HnZr5R8mVmxmATQ3anrSs=; b=ApU1kxd3EOfeClb7bw+luFK+O6AopHTFlg92cDrqZ8xw8mt+4AamCcj94Dh0x6v8Dk sJKuweCbn7mYNnWrmfMiNN2meMPSeb2yOg1WFc62bvelsgBP9ggMYUGkjJ83ZMSk76gu /q+HOkHQBokWwWQ/wSphhXJRIeLq2X8W6+Vh1C07xYnk8S+ikEl7XPBmqDe1EktDgzaD ybu0FTEtidHmaNGZ0UTqrkEkio4aoJAM1jAG+LUu9c3TyXTJw9ppEMKOp6/um4M/L6JB kmggqJ2UcLgwKK76z9jh60eINoQOT8CqYuTSa8v+/MQWXS/86X3cM4eEmnT+imTy+w6a NKcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728824515; x=1729429315; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YUH0O52iG9NocMBQX2ifD6HnZr5R8mVmxmATQ3anrSs=; b=vqa+1aHuBkztNcPijbUiomrx8fv4cd5lQ24NQP6H5h6mFg+zlagCeoNxGlpBWJipHy F95UhuGYAO9/bXhAj9HsKiWe3B5Os/jkueGv+fOuNwlfDNtvefzEcEPgceDYJZ6gfKcH 6JeDCHCctNYYXyNYdtDEhSlrnz6rp59wghm+dViUm4NztO7DB81trfQ6kdlsg2VIAG8r lAh7vN0L0gfabFYidC9dKMlnkaCa+nllJe4lUme4QA9iW4beCcLHCU1TauICuuJ2IWuy OTyQCrc3N5j9s1CkxMQ7vZBt+mF2fQTBOwiZXrmMQRfw3bZI0UmIMZT45JSLLrfvuyO+ uqDQ== X-Forwarded-Encrypted: i=1; AJvYcCUVidAN5RlCZCBRzILloSaeUUUaKMF0TdyRiuvzSC6owdhbNpDwGHviaL9hIuGvCwxHkHWC2KfY/g==@kvack.org X-Gm-Message-State: AOJu0Yy4gH+S7wFRABVtKpuFbWUt8TH/poOkfscVAOpOcK+xSJO9HgZk I/Bm4EhQ2JIPq4A2joO2AvigA3Ogz/IUexb7t0BFHZye5WNbRbnS X-Google-Smtp-Source: AGHT+IF9TP9UXY7+Xn/KTanZ8SmeeHtdh4zwU64TMJUgxaxAT9yUrVHKBUO3RgLezRWQskcH3dLtjw== X-Received: by 2002:a17:907:2d8b:b0:a99:399f:cf2b with SMTP id a640c23a62f3a-a99b93ae7c8mr624523566b.12.1728824514634; Sun, 13 Oct 2024 06:01:54 -0700 (PDT) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a0d9de967sm19209666b.139.2024.10.13.06.01.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 06:01:54 -0700 (PDT) From: Sabyrzhan Tasbolatov To: andreyknvl@gmail.com Cc: akpm@linux-foundation.org, dvyukov@google.com, glider@google.com, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, ryabinin.a.a@gmail.com, snovitoll@gmail.com, vincenzo.frascino@arm.com, elver@google.com, corbet@lwn.net, alexs@kernel.org, siyanteng@loongson.cn, 2023002089@link.tyut.edu.cn, workflows@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v2 1/3] kasan: move checks to do_strncpy_from_user Date: Sun, 13 Oct 2024 18:02:09 +0500 Message-Id: <20241013130211.3067196-2-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013130211.3067196-1-snovitoll@gmail.com> References: <20241013130211.3067196-1-snovitoll@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: BA3F314001D X-Stat-Signature: dd7yti4kxqzmjab79zg13wc6eb95ycpr X-Rspam-User: X-HE-Tag: 1728824512-962543 X-HE-Meta: U2FsdGVkX1/nl1QwcoNR9i5iaTKgNwJFT/1sB02qmtd+C1hcwtA119+2hBLp5vHIoo+C2+ihIMDIsmTT4MDTW/9INOyGjjr3rDD+8qVkkhyto4S5FMi+EYbaLZgr6uo6RNOY9/1XDxbZvA+4VIEeTB7fCYnHL9A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TWA7bCJBGogSbWclDxO+ocRPd0mHVvGD8vnWrDzOYPHLiWDCZUAb3vL75msEfNW+rE+b38sQrGLM3g8vvTKe+TYeV1Xvxr9xNExbkkoVgt7lky/gIKXz+74WXxtRgECHv6vzXWWL43C+Zq28SPkM5V9t58JJbQ12NOZjXKW++LeJQbAVQ0PDfDB/5cA8mB349PqkQCWLRfiPGH/Psf2HMp4hhT3UfbLeBxyC02FFnplHUnkkBYJdP3zGaim1MA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Since in the commit 2865baf54077("x86: support user address masking instead of non-speculative conditional") do_strncpy_from_user() is called from multiple places, we should sanitize the kernel *dst memory and size which were done in strncpy_from_user() previously. Fixes: 2865baf54077 ("x86: support user address masking instead of non-speculative conditional") Signed-off-by: Sabyrzhan Tasbolatov Reviewed-by: Andrey Konovalov --- lib/strncpy_from_user.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c index 989a12a6787..f36ad821176 100644 --- a/lib/strncpy_from_user.c +++ b/lib/strncpy_from_user.c @@ -31,6 +31,9 @@ static __always_inline long do_strncpy_from_user(char *dst, const char __user *s const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS; unsigned long res = 0; + kasan_check_write(dst, count); + check_object_size(dst, count, false); + if (IS_UNALIGNED(src, dst)) goto byte_at_a_time; @@ -142,8 +145,6 @@ long strncpy_from_user(char *dst, const char __user *src, long count) if (max > count) max = count; - kasan_check_write(dst, count); - check_object_size(dst, count, false); if (user_read_access_begin(src, max)) { retval = do_strncpy_from_user(dst, src, count, max); user_read_access_end(); From patchwork Sun Oct 13 13:02:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sabyrzhan Tasbolatov X-Patchwork-Id: 13833405 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 518A4CF2576 for ; Sun, 13 Oct 2024 13:02:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA5316B0089; Sun, 13 Oct 2024 09:02:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C549A6B008A; Sun, 13 Oct 2024 09:02:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF5066B008C; Sun, 13 Oct 2024 09:02:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8B1576B0089 for ; Sun, 13 Oct 2024 09:02:24 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0EB0FAB109 for ; Sun, 13 Oct 2024 13:02:11 +0000 (UTC) X-FDA: 82668592524.29.D7CB2D9 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by imf07.hostedemail.com (Postfix) with ESMTP id 262F940017 for ; Sun, 13 Oct 2024 13:02:14 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nErMbpdn; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf07.hostedemail.com: domain of snovitoll@gmail.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=snovitoll@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728824427; a=rsa-sha256; cv=none; b=DmSamO5seKnEpj5JUnP5IybvaS/kLf2p0cg5advHVoyy6o0H1a3Ra9TiH1T/m2Ze0hiQMb KKrMNCgpXCSiZqgpjLnOM7OUCE+DcL2RtY8+VCacZPLWqHj6HiQ1vTWfIX7ARmyAK65cei dYGAcnz8ZSw03GLzo3SW4H1NJkzHbGc= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nErMbpdn; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf07.hostedemail.com: domain of snovitoll@gmail.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=snovitoll@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728824427; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EOio8S+6KOqaUEgqnfvfmeW8wlYXV0IlIhkZKQFgu/c=; b=Ffmx59viKY4QmlQR5CntkA2fxoP8lmcCLb0r9FjtfAKQpmaOB581Y5ojTZz7RWllZx6uKp kwaYQkxMMnNdSCMq5Sf8oE7T5ZbT9RVOSMT2MaIZNGFfBwXqDQa6OAja2ldKA7NsQP43uH uPtrJoF8/DbvN0StfAO9smEX8frYSUI= Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5c918c067a1so4294448a12.3 for ; Sun, 13 Oct 2024 06:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728824541; x=1729429341; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EOio8S+6KOqaUEgqnfvfmeW8wlYXV0IlIhkZKQFgu/c=; b=nErMbpdn96Y51S3npPox3mWLqfoehEFzgTG7/hwj10/Bu2KZf3Z8yHXijhAGXoUkPm FaoqDikCJ9G6gKD5V/v38JlkJOC5SqUsqKS/fk9Rkd+kHx1ssDpE/qI6RPvwPiRxbmfb 71d2ykUKknQKlIxJoarp3NRLsItUYYX1Idu61JKiQvNvxcF+2uDW8xfeFj1YRSvrWoCr kLiJS0nXo5q7dKyAq5s98q4lZ4fRWB4Ppf6sLy3gkEn+IDlt9hnnCvu7w4TRpyB1LrIO N8CUVjf6VePh2/oP6Wr8JRJerqt3soAnFJxuvUz7QGrDHaAc+CYKt7UFq/YCTjrSlYkv IJrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728824541; x=1729429341; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EOio8S+6KOqaUEgqnfvfmeW8wlYXV0IlIhkZKQFgu/c=; b=Jpp5goIzk6BSS6I0tDeqLJycv8EhaCcPgZ3YqHUQjukyYjBeSV2Et6xmHGRwZ6TvJH Jh1+s9KTYqyQc42C/CdRFH3/9tQIE25ogrffegHQDqDSOnaolVzjuDXCYIw77waBsmE4 bsL0Dpq7is6q58Lz63tfUvhQlYBkwwVuBsAuM++xDaayVwQ3hoxeWEnYN/dfLEgb5lvf ezCF/XELRMyPamN1GCJVj/CUM6hq8EN+wqt9x6XGvsRJK6yM2Kj2OwQcZSFLItkjV8Gn rHMikjHDvzJCJg5EhunRI/vu5jaWUNcalu2X1hHcXDxYlg28RBmsMX+SR0TFdIyF1zWB 7o3g== X-Forwarded-Encrypted: i=1; AJvYcCUEMhhrs2osGPv9ppLCerdlTDRT9i+AHwJAXL/fq2J7BZH07euoLeUh/RH1jTu22eJjHRsgtT3GDw==@kvack.org X-Gm-Message-State: AOJu0Yym/Y4tSpz2uC8w4vGUU6V2pMqdNtgULQ82UzZA2m3GYniXw9iz 6ZDRSLOTciGdmWMZgMjqGO5VWJmZjik1GBW24EeF6/pI1+21Ikn7 X-Google-Smtp-Source: AGHT+IGa72/I5E1R4rZXYJgY/jp96XXQXIIaDV5rRLP1ox3QbO7ExR6jmFn8fxtaiWDpevEMJRVjBQ== X-Received: by 2002:a17:907:ea3:b0:a99:4e8c:e5c9 with SMTP id a640c23a62f3a-a99b937b7famr780021966b.20.1728824540497; Sun, 13 Oct 2024 06:02:20 -0700 (PDT) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a0d9de967sm19209666b.139.2024.10.13.06.02.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 06:02:19 -0700 (PDT) From: Sabyrzhan Tasbolatov To: andreyknvl@gmail.com Cc: akpm@linux-foundation.org, dvyukov@google.com, glider@google.com, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, ryabinin.a.a@gmail.com, snovitoll@gmail.com, vincenzo.frascino@arm.com, elver@google.com, corbet@lwn.net, alexs@kernel.org, siyanteng@loongson.cn, 2023002089@link.tyut.edu.cn, workflows@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v2 2/3] kasan: migrate copy_user_test to kunit Date: Sun, 13 Oct 2024 18:02:10 +0500 Message-Id: <20241013130211.3067196-3-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013130211.3067196-1-snovitoll@gmail.com> References: <20241013130211.3067196-1-snovitoll@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 262F940017 X-Stat-Signature: krw9c45kafsrqof7wmbe6qxwigrp1nxp X-Rspam-User: X-HE-Tag: 1728824534-246836 X-HE-Meta: U2FsdGVkX1/+6I9UAvNEoEGpJ60uGv3JWMVbqTCrH+sWr456zO/yhoesPicD728XePt6vMrki5vpXWCvnL1JVs5gLMg2cPlM5C3aS5iHMw61gFRW8Wv8q2M85RzwYx5KQX7AmfIJyN/m+MyZwPphd0Dbiw9COivMNrPn+GoO411QceeMABCIEVAwVLrOE/wcpgaXRMRTh0fNp9C6Xjdl5bgQxaKmGiLk35X7j9o3u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pTwwUYPD8+0crS7W48TecNwLdj3fEwdH+d41K2ST30oVpz0e7+U5/k+IF4mBM4BB3cLn2LUhToumh/uaMfZul9nmgjzqLMNcoFaQ5ZcGmOtmp13rZWWjJOMIPu9V9oBBork1LzFkrGfOv45w8VgmQYP4VHxRsgc0NDKbBU0vufIEMloMmHh2OOKK2dKqJ6m8h1D9U7+A= 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: Migrate the copy_user_test to the KUnit framework to verify out-of-bound detection via KASAN reports in copy_from_user(), copy_to_user() and their static functions. This is the last migrated test in kasan_test_module.c, therefore delete the file. Signed-off-by: Sabyrzhan Tasbolatov --- mm/kasan/Makefile | 2 - mm/kasan/kasan_test_c.c | 39 +++++++++++++++++ mm/kasan/kasan_test_module.c | 81 ------------------------------------ 3 files changed, 39 insertions(+), 83 deletions(-) delete mode 100644 mm/kasan/kasan_test_module.c diff --git a/mm/kasan/Makefile b/mm/kasan/Makefile index b88543e5c0c..1a958e7c8a4 100644 --- a/mm/kasan/Makefile +++ b/mm/kasan/Makefile @@ -46,7 +46,6 @@ endif CFLAGS_kasan_test_c.o := $(CFLAGS_KASAN_TEST) RUSTFLAGS_kasan_test_rust.o := $(RUSTFLAGS_KASAN) -CFLAGS_kasan_test_module.o := $(CFLAGS_KASAN_TEST) obj-y := common.o report.o obj-$(CONFIG_KASAN_GENERIC) += init.o generic.o report_generic.o shadow.o quarantine.o @@ -59,4 +58,3 @@ ifdef CONFIG_RUST endif obj-$(CONFIG_KASAN_KUNIT_TEST) += kasan_test.o -obj-$(CONFIG_KASAN_MODULE_TEST) += kasan_test_module.o diff --git a/mm/kasan/kasan_test_c.c b/mm/kasan/kasan_test_c.c index a181e4780d9..e71a16d0dfb 100644 --- a/mm/kasan/kasan_test_c.c +++ b/mm/kasan/kasan_test_c.c @@ -1954,6 +1954,44 @@ static void rust_uaf(struct kunit *test) KUNIT_EXPECT_KASAN_FAIL(test, kasan_test_rust_uaf()); } +static void copy_user_test_oob(struct kunit *test) +{ + char *kmem; + char __user *usermem; + unsigned long useraddr; + size_t size = 128 - KASAN_GRANULE_SIZE; + int __maybe_unused unused; + + kmem = kunit_kmalloc(test, size, GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, kmem); + + useraddr = kunit_vm_mmap(test, NULL, 0, PAGE_SIZE, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_ANONYMOUS | MAP_PRIVATE, 0); + KUNIT_ASSERT_NE_MSG(test, useraddr, 0, + "Could not create userspace mm"); + KUNIT_ASSERT_LT_MSG(test, useraddr, (unsigned long)TASK_SIZE, + "Failed to allocate user memory"); + + OPTIMIZER_HIDE_VAR(size); + usermem = (char __user *)useraddr; + + KUNIT_EXPECT_KASAN_FAIL(test, + unused = copy_from_user(kmem, usermem, size + 1)); + KUNIT_EXPECT_KASAN_FAIL(test, + unused = copy_to_user(usermem, kmem, size + 1)); + KUNIT_EXPECT_KASAN_FAIL(test, + unused = __copy_from_user(kmem, usermem, size + 1)); + KUNIT_EXPECT_KASAN_FAIL(test, + unused = __copy_to_user(usermem, kmem, size + 1)); + KUNIT_EXPECT_KASAN_FAIL(test, + unused = __copy_from_user_inatomic(kmem, usermem, size + 1)); + KUNIT_EXPECT_KASAN_FAIL(test, + unused = __copy_to_user_inatomic(usermem, kmem, size + 1)); + KUNIT_EXPECT_KASAN_FAIL(test, + unused = strncpy_from_user(kmem, usermem, size + 1)); +} + static struct kunit_case kasan_kunit_test_cases[] = { KUNIT_CASE(kmalloc_oob_right), KUNIT_CASE(kmalloc_oob_left), @@ -2028,6 +2066,7 @@ static struct kunit_case kasan_kunit_test_cases[] = { KUNIT_CASE(match_all_ptr_tag), KUNIT_CASE(match_all_mem_tag), KUNIT_CASE(rust_uaf), + KUNIT_CASE(copy_user_test_oob), {} }; diff --git a/mm/kasan/kasan_test_module.c b/mm/kasan/kasan_test_module.c deleted file mode 100644 index 27ec22767e4..00000000000 --- a/mm/kasan/kasan_test_module.c +++ /dev/null @@ -1,81 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * Author: Andrey Ryabinin - */ - -#define pr_fmt(fmt) "kasan: test: " fmt - -#include -#include -#include -#include -#include - -#include "kasan.h" - -static noinline void __init copy_user_test(void) -{ - char *kmem; - char __user *usermem; - size_t size = 128 - KASAN_GRANULE_SIZE; - int __maybe_unused unused; - - kmem = kmalloc(size, GFP_KERNEL); - if (!kmem) - return; - - usermem = (char __user *)vm_mmap(NULL, 0, PAGE_SIZE, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_ANONYMOUS | MAP_PRIVATE, 0); - if (IS_ERR(usermem)) { - pr_err("Failed to allocate user memory\n"); - kfree(kmem); - return; - } - - OPTIMIZER_HIDE_VAR(size); - - pr_info("out-of-bounds in copy_from_user()\n"); - unused = copy_from_user(kmem, usermem, size + 1); - - pr_info("out-of-bounds in copy_to_user()\n"); - unused = copy_to_user(usermem, kmem, size + 1); - - pr_info("out-of-bounds in __copy_from_user()\n"); - unused = __copy_from_user(kmem, usermem, size + 1); - - pr_info("out-of-bounds in __copy_to_user()\n"); - unused = __copy_to_user(usermem, kmem, size + 1); - - pr_info("out-of-bounds in __copy_from_user_inatomic()\n"); - unused = __copy_from_user_inatomic(kmem, usermem, size + 1); - - pr_info("out-of-bounds in __copy_to_user_inatomic()\n"); - unused = __copy_to_user_inatomic(usermem, kmem, size + 1); - - pr_info("out-of-bounds in strncpy_from_user()\n"); - unused = strncpy_from_user(kmem, usermem, size + 1); - - vm_munmap((unsigned long)usermem, PAGE_SIZE); - kfree(kmem); -} - -static int __init kasan_test_module_init(void) -{ - /* - * Temporarily enable multi-shot mode. Otherwise, KASAN would only - * report the first detected bug and panic the kernel if panic_on_warn - * is enabled. - */ - bool multishot = kasan_save_enable_multi_shot(); - - copy_user_test(); - - kasan_restore_multi_shot(multishot); - return -EAGAIN; -} - -module_init(kasan_test_module_init); -MODULE_LICENSE("GPL"); From patchwork Sun Oct 13 13:02:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sabyrzhan Tasbolatov X-Patchwork-Id: 13833406 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 E7504CF2579 for ; Sun, 13 Oct 2024 13:02:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 74E746B008C; Sun, 13 Oct 2024 09:02:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6FFC46B0092; Sun, 13 Oct 2024 09:02:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 577976B0093; Sun, 13 Oct 2024 09:02:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 39A4B6B008C for ; Sun, 13 Oct 2024 09:02:29 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id ADC9312025A for ; Sun, 13 Oct 2024 13:02:22 +0000 (UTC) X-FDA: 82668592608.27.65C9BFF Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by imf22.hostedemail.com (Postfix) with ESMTP id 0B866C0019 for ; Sun, 13 Oct 2024 13:02:20 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="PY/ORs1b"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of snovitoll@gmail.com designates 209.85.218.53 as permitted sender) smtp.mailfrom=snovitoll@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728824432; a=rsa-sha256; cv=none; b=bHWJbvCAjW1nbUjQC70bciFMN7HldN48ZlM/LhvYQEAN9KGtJP+GxPDR3pgbrCkOojKx0c cQpIdon20D5zvhGwlJ3ClY+6qEc27CxN9zfEkyTnI1e24lAkkHnqF7YvVteEiUUsuHjTPw A6aqJVIwws3N1VHAGnxHTDvwOKOMl84= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="PY/ORs1b"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of snovitoll@gmail.com designates 209.85.218.53 as permitted sender) smtp.mailfrom=snovitoll@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728824432; 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=pqumvoIyJhkt9W5HwjJwb/i/n9g4P9IeX/TAEyTfGvM=; b=sQzPPNr9uzqDfHW8hjsWb9CtSsU6D9imQW5tVuPqbDrw5P5yRn8ReyeuVG+cWHyhkDZHCa zQw8Mgcugiac7YaE68u9eLx/sAg5P8FYMm+bKbVHBIz4jxfouy/JOaO4Cp/kV96HYSczP3 WTTpKBv8pwaxEq6h5EHRznICQ0+OC4Q= Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a9a0cee600aso17092566b.1 for ; Sun, 13 Oct 2024 06:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728824545; x=1729429345; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pqumvoIyJhkt9W5HwjJwb/i/n9g4P9IeX/TAEyTfGvM=; b=PY/ORs1bsoWaZmgdnRwU6Ax6PwP0B0MICjRih7xB6pqORyVp3w6yWYk4DTqPZcRRyB 4yaEy7lGhrTtf/UbTRAMfAaPP6eGrN+ctSVddln7jzOsk6JGKOqQ3FquA+AmNWqYoBqY usMPJoXESx6hFSMPHzLUdrDiGRrQuVaOQmgYszWg67fW0lxs2QXEXjcNuw0DIq85NA3m jO7QrnsqSeGsG/G94KUCpGZ+yJ3KiX4Tkf3KEpiTZp1CTZPcoyOITse3dpI6C2eZmMQv exunijMZvuWPVUWdURe8P9R4z1ed18aIphZANef1O2pshinDy9KhiC+L9rdI/01u+PR6 Eywg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728824545; x=1729429345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pqumvoIyJhkt9W5HwjJwb/i/n9g4P9IeX/TAEyTfGvM=; b=T3KF/+tX/4bHXLBIA35AwLz9T7UoRc5kr3lM2gxIbppUKgRDHwYoIzPAV/gz8dq1Gv ITlimaamKm0OvEcnt1aLjUNU2bxUwT12NK6jpq8sFVlwwXXVzsyJuRgYwHJ45sZmiC3b /rGLsa2LK5jU8XLPvHoubU90oIqcILnxTlrzlP/UIDx9c4rfQtm2Uum0BQ01NJxMadAX yLgRDOw+2LYkdh+m1nEI2AaahhSs0I7K0OrF6hmd0RroSbtH/4mCqh41QSKrpjw/TG5k RPl8um9IT4l7XOtXLF5vR7WHZMjUOhTuIkAG4Lz54VY5GwMqDqTfpem52GULYZmxzEQV PS+w== X-Forwarded-Encrypted: i=1; AJvYcCUNfS2WC7Hl350U8XUCBXv5iSlJT+LVmAzOtPl2y0oERmELbchXalrPkHnCF14B4oRIv9On/Cn8Hw==@kvack.org X-Gm-Message-State: AOJu0YwjorYb5ExN41XHF+UTEDVUzsoACRl+2/scBxhZorC9hK3TaV06 pYkDXbrLY54+E8ygynnuPPIYG5zfwlvmW+KLcPOh/d6nZpN8pOt4 X-Google-Smtp-Source: AGHT+IH3hBQZELCO27froLhmQMniGAn0bBg1HgfDg+xB1ADD1RL5C7wQdwmHKKqPnxl1b745khWtcw== X-Received: by 2002:a17:907:9723:b0:a99:ef41:33db with SMTP id a640c23a62f3a-a99ef4137ebmr460504966b.19.1728824544896; Sun, 13 Oct 2024 06:02:24 -0700 (PDT) Received: from work.. (2.133.25.254.dynamic.telecom.kz. [2.133.25.254]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a0d9de967sm19209666b.139.2024.10.13.06.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 06:02:24 -0700 (PDT) From: Sabyrzhan Tasbolatov To: andreyknvl@gmail.com Cc: akpm@linux-foundation.org, dvyukov@google.com, glider@google.com, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, ryabinin.a.a@gmail.com, snovitoll@gmail.com, vincenzo.frascino@arm.com, elver@google.com, corbet@lwn.net, alexs@kernel.org, siyanteng@loongson.cn, 2023002089@link.tyut.edu.cn, workflows@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v2 3/3] kasan: delete CONFIG_KASAN_MODULE_TEST Date: Sun, 13 Oct 2024 18:02:11 +0500 Message-Id: <20241013130211.3067196-4-snovitoll@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241013130211.3067196-1-snovitoll@gmail.com> References: <20241013130211.3067196-1-snovitoll@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0B866C0019 X-Stat-Signature: t5k7wawzmudbahmwsug3g6fgnwqo7ajt X-Rspam-User: X-HE-Tag: 1728824540-717946 X-HE-Meta: U2FsdGVkX1/L1O/m8GKPmhBz/isysl2VFOJEHW/ZFatvT1w52MrARgrNmDkwCeYLx81p7HIY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DBrEyWutOWdhxeQ0m4rOahW2dnFlAk9t/uvO929M0tbnvgjTGVdXR5t2MjgRgzKrk0EDVpkNMtYkcRjOSMR8ojGlyOXn/D+7f+h5h1y8jwT/OoUETBa2sYzsXUXUfX4QXzbOHODKUU1hxIxU1hBq5CPtcoJPH6RrDJV/BbhIWQyjEsDehtct2G4Mp8LNeRU89O0VcAaR8FZYZSZZGphUrN8kai4QT0l+/Zw2Q9PgsRjVEh958PSUsU20KBbCgTJwNBMeBHm5FmnlLzLG9lPwR4rHG01jBeiEAZjiBL9iLYPcqV8YaYMVXgNK+cF5CfJkG39ofMLN0/ryh0pw2dqULPFUudEvzd2Il2ae8MotlfzpIppDuUDJg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.003384, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Since we've migrated all tests to the KUnit framework, we can delete CONFIG_KASAN_MODULE_TEST and mentioning of it in the documentation as well. I've used the online translator to modify the non-English documentation. Signed-off-by: Sabyrzhan Tasbolatov --- Documentation/dev-tools/kasan.rst | 9 ++------- Documentation/translations/zh_CN/dev-tools/kasan.rst | 6 +----- Documentation/translations/zh_TW/dev-tools/kasan.rst | 6 +----- lib/Kconfig.kasan | 7 ------- mm/kasan/kasan.h | 2 +- mm/kasan/report.c | 2 +- 6 files changed, 6 insertions(+), 26 deletions(-) diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst index d7de44f5339..52fdd6b5ef6 100644 --- a/Documentation/dev-tools/kasan.rst +++ b/Documentation/dev-tools/kasan.rst @@ -511,17 +511,12 @@ Tests ~~~~~ There are KASAN tests that allow verifying that KASAN works and can detect -certain types of memory corruptions. The tests consist of two parts: +certain types of memory corruptions. -1. Tests that are integrated with the KUnit Test Framework. Enabled with +Tests that are integrated with the KUnit Test Framework. Enabled with ``CONFIG_KASAN_KUNIT_TEST``. These tests can be run and partially verified automatically in a few different ways; see the instructions below. -2. Tests that are currently incompatible with KUnit. Enabled with -``CONFIG_KASAN_MODULE_TEST`` and can only be run as a module. These tests can -only be verified manually by loading the kernel module and inspecting the -kernel log for KASAN reports. - Each KUnit-compatible KASAN test prints one of multiple KASAN reports if an error is detected. Then the test prints its number and status. diff --git a/Documentation/translations/zh_CN/dev-tools/kasan.rst b/Documentation/translations/zh_CN/dev-tools/kasan.rst index 4491ad2830e..f968d262be1 100644 --- a/Documentation/translations/zh_CN/dev-tools/kasan.rst +++ b/Documentation/translations/zh_CN/dev-tools/kasan.rst @@ -422,14 +422,10 @@ KASAN连接到vmap基础架构以懒清理未使用的影子内存。 ~~~~ 有一些KASAN测试可以验证KASAN是否正常工作并可以检测某些类型的内存损坏。 -测试由两部分组成: -1. 与KUnit测试框架集成的测试。使用 ``CONFIG_KASAN_KUNIT_TEST`` 启用。 +与KUnit测试框架集成的测试。使用 ``CONFIG_KASAN_KUNIT_TEST`` 启用。 这些测试可以通过几种不同的方式自动运行和部分验证;请参阅下面的说明。 -2. 与KUnit不兼容的测试。使用 ``CONFIG_KASAN_MODULE_TEST`` 启用并且只能作为模块 -运行。这些测试只能通过加载内核模块并检查内核日志以获取KASAN报告来手动验证。 - 如果检测到错误,每个KUnit兼容的KASAN测试都会打印多个KASAN报告之一,然后测试打印 其编号和状态。 diff --git a/Documentation/translations/zh_TW/dev-tools/kasan.rst b/Documentation/translations/zh_TW/dev-tools/kasan.rst index ed342e67d8e..19457860486 100644 --- a/Documentation/translations/zh_TW/dev-tools/kasan.rst +++ b/Documentation/translations/zh_TW/dev-tools/kasan.rst @@ -404,14 +404,10 @@ KASAN連接到vmap基礎架構以懶清理未使用的影子內存。 ~~~~ 有一些KASAN測試可以驗證KASAN是否正常工作並可以檢測某些類型的內存損壞。 -測試由兩部分組成: -1. 與KUnit測試框架集成的測試。使用 ``CONFIG_KASAN_KUNIT_TEST`` 啓用。 +與KUnit測試框架集成的測試。使用 ``CONFIG_KASAN_KUNIT_TEST`` 啓用。 這些測試可以通過幾種不同的方式自動運行和部分驗證;請參閱下面的說明。 -2. 與KUnit不兼容的測試。使用 ``CONFIG_KASAN_MODULE_TEST`` 啓用並且只能作爲模塊 -運行。這些測試只能通過加載內核模塊並檢查內核日誌以獲取KASAN報告來手動驗證。 - 如果檢測到錯誤,每個KUnit兼容的KASAN測試都會打印多個KASAN報告之一,然後測試打印 其編號和狀態。 diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan index 98016e137b7..f82889a830f 100644 --- a/lib/Kconfig.kasan +++ b/lib/Kconfig.kasan @@ -195,13 +195,6 @@ config KASAN_KUNIT_TEST For more information on KUnit and unit tests in general, please refer to the KUnit documentation in Documentation/dev-tools/kunit/. -config KASAN_MODULE_TEST - tristate "KUnit-incompatible tests of KASAN bug detection capabilities" - depends on m && KASAN && !KASAN_HW_TAGS - help - A part of the KASAN test suite that is not integrated with KUnit. - Incompatible with Hardware Tag-Based KASAN. - config KASAN_EXTRA_INFO bool "Record and report more information" depends on KASAN diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index f438a6cdc96..b7e4b81421b 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -568,7 +568,7 @@ static inline void kasan_kunit_test_suite_end(void) { } #endif /* CONFIG_KASAN_KUNIT_TEST */ -#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) || IS_ENABLED(CONFIG_KASAN_MODULE_TEST) +#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) bool kasan_save_enable_multi_shot(void); void kasan_restore_multi_shot(bool enabled); diff --git a/mm/kasan/report.c b/mm/kasan/report.c index b48c768acc8..3e48668c3e4 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -132,7 +132,7 @@ static bool report_enabled(void) return !test_and_set_bit(KASAN_BIT_REPORTED, &kasan_flags); } -#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) || IS_ENABLED(CONFIG_KASAN_MODULE_TEST) +#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) bool kasan_save_enable_multi_shot(void) {