Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp7510lqe; Fri, 5 Apr 2024 10:46:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUYhR9NqdausSMIil8w/F++zA5DgH+qLKdApuOilyRAkgz/i6dHxlmwQ6yhu/8uFpvN/8J6YhhzdtXEsru0RD7jHygGZgJPTKyj9AUIHw== X-Google-Smtp-Source: AGHT+IGW7EMQjQ7scwyLl9fecgk5X2gmpHqx1u6EF+isUJTfwSxGwEfQ1vXZOlX/Xz98khWbaX7O X-Received: by 2002:a05:6214:b13:b0:699:1b89:178c with SMTP id u19-20020a0562140b1300b006991b89178cmr5740763qvj.2.1712339161766; Fri, 05 Apr 2024 10:46:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712339161; cv=pass; d=google.com; s=arc-20160816; b=cm5pEiKZSgqSR8J3xt/PkODQoJESR0JwL9vmLauxAmrO3yHfjAQxH2scfU2w3lUI8U u6olRVCspJsIZqDEDo5S97/s8VnpUeZun4GxV3JrdoUg6OJesdFjjJJ/aqFcIVDdGHE9 mtivPwsBmHwSZHPeeGn/D4k2SMARP5DxCmebZcw4K6/2ACwDsLKswSkyKQUE07IsnGLR uw6f9MSoTRGx4SKOmusDZ9Fqn/Ra+b12zH8wQtITAKA1S05a9eOJYIUNAVwQZQ5rHaxS 4wJwHec74mK/mvLEQx+T3fSq6B03CZtOqlNmS580T4GggKXGatd/YDNO4Mp434e4vyL/ Zj8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=wTKr7S2CnGDPCH8KeSUhRKLbKn96nzFzodF76YgrJho=; fh=Xe8+aIhXI4Nlkexkpo+9XXLyzlA02WvAulwPxKsxnkw=; b=N3XMVlcP9g+2sN32PFb8nBJsJbYttR/jSmYLbAxPlRpDPgefJahfGp+vleFv8CnsFJ PD/YXr7Z/tFUsovhRYVOWmrPdFKpqBw6Ne4iGM4TQtLvDmEiWIJhpBG8p9fO3N9IgviZ eL1YkPNt+xFiG3yh0GMwmCQrKrKncftzULKOClZPJAXdlTsrjAPJ4CmknYTUVtD8+EBv 80o3emPwBvA2Ou3b8BKNwRPxnfEYaYJVFGXa0upVdRTTOW96X2Vii+lEA3UT1aL5XuYj wTloLX+c9hFboiZiWTwAhsdr78bJq/iYw7QilgpTs92LTeCpukzsl4Au/3lvyjDuo3hI pNDg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PZppgxgv; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-bluetooth+bounces-3290-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-3290-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c5-20020a0ceb45000000b0069934506accsi2184522qvq.324.2024.04.05.10.46.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 10:46:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-3290-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PZppgxgv; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-bluetooth+bounces-3290-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-3290-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7DB8E1C21463 for ; Fri, 5 Apr 2024 17:46:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 36743171E60; Fri, 5 Apr 2024 17:45:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PZppgxgv" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (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 E6CCA17166A for ; Fri, 5 Apr 2024 17:45:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712339151; cv=none; b=R9u3PwazD/DOI+rQM3R/olSrJTGUjc5A8OuWi1Bi3z+GmbDcYajrYS6TNWjx1eZaFk1M9CV9Qais9LkWT5QlZp0glDepUdewqFe2Vx/YW/jS9D8xJA6DFDSyoUV1n0b/7ddqThJ5LUC8+UbAcSmmMhqCc+EWyxSVppaMNeD/x08= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712339151; c=relaxed/simple; bh=wTKr7S2CnGDPCH8KeSUhRKLbKn96nzFzodF76YgrJho=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=KSymoc3IJx/e6QtH9ehajjoWvSR/+mzWIc1ODL6oaX/ODkBOok4RoPLecEzMxViu3mKuTMBGZ7GrtO9auf64tHMS307Ho0yUMVMEm62+wrYZWVItu4TfvGlGfATJSKiMFvxga801opkDeXRaRIAPWmm2O4y0zQt6WtAdWqEgRHA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=PZppgxgv; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-56beb6e68aeso1444a12.1 for ; Fri, 05 Apr 2024 10:45:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712339148; x=1712943948; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=wTKr7S2CnGDPCH8KeSUhRKLbKn96nzFzodF76YgrJho=; b=PZppgxgv3sXQ5rxBacQdn/ZCVjKHGo/bOeV+IPdhHr1lRFql2XWpnBDmpThAhNZLMJ 8LEt9Ja2ub9Trpfrypt/+CVvFnaLaFoigDmmZEZ6Wz2D1AEaP5WsJkRJ1ZuH7/p6vFwJ VYUlnUNdNfPqEKKw6PavVhDV3bCLzQ8/fu90lt95UmV+QvtJbRRudaoPsT8yiyho9oKP vRkv3ZBpG2/rBcbbIz3/CHZ2Im7QKAf4f1UpzV+vsZWtilfIYssYhBmQ2vCdM+cnC3vG +uGrTioOEk4cOepPAcjvwO+gmk55vIZJylySm6fhjX2auqd3y2EfXgA5jKgYgeXK9Cz3 u87w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712339148; x=1712943948; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wTKr7S2CnGDPCH8KeSUhRKLbKn96nzFzodF76YgrJho=; b=GnlLLwrB32ePAGTmOwiuRTUmLQqdkaGpPlHjbFtLN7TEwHvc8MVt0VGJ0hZNQXliUc gOPNf38fDbxmdAtC/LbNozSmvYh8jBh7KDn68WAXJMy5xqjEWiveaYLr1IhVCemuW3mf fh9M/Gb9X98ejkHTZwzzebZuN2GHuW+gTZFyjA8lTmXXxmfBrYBmrUHObzWPhzcObr5T XSuaP7D929xG3y0ttz2SFSWUGXhFBTddcykK/F+dSYX5qVqXGGXAxhnRV2ziNKCFKjMO 9O/jQRXLzcdtqdf+OsargJT/mAxIxXGUTPmkFzX8EupI3g/69a+9PYvXvwqXIaji26SP As3Q== X-Forwarded-Encrypted: i=1; AJvYcCXSj+6EGT4+uRpVcxKiNy1lwziM2dH3kcJY+X2KHJnmCnHnCuNKWFujeaAe68NaLAkoQl3SrNmG5pgf9Mpk3cxRL+NkQIpyiPYgYamfw2Ix X-Gm-Message-State: AOJu0YywyXPOCPp2KBOICDvAfTZRkOSUvNGM8F+NVPSXVwu5Zxo4V5W4 YuoRFiVK18K7tHv/mDMa06ATmwL3VuwZ+lT75aNB0xnTOQ5crDipuAB3ZM3JY6B9exdL5pIqYAC DPWJiunudX6yY4nvo55d/rJDk9mDvo3BEtiYd X-Received: by 2002:aa7:d94f:0:b0:56e:2239:bcbe with SMTP id l15-20020aa7d94f000000b0056e2239bcbemr5277eds.2.1712339148083; Fri, 05 Apr 2024 10:45:48 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240404123602.2369488-1-edumazet@google.com> In-Reply-To: From: Eric Dumazet Date: Fri, 5 Apr 2024 19:45:37 +0200 Message-ID: Subject: Re: [PATCH net] Bluetooth: validate setsockopt( BT_PKT_STATUS / BT_DEFER_SETUP) user input To: Luiz Augusto von Dentz Cc: "David S . Miller" , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, eric.dumazet@gmail.com, syzbot , Marcel Holtmann , Johan Hedberg , linux-bluetooth@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Apr 5, 2024 at 7:38=E2=80=AFPM Luiz Augusto von Dentz wrote: > > Hi Eric, > > On Fri, Apr 5, 2024 at 12:30=E2=80=AFPM Eric Dumazet wrote: > > > > On Fri, Apr 5, 2024 at 6:24=E2=80=AFPM Luiz Augusto von Dentz > > wrote: > > > > > ave used this so far (without risking a kernel bug) > > > > > > Fair enough, if we don't really have any risk of breaking the API > > > (would result in using uninitialized memory) then I propose we do > > > something like this: > > > > > > https://gist.github.com/Vudentz/c9092e8a3cb1e7e6a8fd384a51300eee > > > > > > That said perhaps copy_from_sockptr shall really take into account > > > both source and destination lengths so it could incorporate the check > > > e.g. if (dst_size > src_size) but that might result in changing every > > > user of copy_from_sockptr thus I left it to be specific to bluetooth. > > > > Make sure to return -EINVAL if the user provided length is too small, > > not -EFAULT. > > Sure, there was also a use of -EOVERFLOW and the fact we are using the > return of copy_from_sockptr so if it fails we just return -EFAULT > anyway, so if we do start returning the error from the like > bt_copy_from_sockptr then we better figure out the errors it returns > are proper. > > Btw, do you want me to spin a new version containing these changes or > you would like to incorporate them into your patch and spin a v2? Please go ahead and submit your own patch(es), thanks !