Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp115686lqf; Fri, 26 Apr 2024 01:01:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWKPTwNmnjev38NY8/SoFBeou8xcEo4w+F/zSAeJkk/+uOJnw87SJoMSRaFCQQw6W/BM7Ia8QkcERrRDfb3PTzcRmdUPOzN7Vqe0ZanYw== X-Google-Smtp-Source: AGHT+IEQAG682r0KdhxKgErFGlebJOUu9oF2RuyaTjZdRPJuTWtvvGuoVT7x98n2ixpTm+9sxI/J X-Received: by 2002:ac2:5ec6:0:b0:51b:5da2:2dc9 with SMTP id d6-20020ac25ec6000000b0051b5da22dc9mr1582824lfq.52.1714118470413; Fri, 26 Apr 2024 01:01:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714118470; cv=pass; d=google.com; s=arc-20160816; b=amxQKyDvWsm0jG5RyCTy6QcClUE9euH7VnMIZYxKIercPK9o4oin6dFS1SgZz8Z6DM gNNMlodU/2bAv+pGpY4+RmEcHJyJANq6yiNkpKIOTIwXrl1Gy5HPlh8ffLicouyqaSUw AdCaXTyWNtDTnC55B9/v9lDHqcvG6jnXVLgxDJ3Q7oh2EWNCU6iLL6KdlU2fKvCDnQZs hWqGSt6AuWRC7ACazrtqYKNG8kJyf8MLxEoU9OFoVay34ibzmyLrGkOj6l6EW2TbEzFV Z+nUN2MFbc1KSLz3Xftg8BWcpeCuC6LvDogNVP7T0N4GyFivUJ67Pl5atXXUF5iz5xBC JT0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:content-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:cc:to:references :in-reply-to:from:organization:dkim-signature; bh=xIFFxT8ZyW309/4jPgibBUS9mKjAZgteIkx/pxryLuo=; fh=C+5pQyTXyeuXRoqu92Ne/IeKb9/TU34JMpasN6sHECs=; b=MAmSBkKtEE2/HvQ9CKPGFw5lzDF3K/HA4gxImO0/bOmWPd9UAzEqiHc4qw+buFMYWn kwKWP6pxZRCeuX4eAtrAadgq9fVX0W8kYGwzW+A3QrNSWQaK4PRIqyTC0oK5MpjEPFoT jmt5TvKOFsUYK+zLQ+5UilVL+tKGYT4pwiBdRUKzDnyEZFG0teqAD4XPs5vu65aR27wx ahhTdSCxDY+5Au8lgtbg1Z9bePdCgS2udZuQfkgd4DjpGWfOspvZU9e7up+1SEjiaInK yP8IJOMyd8us+CkDWwHlKIIhbEWQxUsUCL5DP+QZ2aHM/aYItJ2sYD2MRIWIiE3anDVy ltNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DthkIkvj; 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-kernel+bounces-159670-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159670-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id p13-20020aa7c88d000000b005721c06cfc9si4981837eds.151.2024.04.26.01.01.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 01:01:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159670-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DthkIkvj; 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-kernel+bounces-159670-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159670-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 244D51F22253 for ; Fri, 26 Apr 2024 08:01:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 53C2713CF8A; Fri, 26 Apr 2024 08:00:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DthkIkvj" 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 2D50F13C90A for ; Fri, 26 Apr 2024 08:00:42 +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=1714118444; cv=none; b=OOxML6mwpBdeU7z4cQ63pXJ027lUkKt0Y/W1q27vDagsD0k2Qw4qwlG5IMaZpR6NFMuiJT026WieNz2RUfvIHXchmHgzJ08cDQtOsmn7qJihI69kVNt/0MJD+L2/T/DWqNfCqAlhKqaGWqwD32OMISKYlJgwd6kfaHjwbMQBLmA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714118444; c=relaxed/simple; bh=8moJHIF915kF9JPZZi2hSy1ahaIWtygA+5VPkH7e8r8=; h=From:In-Reply-To:References:To:Cc:Subject:MIME-Version: Content-Type:Date:Message-ID; b=PKK5kT4cOUQDMNC9QNeRF09VD1vPqcNSohgPQjnmdJZsDEfU8uVCDR4TXojAS2aD6URnVjIibTM8ETZ+horcG8J1I52cxrS8l94qy5I+Ek6d3cVwPkKetIWda404m6hk6psz+YEq6oPnNUZYbA6aauMNJ/9cbiVc/69lLF+XoAU= 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=DthkIkvj; 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=1714118442; 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=xIFFxT8ZyW309/4jPgibBUS9mKjAZgteIkx/pxryLuo=; b=DthkIkvjr3CwlIX2FtQWnIvf15oQZS/O7nxVr5+zu8WvQKulzHBu9NUwabCX9aGSsRTD9+ 5wh2CSpN3I+lxjERz0QK0XLLMGr+nHDLw1TJTlc3rw+KxY7Y3yC/51iMNQ+xAgTNkxYuch 2jFRsgqrjcV4S3aK+D00M+avVB38BOk= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-573-mr3uO8cZOamc3ageCNO_lw-1; Fri, 26 Apr 2024 04:00:37 -0400 X-MC-Unique: mr3uO8cZOamc3ageCNO_lw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 BE0893811701; Fri, 26 Apr 2024 08:00:36 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.200]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16B5016D93; Fri, 26 Apr 2024 08:00:34 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20240425084537.6e406d86@kernel.org> References: <20240425084537.6e406d86@kernel.org> <1967121.1714034372@warthog.procyon.org.uk> To: Jakub Kicinski Cc: dhowells@redhat.com, netdev@vger.kernel.org, Jeff Layton , Steve French , Herbert Xu , "David S. Miller" , Eric Dumazet , Paolo Abeni , netfs@lists.linux.dev, linux-crypto@vger.kernel.org, linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net] Fix a potential infinite loop in extract_user_to_sg() 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-ID: <2101063.1714118434.1@warthog.procyon.org.uk> Date: Fri, 26 Apr 2024 09:00:34 +0100 Message-ID: <2101064.1714118434@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 Jakub Kicinski wrote: > On Thu, 25 Apr 2024 09:39:32 +0100 David Howells wrote: > > Fix extract_user_to_sg() so that it will break out of the loop if > > iov_iter_extract_pages() returns 0 rather than looping around forever. > > Is "goto fail" the right way to break out here? > My intuition would be "break". > > On a quick read it seems like res = 0 may occur if we run out of > iterator, is passing maxsize > iter->count illegal? I would say that you're not allowed to ask for more than is in the iterator. In a number of places this is called, it's a clear failure if you can't get that the requested amount out of it - for example, if we're building a cifs message and have set all the fields in the header and are trying to encrypt the message. David