Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp175631rdb; Sat, 27 Jan 2024 01:44:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGb4WoU0Z3WsyqwYORCCa2aknVEitwJEc9zna2B03oYmjG9w6W0bGjssdY425ISXTRo4f0/ X-Received: by 2002:a05:620a:5626:b0:783:76ac:fd8f with SMTP id vv6-20020a05620a562600b0078376acfd8fmr1356521qkn.131.1706348665319; Sat, 27 Jan 2024 01:44:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706348665; cv=pass; d=google.com; s=arc-20160816; b=oGzKSoRJkmLtSAQ3hSTcJH55mYIJsTiWFwqniFXCSzZsUKfH4C/zH0Fi+lQ/FahaTH rgPtSMS01hYbLu4wlKp0RDGD/Ugpe97wLqqZyBuLxeSgCtvq9OAvLl+UBKoR2jRMWsws sRTKg2ALuEAkojBXFoZQ0j5Sm2Gij6xndgGFoC+d4P89cLneX7Ge0D0ikCn35VNo5Jke G804wOGBgVL6NIpIC2MxtDt7fYY0JVkseGcnJ5ZDU9iY9NViHwmyiepap2eTDUWfzZZw ggFnVR1ppFsijwhqBTOyeIJMkehbzXm+2POIMFtwL8uvgopYVDDA4ihHZ/o5Po7VjTIF s1JQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=GFZ75ouhCuL4FL5l9x6XpSxnz3lxAM7P5KjxjfPpp9A=; fh=92dyweTqOeFTuGThZO8+myTsUebNaU6XYotgUqUUj9g=; b=AcvesdhHRyOeySuAbkR7a0rNNqg055teGd6/MH0WYh/deCXpg2Wxf7mPAN56YOaq6F ktwkskbaVNeD500itK8oA1S3jHQo2vV8TLoLNDcfUxWcJ3P2UK1Oo4cqOcPwgcCrWjQC nEqD5eP00OidEPpqPT/6TvYa/lJSwXUVnJ2WuHdbqTmC9zgi3bqE21ZZYU5xWuXMDz72 dshE03wlKzaZCipz79euhAQ3atbVj5Akql7+pdw2wAC2jMmBUozSAWY00gl+lL+Jm0vC tP9sOHXqOBbGH1/Q0ZOjxLYBpPUUkjQaL9afVVHMxCA/wjKOnkAO1hQC1NCBCImvXuzZ 1swg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DtH5T7sl; 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-41137-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41137-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. [147.75.199.223]) by mx.google.com with ESMTPS id o16-20020a05620a229000b0077f017ae9fesi3060521qkh.529.2024.01.27.01.44.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 01:44:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41137-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=@gmail.com header.s=20230601 header.b=DtH5T7sl; 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-41137-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41137-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 C23A31C21D31 for ; Sat, 27 Jan 2024 09:44:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 20F701EB25; Sat, 27 Jan 2024 09:44:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DtH5T7sl" Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.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 B1BF31EA72; Sat, 27 Jan 2024 09:44:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706348655; cv=none; b=L39QJTVDszdyoi9jhRcdOH3E87KGjZa6KCuh3OsAP5fgDh1UFhVrpNt3udSiHxfGki11i+dZoRKwhjpiGdNolnz312nrCrBA6APNFfK3iGXsNMwzJEB18ZlSjBudsR5wh7AlUNUxP196/sJyu4VEtQOcsv02vOtteO6UthsoFPg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706348655; c=relaxed/simple; bh=kVhSTIelyXWQSAD16/k9ltTCONBkMFXBG2lAiytbs0c=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=F8DZKUml4V6myUsTlwz8QegQtjr89NEDnz2dYqGnzM7qW67bvG+CJVwcTyuYiCedI2poR6HSz2f0zAThwmU4Mqz1PxinGiwx9qPWERrTgPJf6XLthXpZNF90+aPOAiOcB4y432qDGREynn8tW1aR71fiDV5/QiGg5EC7eEo9Szg= 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=DtH5T7sl; arc=none smtp.client-ip=209.85.218.53 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-ej1-f53.google.com with SMTP id a640c23a62f3a-a2d7e2e7fe0so233216866b.1; Sat, 27 Jan 2024 01:44:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706348652; x=1706953452; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=GFZ75ouhCuL4FL5l9x6XpSxnz3lxAM7P5KjxjfPpp9A=; b=DtH5T7slxkCn4PbIDOWmX9xGtnhlu53UHDcLZi2uLFeVEdF8iQ4SgYM8LnFSDoNMUL 6morIpj3bjFWQf9mYC8eHVLcoG94oa5ATftW6E5OEPX8gnNdVcPrmJcvg8gc22qk6aG7 ojkfJvCUkF9sV+DPAKHrIJYOOHrG6aKnakGvscsD8OVtrQ5kNO6D1Ug8DiwCqkknZ+aj jkSiYQPRYHHk4liEVUOGgKSMjxaB1iZWQrF2hfy7/oNAfcnxuD0iw5rnK9GYyK17G5Dr 6cVT4qDxiisDEqjwpcIOt1YOoM5yIl+r2CHr/rsRmUYpiNVSMDz9sxHMLDundv3of8lg JDYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706348652; x=1706953452; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GFZ75ouhCuL4FL5l9x6XpSxnz3lxAM7P5KjxjfPpp9A=; b=vH72iupAgReTPPkZHR0IOsrM9qnswl9GxnKZ7qXkbPGWYekCIRLTe14e1SOx59QSb0 FV2o81qMUn93Rv6M8wi3if6IBHvYt4VUYarIDLgXyg2zJ/G91CTtZxgAXes9yKCZicPF 8TSZBjwWvgxRWxmCDwE4ahNN8lgdu99MVbScHhb2N9CY8yIDLtAqrPgFWMUociacwiC5 YIAJJ9qL27mu3VSPw4A36Fsf+d01UfOo3KUrKzgcmuQIMgNdXTbb78+kkAhmX+wyrX3E AcaFoHmtnKUVYJaeylvdb/cqF65MGCobo6GbY8BB8NfcJvXK75cNONkVBJPzi3XrvZUv eJ4Q== X-Gm-Message-State: AOJu0YzWSpNV/0M47cmppUKF5zaDDIdUzqrfTcuEMdpsdbjBZQzY3U/0 Z7TRzgWd2Y6SdhW2KYeiRPkMB8MCLpxdGXj6n57cMx3IsMGFRH4= X-Received: by 2002:a17:907:a0d3:b0:a35:278:1c23 with SMTP id hw19-20020a170907a0d300b00a3502781c23mr3487263ejc.35.1706348651715; Sat, 27 Jan 2024 01:44:11 -0800 (PST) Received: from p183 ([46.53.251.60]) by smtp.gmail.com with ESMTPSA id sf5-20020a1709078a8500b00a353bfdd411sm497828ejc.59.2024.01.27.01.44.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 01:44:11 -0800 (PST) Date: Sat, 27 Jan 2024 12:44:09 +0300 From: Alexey Dobriyan To: Baokun Li Cc: linux-ext4@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, ritesh.list@gmail.com, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, chengzhihao1@huawei.com, yukuai3@huawei.com, libaokun1@huawei.com Subject: Re: [PATCH 1/7] ext4: avoid overflow when setting values via sysfs Message-ID: <1da0649d-812f-4dee-9c1b-af567afa2e46@p183> 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-Disposition: inline Baokun Li wrote: > @@ -463,6 +463,8 @@ static ssize_t ext4_attr_store(struct kobject *kobj, > ret = kstrtoul(skip_spaces(buf), 0, &t); > if (ret) > return ret; > + if (t != (unsigned int)t) > + return -EINVAL; kstrto*() interface has variants for all standard types. It should be changed to kstrtou32() or kstrtouint(); If you check if kstrto*() result fits into another type, you're probably doing it wrong. > if (a->attr_ptr == ptr_ext4_super_block_offset) > *((__le32 *) ptr) = cpu_to_le32(t);