Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp649067rdb; Fri, 26 Jan 2024 06:49:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IG9T7xeSkNZJXs+NzgK8Tvy/q7gNa8VyMZ1cjomdtt9NBI23aAJmumT1QrCxac4dpWO1sXd X-Received: by 2002:a05:6358:948f:b0:176:9e32:8d71 with SMTP id i15-20020a056358948f00b001769e328d71mr1536764rwb.8.1706280593879; Fri, 26 Jan 2024 06:49:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706280593; cv=pass; d=google.com; s=arc-20160816; b=C4XOizBDYQKJfz3lYXzgscJNrj8Mq3t/5p/pAvhyiWQ6KrqFZVS09vsnBTrkcpbjYx 1G+w4a+MRPFB6SA1Ej1GOeIhD40uzR4g7iggojg7aICgds35K4IUfi9enVhnStzEtbXr oH/M7vAVUWIPwoM8zEtKPPdlfBIf/OB4Td7obWO/0MCCuAK0P7uQz87WyK+5L71duZOy k4juLqvqR4NMsA7wanQWEv6KWr7bgLoJtW2A+HiB0cU+jTvpliVq8NcvHfg9fjb65lJe /gAAq6pxomQTbSRtZo8dPmjCF/8GUCHVNBJR9YpjLVj25JoJu0kYkXgCSUc+qPBURhXv 5b4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hP3F7tUOZj4NkFcIf9v3fxcPWZibPIm9ccpvXfyw+nY=; fh=F6GYX1KHOuGT7WFzWUGZO8PVqzMspbuNKdKxZGPg2ok=; b=L4WOzPaFNefWs1QRPuGL1iCYrlinegK2cwi97QfTPhQibkFAN71T8KvBjqWy4Wy2PN w/B7MkkblYKZpGF3Omh24/Jpwzzo1rjZqa2LU3J6ctaGi4wt4CAYqXJWLpcILLmxCvwB fjHCNKUE8v3aicavNtGB7GY8NiBWhOKCbqcdYWD4kIg8jRJUMW2mS60FO8YiWc+DZfTr 0nLejcpkmCQZFuK+R4MLzIL4DzIfvhh3TmR+PbvsJ3glEaKGSVxdo904iNAKRtEf4ECn SIvsMz3GaAi/89aTQKaQ/17eEHAifhrpENwrCtPF8BrPVK5MEuBeagWO0WS+tGwYxMKb Vgtg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gljumD3u; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-nfs+bounces-1468-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1468-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q26-20020a65685a000000b005be1955657esi1237810pgt.127.2024.01.26.06.49.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 06:49:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-1468-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=@redhat.com header.s=mimecast20190719 header.b=gljumD3u; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-nfs+bounces-1468-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1468-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 562532814BF for ; Fri, 26 Jan 2024 14:49:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CA42E1B974; Fri, 26 Jan 2024 14:49:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gljumD3u" X-Original-To: linux-nfs@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 330C7134A6 for ; Fri, 26 Jan 2024 14:49:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706280591; cv=none; b=NUUlAfMC9t0+C0XmS7OtMxKuS+1AOX+B9zq99hbnWCYBy0CIrBxixPz9u25ZvCtvHdapa8fUKaBrkEAueslLzAfUSwzi+N1Bj8JlcIUgUNP/012riEQsd1Vt7gCpZqh53NvrAAJBrb1KXjtTIwHN2GLprv83uwbyjLRq9jiFVzc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706280591; c=relaxed/simple; bh=/zYBZcx4v9usrAZRPolszdle6unUQjGL0+iI3V9+JEI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fjMhll8kxBdnyRFuj279APCyF+/ci9oZinM7RypIK3riqQhXVc9/Dm3QnqaIv4XH3UqXoUWY31L6piMxlAtNw78fpzxuCeaIrvaoQJ+85ThxSSXAkbu7wrHYwmX4saSvwxZILrfWHPkxm1lZq79KBQdi6HdLnbUzmOBH1oDv4Is= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=gljumD3u; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706280589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hP3F7tUOZj4NkFcIf9v3fxcPWZibPIm9ccpvXfyw+nY=; b=gljumD3uWCsshFBLnQkslO/pt/ix18tva2H6iJ16dPq9OtSoSk0/Gn73gnWTaqdp0uzzo0 yjnc9BDRzCFfPIc6GSPlcs0SAefE24cwR7Fl29w3S/0UXRNpTIKsKScLyOaMnmxbBR6ARC zU8HcwoAr+dy3oDLgE+uLJIaGy3ABM8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-675-H4oypw4INryXSqdgC_3fAg-1; Fri, 26 Jan 2024 09:49:45 -0500 X-MC-Unique: H4oypw4INryXSqdgC_3fAg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 498C911BB5E8; Fri, 26 Jan 2024 14:49:45 +0000 (UTC) Received: from [192.168.37.1] (ovpn-0-9.rdu2.redhat.com [10.22.0.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C54C2166B32; Fri, 26 Jan 2024 14:49:44 +0000 (UTC) From: Benjamin Coddington To: Jorge Mora Cc: linux-nfs@vger.kernel.org, trond.myklebust@hammerspace.com, anna@kernel.org Subject: Re: [PATCH] NFSv4.2: fix nfs4_listxattr kernel BUG at mm/usercopy.c:102 Date: Fri, 26 Jan 2024 09:49:43 -0500 Message-ID: <8D1EF949-6A21-4839-B044-6AD4ABD49614@redhat.com> In-Reply-To: <20240125145613.12995-1-mora@netapp.com> References: <20240125145613.12995-1-mora@netapp.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 On 25 Jan 2024, at 9:56, Jorge Mora wrote: > A call to listxattr() with a buffer size = 0 returns the actual > size of the buffer needed for a subsequent call. When size > 0, > nfs4_listxattr() does not return an error because either > generic_listxattr() or nfs4_listxattr_nfs4_label() consumes > exactly all the bytes then size is 0 when calling > nfs4_listxattr_nfs4_user() which then triggers the following > kernel BUG: > > [ 99.403778] kernel BUG at mm/usercopy.c:102! > [ 99.404063] Internal error: Oops - BUG: 00000000f2000800 [#1] SMP > [ 99.408463] CPU: 0 PID: 3310 Comm: python3 Not tainted 6.6.0-61.fc40.aarch64 #1 > [ 99.415827] Call trace: > [ 99.415985] usercopy_abort+0x70/0xa0 > [ 99.416227] __check_heap_object+0x134/0x158 > [ 99.416505] check_heap_object+0x150/0x188 > [ 99.416696] __check_object_size.part.0+0x78/0x168 > [ 99.416886] __check_object_size+0x28/0x40 > [ 99.417078] listxattr+0x8c/0x120 > [ 99.417252] path_listxattr+0x78/0xe0 > [ 99.417476] __arm64_sys_listxattr+0x28/0x40 > [ 99.417723] invoke_syscall+0x78/0x100 > [ 99.417929] el0_svc_common.constprop.0+0x48/0xf0 > [ 99.418186] do_el0_svc+0x24/0x38 > [ 99.418376] el0_svc+0x3c/0x110 > [ 99.418554] el0t_64_sync_handler+0x120/0x130 > [ 99.418788] el0t_64_sync+0x194/0x198 > [ 99.418994] Code: aa0003e3 d000a3e0 91310000 97f49bdb (d4210000) > > Issue is reproduced when generic_listxattr() returns 'system.nfs4_acl', > thus calling lisxattr() with size = 16 will trigger the bug. > > Add check on nfs4_listxattr() to return ERANGE error when it is > called with size > 0 and the return value is greater than size. > > Fixes: 012a211abd5d ("NFSv4.2: hook in the user extended attribute handlers") > Signed-off-by: Jorge Mora Reviewed-by: Benjamin Coddington Ben