Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3702981pxb; Mon, 24 Jan 2022 15:49:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxAsOUS5wXe0KWJ8/rK7fOQZi6bLxzxTBpeO2I2ueL41zCAapTRSX2nNahnvTfq23dzjfvl X-Received: by 2002:a05:6a00:180c:b0:4c9:f19c:1e52 with SMTP id y12-20020a056a00180c00b004c9f19c1e52mr3863584pfa.35.1643068166102; Mon, 24 Jan 2022 15:49:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643068166; cv=none; d=google.com; s=arc-20160816; b=bEG4RIMzBnaU4iF3pYwCfVDlgfIXqersAC+cUBE//V8xVcvyegIndVhqaJA8pRhCF5 vyiiB0YfcfZ/wJQHe4rVOLyQYoKADWRoOTKEJJhZuqbkvIt4ihxJXP8Fdl6F5aJPEVDw yYWHrUwDNdn9uineHGc3vXYa7k9TLRwUqesDr6b493PV4tPrtmHqa5zRIWS26/iM7hfq ZcGJi0k3+0ZHzeppqS3/usv2qrT0fgsHe2eMnutJOIPIrkTotPoi+GR2X1YpHU8T9smZ HwkmJ2Nnr2lAwRW5MRhAMlZogBO18XtbxJmCI/hxXCMtYIPuwDSa2SAtynwSUknZPPJV +P2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=U98j+Y7sNco0tujbvYA16ItdKNeqaD105fkuU/DfxyY=; b=mTZgueQnYukUywRj6HvHK7DzwzcaCSmNcKlrWoxa2L6qpIa5sFU8bOrrY03NZ5t9EP dxC+ss7FIm8JRXgMRhS4TzSD2jO+hB2dD3l0Ye2jvi0CMhf/igQHWkc7MASdiPulShFM ioG5gE0UdIOFqK+JmLlOH0GeSBO9Q6eCVGcLrYgQMcrkC2WEvEkMf3YxGXE/XOQ4xWQM GXb6Ld0MbQgW7jbpELuPxXZLrW5ehFTPv3goLgliTHAd0l+pIrTDthTcWVNEZ/St5pzU uxUXZDg7COk60jPXJ/Rn+XDtnok3HJ5p3hRXazzi6tclyXDZVZyHLk0V0kQwNLSIKGe8 10PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nGOYJoBo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p23si15622563plr.512.2022.01.24.15.49.14; Mon, 24 Jan 2022 15:49:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nGOYJoBo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2362269AbiAXXmF (ORCPT + 99 others); Mon, 24 Jan 2022 18:42:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1842547AbiAXXCF (ORCPT ); Mon, 24 Jan 2022 18:02:05 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF9ECC0F057C; Mon, 24 Jan 2022 13:14:23 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4F91F614FC; Mon, 24 Jan 2022 21:14:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27A8BC340E5; Mon, 24 Jan 2022 21:14:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058862; bh=hPGCHYzswTPBY7Jbzbp86wCDznBp1EHftpZ+lmBxNp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nGOYJoBo9bhZkZjROE9x79p7kEtC0H78faIKbh304F9xG8KmCgV8nluiWSkhPvrRg lJiBE9/qPumtRssI1I929pvhBxNmahQ41IKwddbat+XzETD2FAwAlwLj3NKfOe5Hz+ gAsR+8/dxCIWcImYSlH1RbAKY5TYsZ03c/oHEx9M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , "David S. Miller" , Sasha Levin Subject: [PATCH 5.16 0426/1039] netrom: fix api breakage in nr_setsockopt() Date: Mon, 24 Jan 2022 19:36:55 +0100 Message-Id: <20220124184139.620652801@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit dc35616e6c2907b0c0c391a205802d8880f7fd85 ] This needs to copy an unsigned int from user space instead of a long to avoid breaking user space with an API change. I have updated all the integer overflow checks from ULONG to UINT as well. This is a slight API change but I do not expect it to affect anything in real life. Fixes: 3087a6f36ee0 ("netrom: fix copying in user data in nr_setsockopt") Signed-off-by: Dan Carpenter Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/netrom/af_netrom.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index f1ba7dd3d253d..fa9dc2ba39418 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -298,7 +298,7 @@ static int nr_setsockopt(struct socket *sock, int level, int optname, { struct sock *sk = sock->sk; struct nr_sock *nr = nr_sk(sk); - unsigned long opt; + unsigned int opt; if (level != SOL_NETROM) return -ENOPROTOOPT; @@ -306,18 +306,18 @@ static int nr_setsockopt(struct socket *sock, int level, int optname, if (optlen < sizeof(unsigned int)) return -EINVAL; - if (copy_from_sockptr(&opt, optval, sizeof(unsigned long))) + if (copy_from_sockptr(&opt, optval, sizeof(opt))) return -EFAULT; switch (optname) { case NETROM_T1: - if (opt < 1 || opt > ULONG_MAX / HZ) + if (opt < 1 || opt > UINT_MAX / HZ) return -EINVAL; nr->t1 = opt * HZ; return 0; case NETROM_T2: - if (opt < 1 || opt > ULONG_MAX / HZ) + if (opt < 1 || opt > UINT_MAX / HZ) return -EINVAL; nr->t2 = opt * HZ; return 0; @@ -329,13 +329,13 @@ static int nr_setsockopt(struct socket *sock, int level, int optname, return 0; case NETROM_T4: - if (opt < 1 || opt > ULONG_MAX / HZ) + if (opt < 1 || opt > UINT_MAX / HZ) return -EINVAL; nr->t4 = opt * HZ; return 0; case NETROM_IDLE: - if (opt > ULONG_MAX / (60 * HZ)) + if (opt > UINT_MAX / (60 * HZ)) return -EINVAL; nr->idle = opt * 60 * HZ; return 0; -- 2.34.1