Received: by 2002:ab2:5182:0:b0:1f4:61d5:3ad4 with SMTP id x2csp53079lqi; Fri, 5 Apr 2024 09:30:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXlJAargUfRSCCBwuvbHJABpkzmf04TU3eeYdvIKHGTESzVpuXO0ahkCyhXRIQ1xaokXF03mCzQm+kWZpUf7Js6+NW7/hsM2sILJlD8Nw== X-Google-Smtp-Source: AGHT+IGlZhjJTRVBRhYWenQspLO23JKxqDmNAcUU9dq+0niDMxA7SXUmKJ1SPFErzUhF7lP93SaE X-Received: by 2002:a05:6a21:1f04:b0:1a5:72dc:2fe0 with SMTP id ry4-20020a056a211f0400b001a572dc2fe0mr1807931pzb.14.1712334647320; Fri, 05 Apr 2024 09:30:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712334647; cv=pass; d=google.com; s=arc-20160816; b=dNIu/v74S5B+L8FLB6Btcj6v+p4MjACRB1BuIEt3B6ygxNQ2jEgFyYyUDE9ISJ0Sbx 7f2xb0Dwk55NgH6tzAQ2njguAR89vwEuADkpi18udS3mc0V051UuW2xU7bTdXijWokpc qYh1Lm1acflB8qMwziLEXSqDuod1KI88Iilf4qL4TEH1BvC1lkf9Wzpjhh6LUGVRxccL ek+t2a7/Zi6/dEWwiy/vqNuNAKcM6GnYQgmxOZS8BJcYCQDKA6GG+Dv+ua1QQZGTqa3m GfR41a7H9pVWqsXmkcCeR4I1s+pzNOTjxisCijv735pmbRY88eygn++FFXTxvkwfgxKt P2BQ== 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=mZAO0eGvkxHG2mpyu+CTArarNbr1y0UO3cO2sRLcGX4=; fh=NxHNp2rKfWB1eFOA5xbOTVznd8jmJOIeP3OjXXnZdks=; b=bGzzqUy0dK6NGDrsiNYoYNndU1pFu508fBVbteK/Ymjhc3E8ih82UFsTDmleVxAwIQ TK+s2DDhzKdFZP9C2PpoZs5lhAL8TCDVvNcHzPOV6X+XpTQjiuYXDBvmkVmqQzlRWjaA SkLFv+S0qEHfIrg5KZdwngEfpATJTg7xTU48DETLQPpNhO/IeV/g5zIaUdT+MSVxThzU 9cPtiX/hSn8E7Y3D7wnlDi+CQGaUf4InEHo5thifZ4FVwoer6cwwt+vvur1pqCtq0CKR Zxs2uNNVgjbJs1FzzGS4iCiei8wNCarcxLGVNzBFJGC5d1kDO/QkLDTTH1EIHW8SbZpQ yzCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=0Cfaaa53; 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-3285-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-3285-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s14-20020a056a00178e00b006ecec8194ccsi1629183pfg.370.2024.04.05.09.30.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 09:30:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-3285-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=0Cfaaa53; 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-3285-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-3285-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D4429282E2B for ; Fri, 5 Apr 2024 16:30:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D3D4120B0F; Fri, 5 Apr 2024 16:30:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="0Cfaaa53" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 979881B962 for ; Fri, 5 Apr 2024 16:30:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712334643; cv=none; b=jtI88s6qVRP8xteGsprF9YKL/tuLA4GdZga81NequlgbPaI016/hqrsicIj8xlP8pUCp2+AA8Pm2TrUvO9CmbzZDmtjwojltqGp5ial0lPW9zf9uUEZ+VidAzPddvuVbwaLphB+aSw2FJiv/o/KCW5Od9TQlQWC9lbeDXx2y0/4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712334643; c=relaxed/simple; bh=mZAO0eGvkxHG2mpyu+CTArarNbr1y0UO3cO2sRLcGX4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=OxjLca9fBhtZ6GJgdDfG3fra9VEflFt9wsOdTMYjFpspoIrZJNKB1s2wyLSFhoVtpBQ4tNMS8nxccuOl41l6HzX7cIE9BTFDa82WyOSZXby6iyr9GhrLb50Q0arRKHUoVnBtlTX0Tm9pvp0Ew5IwLlrURu2jlOOt0ePQ10RHSBU= 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=0Cfaaa53; arc=none smtp.client-ip=209.85.208.53 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-f53.google.com with SMTP id 4fb4d7f45d1cf-56beb6e68aeso13842a12.1 for ; Fri, 05 Apr 2024 09:30:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712334640; x=1712939440; 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=mZAO0eGvkxHG2mpyu+CTArarNbr1y0UO3cO2sRLcGX4=; b=0Cfaaa53DzmmjnfbvYyIM/VTyn2u1ZkXnBM0g/B1Rh/NmHcw8hiB8N3Co73zN6ttNo XX1QUzoX0vpMeOAyPdx6E4Twyc9MZAMffCxS4UTW9mpUFyMif+Fy5KPVosanUSm5LEaA XEcofDgRlsBQzAmhimWNxWCzeRhb6XhhPgT3gLTPagFxdKSJ9igQjPsUmrCQuoI15S7o 2W3jsaF/29a3pgwJrQCKgN5MHubNYqB/pojcTjiJkcQEd60RuVC/n2g7ytl3w8i8OKkY Fg6tT205xQ5MI9C9vU6Gyqr5a8cmywld2pNWEgfMRLhRSGgEQ9ie+tJ1VoN8pHGwkxZX g2jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712334640; x=1712939440; 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=mZAO0eGvkxHG2mpyu+CTArarNbr1y0UO3cO2sRLcGX4=; b=T8SnoCX3rjaXdis9Gto4wjjOK90qgngi/U5Yljg38nYt6RcwpBDIjJlej9a6A2IyMU Lk0KYOmjAnyW81S8Vd4ge9QriT6oXLr3zFE+AK1UKWOBBvru+xINoZbm0dFIVbVQwDq7 Mw2OM4DW5lQmEX1uDt6rG3J5ovue52bXvxd/I8pxB6ztDEnqV4dJsJ7BQbrimI9OwbH+ CnUCnn3qLv/5GdhVeHhjMnm+zYOnozruq5rA+ntFYiAYtvyA/aBhUv8hOI69KJsrplEu kwaOPJ+BXKbq/EL2ltlPemLQcgU0W7IcGOdLFPqoHFyMPSEt6V0UP6zQ21yO08PYIAlP ApZQ== X-Forwarded-Encrypted: i=1; AJvYcCUnKVMeFBgNiEHKPrjYRfbzZU31iMKCPfUciQMGVOrzXPP7wUIwh34bJKTLX0lInujxzoTlFpD5AhVFRvuiDYgEVe6V2PJMZF1hC9BhugR6 X-Gm-Message-State: AOJu0YyoIy+hKX2U13nRWpH9eXevx9qBtjmI2An3ePmv0AJ6JHOR0yJ7 0GRacNAF3xTLd9pXu3rujTPqLffHbB5qh5qvxpHka0DTYaLMcYP4J13bcgSo57N5x41F0W/xCRF pP7wW7Dd5a2UpenSMZn905OPD1RCm5v/39ggz X-Received: by 2002:a05:6402:2035:b0:56e:2b67:a2f8 with SMTP id ay21-20020a056402203500b0056e2b67a2f8mr239524edb.7.1712334639671; Fri, 05 Apr 2024 09:30:39 -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 18:30:26 +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 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.