Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6995817rdb; Fri, 15 Dec 2023 14:33:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IEP2rC2ZB5ELG20tr/ZPYnn6YBeyJRDrFSYKNYva1vZ+PzF52WIBI/kYqE8cqBdN5PNuSuP X-Received: by 2002:a05:6a20:9693:b0:18f:97c:8270 with SMTP id hp19-20020a056a20969300b0018f097c8270mr6373913pzc.122.1702679604844; Fri, 15 Dec 2023 14:33:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702679604; cv=none; d=google.com; s=arc-20160816; b=TodUKxx3E+s/2B2S4p4orNVskOTAPxXqPEIsmD/qfjdYG35U0GAc6t1OPGHBFvpWgf KB22EKC30DSmPnrOaf8zL8EygVGQiQuvYJLAirsNwXbzmRG3qM6HsVVEq/uyUamfhAcz AcrKYajqfZ7mlA7Q2ziB7qoeYupq666O7G6QvjQThkhEhejgjpkPX88P/cEaW5/TdP/c yZ9IiwoYzKFQHBoONst0698l+062FwosXQ9DbQt7uphW8JL/zSFw2VeytDZixKiSkSxU dmUDiNxsR0S/81EC9E9IH3NrujEu1nEQAd57S2A0TDDzWQo9Qv7W5dMWHm6x4qryHbHf hFgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Z6gE5MsrAaAORf3VjfmyHVqm+yqircqVcZWJ66dQBiE=; fh=oeWWgArGQrov3Bk7L7Hu86tiRgGctzah9oHkOQZBlMM=; b=OgQqurv3gmLp/f1fO/jvSlLncJdtZi0dGzyyZOWZtLFVlSscsQtZFds7ZSS8a2+x+M iRXXLX/l1TYX3bANcb+fkruvlk6CZL/YdZpUm0vHU2UxW2g3nqHleKVeyZLDn62MyW6v 7p77OtG+my8wD6LLKATpGCxO594i5H+X3WUQcbgbZL/NLoyU1z9Gnr9FSchI3hykTjN7 zX9GPJtJnd7Eepz8sWWnquHEj1o8EBll+ixWTKukcLebKf2irU3ye5BUDZxJwAxFDYDt KLIXj86CVeg3vnYOj8UDiV0A6NRvU/c0QBRegrs3kloPgl4zRKIgdtHZ2LKnqast02xV R3vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=GJjZijPr; spf=pass (google.com: domain of linux-kernel+bounces-1764-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1764-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j4-20020a170902da8400b001cf6aac6b5fsi13724030plx.559.2023.12.15.14.33.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 14:33:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1764-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=GJjZijPr; spf=pass (google.com: domain of linux-kernel+bounces-1764-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1764-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 18147286DE8 for ; Fri, 15 Dec 2023 22:33:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7EF1C18EC0; Fri, 15 Dec 2023 22:33:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="GJjZijPr" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (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 5B89113AC6 for ; Fri, 15 Dec 2023 22:33:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-6d9f879f784so902089a34.2 for ; Fri, 15 Dec 2023 14:33:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1702679595; x=1703284395; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Z6gE5MsrAaAORf3VjfmyHVqm+yqircqVcZWJ66dQBiE=; b=GJjZijPrRZJtU65a1Wv+o9R0gpgwdTvlYlDeT4K0p1wUeXWyt71xbL+avcWDRoHYxF nKC/Wt89SpZlxWY/uUpbi7oqaHlzS36LW2i2nxcUwu/p3rPsrPHxNmvD6OsJMlhNbQoh 0KVIKvdkVjptOjygVPKBUTNWf/9Ty3iaM+DV/DNiZg62fdKlMlb9D/kODBcrZ+CTqLJa 7hF5giyG6Pif95Z1LOTMQf9CWPRSUmyZVlm/fFkuG8ZycRY5uGoUfFcP5i4SMn/wIbu8 cxiXMDlip5FwBkXpJiigC/U4THsoam6eOw3tfi+HzUcTv9bbWKU0O02/TKEgixqgCyPJ ql3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702679595; x=1703284395; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Z6gE5MsrAaAORf3VjfmyHVqm+yqircqVcZWJ66dQBiE=; b=AoyVHNFbPHA4wlPvcohngSFjilzKRmDd8/Sn3JTh0BbJpDE5xDYtyvZyJgJ+7qJGE3 kqB/wlr4ddeSCgzVEVZnKkax5GNcl8nnfnr/apWBa1S1o/jNaKULGPqsdRGD7B5LCZQz 6rPwQ6xw5667dcy9SmhS6zDhCCd8O8gSGRgOk4Bm7c1DbTJQQCOR44jrQZ4a8wV06XFj whUMfEEqOp1IKkONliIe21x5ALWXG2o8fV/STNjkP3Vx7BeVEDf07g6ZaMCNkwTuBKIq l6hpaEgfM2IQBzCxVQv+IA47F2ufEokgITtNdUpW6ZxfWsb15ccRJGnWAMkS5rVRqNDC 7QJA== X-Gm-Message-State: AOJu0YyZRw7U1DZraBkq385AUa/+FZNwxMGoSTcdGtCYJOhgH6sCcRm6 SoIGwq7Qubgqn38O5zuZQKFwGg== X-Received: by 2002:a9d:5603:0:b0:6d9:e8e6:d00c with SMTP id e3-20020a9d5603000000b006d9e8e6d00cmr10217426oti.40.1702679595243; Fri, 15 Dec 2023 14:33:15 -0800 (PST) Received: from ghost ([12.44.203.122]) by smtp.gmail.com with ESMTPSA id x11-20020aa793ab000000b006ce497add69sm14013700pff.103.2023.12.15.14.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 14:33:14 -0800 (PST) Date: Fri, 15 Dec 2023 14:33:12 -0800 From: Charlie Jenkins To: Alexandre Ghiti Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, syzbot+afb726d49f84c8d95ee1@syzkaller.appspotmail.com Subject: Re: [PATCH -fixes v2] riscv: Fix wrong usage of lm_alias() when splitting a huge linear mapping Message-ID: References: <20231212195400.128457-1-alexghiti@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231212195400.128457-1-alexghiti@rivosinc.com> On Tue, Dec 12, 2023 at 08:54:00PM +0100, Alexandre Ghiti wrote: > lm_alias() can only be used on kernel mappings since it explicitly uses > __pa_symbol(), so simply fix this by checking where the address belongs > to before. > > Fixes: 311cd2f6e253 ("riscv: Fix set_memory_XX() and set_direct_map_XX() by splitting huge linear mappings") > Reported-by: syzbot+afb726d49f84c8d95ee1@syzkaller.appspotmail.com > Closes: https://lore.kernel.org/linux-riscv/000000000000620dd0060c02c5e1@google.com/ > Signed-off-by: Alexandre Ghiti > --- > > Changes in v2: > - Fix llvm warning about unitialized return value > > arch/riscv/mm/pageattr.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/arch/riscv/mm/pageattr.c b/arch/riscv/mm/pageattr.c > index fc5fc4f785c4..96cbda683936 100644 > --- a/arch/riscv/mm/pageattr.c > +++ b/arch/riscv/mm/pageattr.c > @@ -305,8 +305,13 @@ static int __set_memory(unsigned long addr, int numpages, pgprot_t set_mask, > goto unlock; > } > } else if (is_kernel_mapping(start) || is_linear_mapping(start)) { > - lm_start = (unsigned long)lm_alias(start); > - lm_end = (unsigned long)lm_alias(end); > + if (is_kernel_mapping(start)) { > + lm_start = (unsigned long)lm_alias(start); > + lm_end = (unsigned long)lm_alias(end); > + } else { > + lm_start = start; > + lm_end = end; > + } > > ret = split_linear_mapping(lm_start, lm_end); > if (ret) > -- > 2.39.2 Reviewed-by: Charlie Jenkins > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv