Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp732150lqb; Wed, 29 May 2024 09:00:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV+Ejanfn+aLvFN1HrPOFIn2nlGF4KhWZNoTS8SQDEKmfjwAXDt1W4r3R0e2EYqCtvQnGDx7gqtV6SWdIbtAnKVxAyDG+muGxjznnpueA== X-Google-Smtp-Source: AGHT+IH+STElniMHTKLoHk+RF1cYJSGYee3fzC8XrqymWgKTwO1oObhYPSDyIvTVFmi+d885IEZO X-Received: by 2002:ae9:e704:0:b0:794:7158:f206 with SMTP id af79cd13be357-794ab110c06mr1423388085a.67.1716998428143; Wed, 29 May 2024 09:00:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716998428; cv=pass; d=google.com; s=arc-20160816; b=JDrRsEVFN3kR3bXTYfhmKZ6vsDrNHE9U7R4tQd6E9gTJ/6Z3qkXjrK5gbDWtzYXERJ ic2lW98+ay4kymErEHdNxmG0qHKXOmFxeW1U01FoIHtlUTUryhPRBo6ahSy/dkKf392q MSy96chrmW+iLIKfqw4YIxA5CO8Z95OpazPk1EIx9abcrkBeqI580vZtASlD2CuH8K1i uFfIJ3kEuX7dEffjl3GEbaFTNoFKQkojx5tGgaMpEFM4bE5PI1UIjvQKdsJ1AA6KY7l+ fpc4sO0kHiMx9fqo54Zna846E4X34bmIdshaqif8icFkv3ABkps1K/BlVtF8VXP3Fcjw ULQg== ARC-Message-Signature: i=2; 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=C4K2QerpQV9MXwwRc8iWQmIO1ZXCMRqUdixm5NbWUn0=; fh=oP26Wsi/KAfZMaITGujT1nGl5p6BRRkQ4sba9DwAe38=; b=l9j29NPLEmzXSrWJRntPtkN5x7sk/RegBoq0IyjZ9r1FejRJZnmmRFP7s/DTPYh/ev B3OiPEz05CEBqk1opbyn63gshko/EY7iIEK/kPGg7n6beuUXMxcbc46ke++nGGWhb9dp k8TzKXvddYK/gdLX95fQX3iU0zXcEiTsrlvJvcDhpu8PYbVHObKRkJzv0R08TVGqJsu2 si/g23MXbxf4BZkzSV0mMqE0OmKLYBsZfcNraZNAD8dvmTxaYGisfMuRqmVLeVi+7EMM AEEgIjLsJS+lFjf59vL7Oos8jAA9BdUQnjg2IPqnSMsltR5pUUVnvVt76M3twULMA5GL A8fA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=biw8bEiY; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-194401-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194401-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-794b3ff4f74si1192866685a.447.2024.05.29.09.00.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 09:00:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194401-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=biw8bEiY; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-194401-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194401-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CCB8B1C23A52 for ; Wed, 29 May 2024 16:00:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4CC491836CE; Wed, 29 May 2024 16:00:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="biw8bEiY" Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) (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 01AC9C8DE; Wed, 29 May 2024 16:00:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716998414; cv=none; b=nAE3OY8XTAlC9y6hUHhj1CzELXH09Xaf3SZ1ngGTvPeAB6wGGR0xrkPMDwz/DrjL5BkzxH2y0fhUyYNXfxO/RXrwQ6wKtnGmXscoUgtUAuuYUMOy8EptmSysIuCsbTXP630fRZBz00a5d7f3lD7mdmbyk8FhGJgMXYx31JNZtTI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716998414; c=relaxed/simple; bh=1YrDqDCjeozpqGC+Hig4LtVmdC1ddiYzZ7fRqmZVvk8=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: Mime-Version:Content-Type; b=qilFlm8HF44c4KQ3twKurQYN23s9ZdZiuhyUrJwn9qzKci/9sL/v51ShDAH6IfOsudCO6DZUanwiJ5BYK/cclAbMKDjEGobA1ad62FRPuFh0F3SOi3/itzbAnS5L3WoiYO6Uzvar6veG4LFndPD0YdmMqGyx3s7yW6oU1a/jAqo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=biw8bEiY; arc=none smtp.client-ip=209.85.219.54 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-f54.google.com with SMTP id 6a1803df08f44-6ada6a476c2so2307256d6.2; Wed, 29 May 2024 09:00:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716998412; x=1717603212; 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=C4K2QerpQV9MXwwRc8iWQmIO1ZXCMRqUdixm5NbWUn0=; b=biw8bEiYTNtYI1zmd3UQ0J0nFog37n3hjEawOOoivrGXM+5ykYYnrF1uh24b4lOb5s PZEg2RmU3+I054r6Z6R1Mc1dequT8trlk2m5Gv/hpar3KJ7CbsL5eY2UJFkscdIWgyy6 lj76QLE8Y4sv4JbCF0lRwZYJ/gqNBIhmjlZd8rkZw0S2gsLnhdlMNlicXExOvvifzsGR 53wDToKkdRVjvaodatASTzxl6WxI6pK3P6GGEeAgt25v6EFBGtE07lUxm5f9l8cs7ysC VLwtOI8bN3pdk07xyy19mrGSORC8JjtH29NEJa3mftIZ7MbtReZAC7E9tzbGrKhAsiuh iBbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716998412; x=1717603212; 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=C4K2QerpQV9MXwwRc8iWQmIO1ZXCMRqUdixm5NbWUn0=; b=sE8EVTmbdLKLiMZ3MXuE1JEkgzrIBSXg0Oa9t5nbMLRqBtqETmfjVxCGkpmfGKVFa3 DuPEGnTeOr5oKieXfaAPJdBgPIQmWI9DpJMYmvOW2rBkrgTY2LOr9QNu9AtxvHclY4nJ PmBWpXZlBzUyhclNDO59vqVSARJG8Z0Ncbjb0hD8pgVjgMbLzWNBpLPrDev5cmViI4HH YF0ig9j7mEakr4V5C+WopYN/0+drgFJAVGg+y8DX8n93KYxLUKj2s2kBb9jjESqykEX+ V0x4zzJCKe9gURjPAQPjOD+5MCLFve8MfWW4oFj5XZpR2NZsV88OONKEvNqu4sI/jUeQ UUUQ== X-Forwarded-Encrypted: i=1; AJvYcCUqGBA5mWHR5jptpATBq/eRaDuctDbJWmagCSGIubwCpNCJ/+q3eEIU1WvxxqP8SABztMip1XqKtxOortrMfGxrTZNA9KICSK60+1R9RnrkR1kw5Es1wdS8eqwFxRFO7a42L+sRPCd511LJNAS9FGo/jPCKoPk/Dz6A X-Gm-Message-State: AOJu0YydFc6/h4kLFXtnadIDaW5Gqv3tjvjMpc6G+t/I6cN9ykvIsYl9 u2LFxFfpa62rjDakn4Ug6MvNmQOagP//IKg2Ca5jP3BpZ1wXBi6A X-Received: by 2002:a05:6214:4a09:b0:6ab:82d6:f01c with SMTP id 6a1803df08f44-6abcd0ceedbmr202350816d6.39.1716998411358; Wed, 29 May 2024 09:00:11 -0700 (PDT) Received: from localhost (112.49.199.35.bc.googleusercontent.com. [35.199.49.112]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ad67329467sm45432966d6.95.2024.05.29.09.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 09:00:10 -0700 (PDT) Date: Wed, 29 May 2024 12:00:10 -0400 From: Willem de Bruijn To: "Abhishek Chauhan (ABC)" , Willem de Bruijn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney , Martin KaFai Lau , Martin KaFai Lau , Daniel Borkmann , bpf Cc: kernel@quicinc.com, syzbot+d7b227731ec589e7f4f0@syzkaller.appspotmail.com, syzbot+30a35a2e9c5067cc43fa@syzkaller.appspotmail.com Message-ID: <6657510aa54a4_32016c29461@willemb.c.googlers.com.notmuch> In-Reply-To: <3d04ff60-c01b-4718-ae3d-70d19ee2019a@quicinc.com> References: <20240528224935.1020828-1-quic_abchauha@quicinc.com> <665734886e2a9_31b2672946e@willemb.c.googlers.com.notmuch> <3d04ff60-c01b-4718-ae3d-70d19ee2019a@quicinc.com> Subject: Re: [PATCH net] net: validate SO_TXTIME clockid coming from userspace 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 Abhishek Chauhan (ABC) wrote: > > > On 5/29/2024 6:58 AM, Willem de Bruijn wrote: > > minor: double space before userspace > > > > Abhishek Chauhan wrote: > >> Currently there are no strict checks while setting SO_TXTIME > >> from userspace. With the recent development in skb->tstamp_type > >> clockid with unsupported clocks results in warn_on_once, which causes > >> unnecessary aborts in some systems which enables panic on warns. > >> > >> Add validation in setsockopt to support only CLOCK_REALTIME, > >> CLOCK_MONOTONIC and CLOCK_TAI to be set from userspace. > >> > >> Link: https://lore.kernel.org/netdev/bc037db4-58bb-4861-ac31-a361a93841d3@linux.dev/ > >> Link: https://lore.kernel.org/lkml/20240509211834.3235191-1-quic_abchauha@quicinc.com/ > > > > These discussions can be found directly from the referenced commit? > > If any, I'd like to the conversation we had that arrived at this > > approach. > > > Not Directly but from the patch series. > 1. First link is for why we introduced skb->tstamp_type > 2. Second link points to the series were we discussed on two approach to solve the problem > one being limit the skclockid to just TAI,MONO and REALTIME. Ah, I missed that. Perhaps point directly to the start of that follow-up conversation? https://lore.kernel.org/lkml/6bdba7b6-fd22-4ea5-a356-12268674def1@quicinc.com/ > > > >> Fixes: 1693c5db6ab8 ("net: Add additional bit to support clockid_t timestamp type") > >> Reported-by: syzbot+d7b227731ec589e7f4f0@syzkaller.appspotmail.com > >> Closes: https://syzkaller.appspot.com/bug?extid=d7b227731ec589e7f4f0 > >> Reported-by: syzbot+30a35a2e9c5067cc43fa@syzkaller.appspotmail.com > >> Closes: https://syzkaller.appspot.com/bug?extid=30a35a2e9c5067cc43fa > >> Signed-off-by: Abhishek Chauhan > >> --- > >> net/core/sock.c | 16 ++++++++++++++++ > >> 1 file changed, 16 insertions(+) > >> > >> diff --git a/net/core/sock.c b/net/core/sock.c > >> index 8629f9aecf91..f8374be9d8c9 100644 > >> --- a/net/core/sock.c > >> +++ b/net/core/sock.c > >> @@ -1083,6 +1083,17 @@ bool sockopt_capable(int cap) > >> } > >> EXPORT_SYMBOL(sockopt_capable); > >> > >> +static int sockopt_validate_clockid(int value) > > > > sock_txtime.clockid has type __kernel_clockid_t. > > > > __kernel_clockid_t is typedef of int. It is now, but the stricter type definition exists for a reason. Try to keep the strict types where possible. Besides aiding syntactic checks, it also helps self document code.