Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1326681lqp; Mon, 15 Apr 2024 03:07:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUEBBrjimh84A0HrwBMkgARdC3a0a2BOyTASEOnMCXFB95551ksaJc16PtO5+W+GTY0CICwd/Y1leVlcc+2/1OuxnItx4eBf54sm5xVGA== X-Google-Smtp-Source: AGHT+IHJ6p+5RAAY6zWNGuRhEpZxIC2rK9GTNyzJUneVGB3s+b5puataxkSUf7h8w0iUZHrA2gZA X-Received: by 2002:a05:6359:4d0d:b0:186:3fcb:8da9 with SMTP id oo13-20020a0563594d0d00b001863fcb8da9mr9958449rwb.21.1713175643370; Mon, 15 Apr 2024 03:07:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713175643; cv=pass; d=google.com; s=arc-20160816; b=WynopumxFlFDZUdXkOkp+Eh16YY026nDl8g9xFXPcbMxc3NneQ9JeZRn3NVld11vAF aF87ZG+34iCB4/LpygPW133FQK1/1zs4Tn6CXPzHaJJsRBNZK+I4K17ZzcYp+hzyDtJh /J4IwLeWfyjsuHgm1GB3DxW9PaQRiRODzttDT3Kl0dALDm+cvyQ8/LNKpDh5ohDCpZ8A ahzNLq6Db8yJDT2l5er3PvAMoc6neu8cgd6FvbNvbBDyVGGB8ChcmcBE5cQkHmZ47yye Nzorc/uq09Ak3RpnzDbt6sybigQaMT1K6ru1SJBoV0ovqXNHydfa1IYXhx6io5AdkJeb dHcg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=4wZ/a8zoeqVIA35WySCRZ0p2VjKumv5FfIt/bUIOSAk=; fh=sK+NRfS3jYWFbN56hTft5Ff8ZHE1hpe/SjGfkUJrZdk=; b=Stb+ctIxhEzdH/XPfBvYFLiG0HVS4tzw14kynINPVjtYy1xUXl9Hb0bGX/0RoLrhcm bpmQBibPt74th+xlD/Ymjf5DHZ2nNn3iLLjw+yxFUgCeZ3egL0HyHhKolMduoae5267d 81Up5cbN0T0vV9BpiGzK2Inm72q623vJGC4q9OmZIwfdU6V+AkD7sxg+uRZDgyc3AuvJ wOqUhFikgp2m0XkIMD8VxagFZC28zS9ja+Fa+2K65YH899Qy6bRdah1Nge5gSGav/oD+ w/vII50mZjKHvyDdlYTrwV+LYF8uxAsM8ejxHCLamx9tjTJ6D0gHSQkoncReDDInqHcl Gatw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=i-love.sakura.ne.jp); spf=pass (google.com: domain of linux-kernel+bounces-144878-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144878-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 x6-20020a631706000000b005dc8650cc61si7455986pgl.847.2024.04.15.03.07.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 03:07:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144878-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; arc=pass (i=1 spf=pass spfdomain=i-love.sakura.ne.jp); spf=pass (google.com: domain of linux-kernel+bounces-144878-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144878-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 EC3982875EE for ; Mon, 15 Apr 2024 09:58:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 310A345BE2; Mon, 15 Apr 2024 09:58:55 +0000 (UTC) Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) (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 70E0C4D9E5 for ; Mon, 15 Apr 2024 09:58:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.181.97.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713175134; cv=none; b=Byk+VdyHcg/l6UWH8xdA5Il5stWAdgPWPdFHN1pRbx4sHsDfdjbYmvupUp6CuHKOYGKTqmwVvuEabNPxRipooZDl6+hTgX9iH3mgxqakczsuWUIR9An1yaIFVO/iW6ADgZllo0ZGoqmITsJZv4RJa/K1VMIniV+RX66yyk0N5fM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713175134; c=relaxed/simple; bh=YEylZOmwmPaJuUMD5Rwz8peT9YSG5cuo3z8gAuHuq60=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=I1RprzVrqgNY+5nBKFBxO9i268NXFw7z2VIfohPcxKy+wIdtOepNXbQ+WiFgBnJvUe6FQHMDG/M1vjNG076GBxpBfAD6e9QmQlgZb7PvGeUas0qPX/LbGBS3k1gYtQwiYb5tbuGDHFS+u7TErX03BYgwDYLfGKFD8RjZzhzkLz4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=I-love.SAKURA.ne.jp; spf=pass smtp.mailfrom=I-love.SAKURA.ne.jp; arc=none smtp.client-ip=202.181.97.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=I-love.SAKURA.ne.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=I-love.SAKURA.ne.jp Received: from fsav113.sakura.ne.jp (fsav113.sakura.ne.jp [27.133.134.240]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 43F9wWlu013407; Mon, 15 Apr 2024 18:58:32 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav113.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav113.sakura.ne.jp); Mon, 15 Apr 2024 18:58:32 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav113.sakura.ne.jp) Received: from [192.168.1.6] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 43F9wVQk013402 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Mon, 15 Apr 2024 18:58:31 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: <2ab55fd1-7eb0-488e-93ea-660fa05ee43a@I-love.SAKURA.ne.jp> Date: Mon, 15 Apr 2024 18:58:30 +0900 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: [syzbot] [hardening?] [mm?] BUG: bad usercopy in fpa_set To: "Russell King (Oracle)" Cc: Mark Rutland , Kees Cook , Linux ARM , syzbot , linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com References: <0000000000004cf5c205faf1c7f3@google.com> Content-Language: en-US From: Tetsuo Handa In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2024/04/15 18:44, Russell King (Oracle) wrote: > On Mon, Apr 15, 2024 at 06:38:33PM +0900, Tetsuo Handa wrote: >> On 2024/04/15 18:02, Mark Rutland wrote: >>> 08626a6056aad824 ("arm: Implement thread_struct whitelist for hardened usercopy") >>> >>> That commit says that all accesses are bounce-buffered and bypass the check, >>> but AFAICT the fpa_set() code hasn't changed since then, so either that was >>> wrong or the user_regset_copyin() code has changed. >> >> Then, can we go with https://lkml.kernel.org/r/0b49d91b-511f-449e-b7c3-93b2ccce6c49@I-love.SAKURA.ne.jp ? > > Have you visited that URL? It doesn't point to an email containing a > patch, so sorry, I don't know what patch you're referring to. > Containing a link to a diff. ;-) diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c index c421a899fc84..347611ae762f 100644 --- a/arch/arm/kernel/ptrace.c +++ b/arch/arm/kernel/ptrace.c @@ -583,10 +583,15 @@ static int fpa_set(struct task_struct *target, const void *kbuf, const void __user *ubuf) { struct thread_info *thread = task_thread_info(target); + const unsigned int pos0 = pos; + char buf[sizeof(struct user_fp)]; + int ret; - return user_regset_copyin(&pos, &count, &kbuf, &ubuf, - &thread->fpstate, - 0, sizeof(struct user_fp)); + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, + buf, 0, sizeof(struct user_fp)); + if (!ret) + memcpy(&thread->fpstate, buf, pos - pos0); + return ret; } #ifdef CONFIG_VFP