Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6876583rdb; Tue, 2 Jan 2024 17:39:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHroLkagfU2iReZqJQUhcGePZSRsqt9nZsY++0BkIiOZjwK2HMaO/l71/w/DkgKaj3zpMfk X-Received: by 2002:a17:903:2450:b0:1d4:aab5:afd with SMTP id l16-20020a170903245000b001d4aab50afdmr2425020pls.58.1704245952620; Tue, 02 Jan 2024 17:39:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704245952; cv=none; d=google.com; s=arc-20160816; b=mfP/BJBme9zqcz5WTDvdAPMdcPx7FAPQOJ8v7CC0IMydAzAmUqHTPXXXrEpX3JE+UR NHqILY6qSiZRrpMcmIS/yT9jgeNViocgJXNpMVdPS/Yzwj03d/imYSPPjYsRUhvkDMY9 K3rkcqELGXC9LGqrua95QPQFiEwzB/88t48Le8avo82km7uecaqmcnaA6+aaeR9MbSqE BVaQsuembmrrcwaxIQDcL3QQILLLxkfEHh7BnTFS4HhEq7A4mp0yZYjOVKJolGN8wy1r XprMIcWJDWF8wJAD2fK5Nx8OTGX49jwzps5ksulDlEep1JgxQKlqNJslk84acg46byFk xX1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:references:in-reply-to :message-id:cc:to:from:date:dkim-signature; bh=FC3YNpZQ824RvnO6l/cHjeHZ3qIOYGfCscSR0Xu4SHY=; fh=zq4c6jPLVDA9NVpsYAU0atorrhbUBlhqWkOO/hWgMz4=; b=gTvi0LBQk1g0MnEtLaypOrwra34HQVTFYiLk4+FfK7SGrHv5tmRRRO1zqOvAw55QcX SXAZj2EQtVNCNl6D+liv6YmE0CQKrmkxRgxv/3so+XKWoQeT6/bKnznMQdZ8YHjrxHSH Fzu04rgb1TQCrpfQPp0DoZh27QCfOgU2i1NFqMEjt6YxISPLQhc3oJO8eFH+LZPjKI7z mvD3TMFqeh5Kn0phkhmqGOVaKpDjI9G+cQ8h0OBywpV3/uldsUyuyOUHX/74NZ5SYtSv uSF59+8dHpvwaGHZ2zKOlSDXVl4uXP8wYMSjGnzK0gK2YBb6ST3TQ3lT1FRmCJPSFaHK B1Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aLvOEsXZ; spf=pass (google.com: domain of linux-kernel+bounces-15041-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15041-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l17-20020a170903121100b001d4931a0bfcsi8783635plh.638.2024.01.02.17.39.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 17:39:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15041-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aLvOEsXZ; spf=pass (google.com: domain of linux-kernel+bounces-15041-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15041-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D9192B228F0 for ; Wed, 3 Jan 2024 01:39:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B745A139F; Wed, 3 Jan 2024 01:38:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aLvOEsXZ" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) (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 96F381108; Wed, 3 Jan 2024 01:38:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-680b1a2c966so14930136d6.3; Tue, 02 Jan 2024 17:38:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704245936; x=1704850736; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=FC3YNpZQ824RvnO6l/cHjeHZ3qIOYGfCscSR0Xu4SHY=; b=aLvOEsXZoBm6zsmKM6cYKA3UPQN6cc1g+G8aUxtPjaDaFs5Y+/WsUyzakZUUm+rPv5 g8Vcsjzpx6SDoyaVWWj5i0J4zxD4BK68MyE9ypMqLijEi36iDDpAVgzPPi0CxFMHj+3a nNtJlVVfOTG9s6AlS8ULVc3I+zFfsEDIIdJg2n/cRcwQs42bJ+OaohM8l0UtBNw1CB6s kbMyWCPBwLruX2J1mOsHpIkPLmumte3fpVZiepVHZv+rYODqrLe8BG9beupB5HNCTdPI BpTsZyXWJ8EH4KbZd7utUtLhBb2KiJsu246BDgdO7Sq5AlbyPPQ+qHoNgj0/uxDuCFDt N2XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704245936; x=1704850736; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=FC3YNpZQ824RvnO6l/cHjeHZ3qIOYGfCscSR0Xu4SHY=; b=vxvlK6JrjzeFODkhqfsUcog+nTTe1aR4zIx9I9k5TswQoCXr9AUb5X6JhPwFPJHitm trvrmA9OvXq3VE9HNw0pzowYlSNcqAbIL7lx/18AIEnKhJLAbqohImMmPcXSgqA01MwB gWd7jHcFsVScYhSWXBRp4SePykG3gfJyA1dt4jkHAJfYnTCuOGbDwYnw8wyoynKwDy1e FZWSf3SDUVbvBEUuTu+GmcqTUPxasxUdploJEbMetCAVsQTza+mZhWazMVMT7WRXuqqF kgAsfcXOQ6+v7QgGSDkPAELRNPDLK/ftAIsSwHagkfxiUDQt0rvut3KmzD9OVDiIB7NV qGag== X-Gm-Message-State: AOJu0Yxai061RoCoHNqZydyJ/DQhN1MIz4pJeHkULb4Qe+TARuUrSH4p hpDw74ouWEmP264owjAoG4jvZUKmG3U= X-Received: by 2002:a05:6214:19e7:b0:67f:4f8b:e298 with SMTP id q7-20020a05621419e700b0067f4f8be298mr30598302qvc.0.1704245936508; Tue, 02 Jan 2024 17:38:56 -0800 (PST) Received: from localhost (48.230.85.34.bc.googleusercontent.com. [34.85.230.48]) by smtp.gmail.com with ESMTPSA id w6-20020a0cef86000000b0067f77ca8d18sm10555731qvr.96.2024.01.02.17.38.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 17:38:56 -0800 (PST) Date: Tue, 02 Jan 2024 20:38:56 -0500 From: Willem de Bruijn To: Marc Dionne , netdev@vger.kernel.org, Jordan Rife , Jakub Kicinski , Paolo Abeni , Eric Dumazet , "David S. Miller" Cc: Willem de Bruijn , Simon Horman , linux-kernel@vger.kernel.org Message-ID: <6594bab0a524_2c093829412@willemb.c.googlers.com.notmuch> In-Reply-To: <20231221131230.2025000-1-marc.dionne@auristor.com> References: <20231221131230.2025000-1-marc.dionne@auristor.com> Subject: Re: [PATCH] net: Save and restore msg_namelen in sock_sendmsg 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=utf-8 Content-Transfer-Encoding: 7bit Marc Dionne wrote: > Commit 86a7e0b69bd5 ("net: prevent rewrite of msg_name in > sock_sendmsg()") made sock_sendmsg save the incoming msg_name pointer > and restore it before returning, to insulate the caller against > msg_name being changed by the called code. If the address length > was also changed however, we may return with an inconsistent structure > where the length doesn't match the address, and attempts to reuse it may > lead to lost packets. > > For example, a kernel that doesn't have commit 1c5950fc6fe9 ("udp6: fix > potential access to stale information") will replace a v4 mapped address > with its ipv4 equivalent, and shorten namelen accordingly from 28 to 16. > If the caller attempts to reuse the resulting msg structure, it will have > the original ipv6 (v4 mapped) address but an incorrect v4 length. > > Fixes: 86a7e0b69bd5 ("net: prevent rewrite of msg_name in sock_sendmsg()") > Signed-off-by: Marc Dionne Reviewed-by: Willem de Bruijn